Tanl Linguistic Pipeline |
00001 /* 00002 ** IXE 00003 ** Common/eptacode.h 00004 ** ---------------------------------------------------------------------- 00005 ** Copyright (c) 2000 Ideare SpA. All rights reserved. 00006 ** Copyright (c) 2000 Giuseppe Attardi (attardi@di.unipi.it) 00007 ** ---------------------------------------------------------------------- 00008 ** 00009 ** This file is part of IXE. 00010 ** 00011 ** IXE is free software; you can redistribute it and/or modify it 00012 ** under the terms of the GNU General Public License, version 3, 00013 ** as published by the Free Software Foundation. 00014 ** 00015 ** IXE is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 ** GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 ** ---------------------------------------------------------------------- 00023 */ 00024 00025 #ifndef IXE_eptacode_H 00026 #define IXE_eptacode_H 00027 00028 // Settings 00029 #include "platform.h" 00030 00031 // standard 00032 #include <iostream> 00033 00034 namespace IXE { 00035 00036 //============================================================================= 00048 //============================================================================= 00049 00050 inline unsigned int 00051 parseEptacode(register unsigned char const *& p) 00052 { 00053 register unsigned int n = 0; 00054 register unsigned int expt = 0; 00055 register unsigned char byte; 00056 while (!((byte = *p++) & 0x80)) { 00057 n |= byte << expt; 00058 expt += 7; 00059 } 00060 n |= (byte & 0x7F) << expt; // clear sign bit 00061 return n; 00062 } 00063 00064 std::ostream& outEptacode(std::ostream&, unsigned); 00065 00066 std::ostream& padEptacode(std::ostream& o, register unsigned no, unsigned old); 00067 00072 unsigned int toEptacode(unsigned char* dst, register unsigned n); 00073 00074 struct eptacode 00075 { 00076 unsigned code; 00077 public: 00078 eptacode(unsigned a) : code(a) {} 00079 }; 00080 00081 inline std::ostream& operator <<(std::ostream& o, const eptacode& e) 00082 { 00083 return outEptacode(o, e.code); 00084 } 00085 00086 } // namespace IXE 00087 00088 #endif /* IXE_eptacode_H */