00001 #ifndef NameAttributeValue_H 00002 #define NameAttributeValue_H 00003 00004 // --8<--8<--8<--8<-- 00005 // 00006 // Copyright (C) 2006 Smithsonian Astrophysical Observatory 00007 // 00008 // This file is part of paramxx 00009 // 00010 // paramxx is free software; you can redistribute it and/or 00011 // modify it under the terms of the GNU General Public License 00012 // as published by the Free Software Foundation; either version 2 00013 // of the License, or (at your option) any later version. 00014 // 00015 // paramxx 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, write to the 00022 // Free Software Foundation, Inc. 00023 // 51 Franklin Street, Fifth Floor 00024 // Boston, MA 02110-1301, USA 00025 // 00026 // -->8-->8-->8-->8-- 00027 00028 #include <iostream> 00029 #include <string> 00030 00031 using namespace std; 00032 00040 class NameAttributeValue { 00041 00045 friend ostream& operator << ( ostream& os, NameAttributeValue& a ) { 00046 a.print( os ); 00047 return os; 00048 } 00049 00053 friend ostream& operator << ( ostream& os, NameAttributeValue* a ) { 00054 a->print( os ); 00055 return os; 00056 } 00057 00058 public: 00059 00061 virtual ~NameAttributeValue( ) { } 00062 00064 NameAttributeValue( ) : name( "" ), attribute( "" ), value( "" ) { } 00065 00070 NameAttributeValue( const char* str ) { init_NameAttributeValue( str ); } 00071 00073 string get_attribute( void ) { return attribute; } 00074 00076 string get_name( void ) const { return name; } 00077 00079 string get_value( void ) const { return value; } 00080 00082 void init_NameAttributeValue( const char* str ); 00083 00085 virtual void print( ostream& os=cerr ); 00086 00088 void set_attribute( const char* a ) { attribute = a; } 00089 00091 void set_name( const char* n ) { name = n; } 00092 00094 void set_value( const char* v ) { value = v; } 00095 00096 protected: 00097 00098 string name; 00099 00100 string attribute; 00101 00102 string value; 00103 00104 private: 00105 00106 bool check_boolean( char* str ); 00107 00108 void seperate_keyword_attribute( char* ); 00109 00110 void seperate_keyword_value( char* ); 00111 00112 NameAttributeValue( const NameAttributeValue& s ); 00113 NameAttributeValue& operator = ( const NameAttributeValue& rhs ); 00114 00115 }; 00116 00117 #endif