00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the bit library. * 00006 * * 00007 * The bit library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The bit library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef BITFIELDTYPE_H 00020 #define BITFIELDTYPE_H 00021 00022 #include <string> 00023 00024 #include <bit/enums.h> 00025 00026 namespace bit 00027 { 00028 00032 class FieldType 00033 { 00034 public: 00035 00036 FieldType ( Type type=TYPE_NONE, ByteOrder byte_order=BYTEORDER_NETWORK, Sign sign=SIGN_UNSIGNED ); 00037 00038 ~FieldType(); 00039 00040 Type type() const; 00041 void set_type ( Type ); 00042 const char* type_string() const; 00043 00044 ByteOrder byte_order() const; 00045 void set_byte_order ( ByteOrder ); 00046 const char* byte_order_string() const; 00047 00048 Sign sign() const; 00049 void set_sign ( Sign ); 00050 const char* sign_string() const; 00051 00052 static const char* type_string ( Type ); 00053 static const char* byte_order_string ( ByteOrder ); 00054 static const char* sign_string ( Sign ); 00055 00056 bool operator== ( const FieldType& other ) const; 00057 00058 bool operator!= ( const FieldType& other ) const; 00059 00060 std::string xml() const; 00061 00062 protected: 00063 Type m_type; 00064 ByteOrder m_byte_order; 00065 Sign m_sign; 00066 00067 static const char* m_type_string[]; 00068 static const char* m_byte_order_string[]; 00069 static const char* m_sign_string[]; 00070 }; 00071 00072 } 00073 00074 #endif