00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _nv_attribute_h_
00013 #define _nv_attribute_h_
00014
00015 #pragma warning (disable:4251)
00016
00017 #include <map>
00018 #include <string>
00019
00020
00021 #if ! defined( DOXYGEN_IGNORE )
00022 class nv_attribute
00023 {
00024 typedef std::map<std::string,nv_attribute*> _dico;
00025 typedef _dico::value_type _dico_pair;
00026 typedef _dico::iterator _dico_it;
00027 typedef _dico::const_iterator _dico_cit;
00028 public:
00029
00030 enum
00031 {
00032 NV_FLOAT = 0x00000001,
00033 NV_CHAR = 0x00000002,
00034 NV_UNSIGNED_CHAR = 0x00000004,
00035 NV_UNSIGNED_INT = 0x00000008,
00036 NV_INT = 0x00000010,
00037 NV_SHORT = 0x00000040,
00038
00039 NV_ARRAY = 0x00010000,
00040 NV_FLOAT_ARRAY = 0x00010001,
00041 NV_CHAR_ARRAY = 0x00010002,
00042 NV_UNSIGNED_CHAR_ARRAY = 0x00010004,
00043 NV_UNSIGNED_INT_ARRAY = 0x00010008,
00044 NV_INT_ARRAY = 0x00010010,
00045 NV_ATTRIBUTE_ARRAY = 0x00010020,
00046 NV_SHORT_ARRAY = 0x00010040,
00047 NV_STRING = 0x00010002,
00048
00049 NV_UNASSIGNED = 0xFFFFFFFF
00050 };
00051
00052 nv_attribute();
00053 nv_attribute(const nv_attribute & attr);
00054 ~nv_attribute();
00055
00056
00057 nv_attribute & operator= (const char * str);
00058 nv_attribute & operator= (const float & val);
00059 nv_attribute & operator= (const unsigned int & val);
00060 nv_attribute & operator= (const int & val);
00061 nv_attribute & operator= (const unsigned char & val);
00062 nv_attribute & operator= (const char & val);
00063 nv_attribute & operator= (const short & val);
00064 nv_attribute & operator= (const nv_attribute & attr);
00065
00066
00067 bool is_null () const;
00068 bool is_valid () const;
00069
00070
00071 nv_attribute & operator[] (const char * name);
00072
00073
00074 void array (const nv_attribute * attribs, unsigned int size);
00075 void array (const float * fvector, unsigned int size);
00076 void array (const char * str, unsigned int size);
00077 void array (const unsigned char * str, unsigned int size);
00078 void array (const unsigned int * array, unsigned int size);
00079 void array (const int * array, unsigned int size);
00080 void array (const short * array, unsigned int size);
00081
00082
00083 float as_float () const;
00084 unsigned int as_unsigned_int () const;
00085 unsigned int as_int () const;
00086 short as_word () const;
00087 unsigned char as_uchar () const;
00088 char as_char () const;
00089 const char * as_char_array () const;
00090 const unsigned char * as_unsigned_char_array() const;
00091 const int * as_int_array () const;
00092 const unsigned int * as_unsigned_int_array() const;
00093 const float * as_float_array () const;
00094 const short * as_short_array () const;
00095 const char * as_string () const;
00096 const nv_attribute * as_attribute_array () const;
00097
00098
00099 const unsigned int get_size () const;
00100
00101
00102 const unsigned int get_type () const;
00103
00104 unsigned int get_num_attributes () const;
00105 const char * get_attribute_name (unsigned int i) const;
00106 const nv_attribute * get_attribute (unsigned int i) const;
00107
00108 friend std::ostream & operator << (std::ostream& os, const nv_attribute & attr);
00109
00110 protected:
00111
00112 void erase ();
00113 void copy_from (const nv_attribute * attr);
00114
00115 private:
00116
00117 _dico _attr;
00118
00119
00120 union
00121 {
00122 void * _pdata;
00123 unsigned char _ubyte;
00124 unsigned char _byte;
00125 short _word;
00126 unsigned int _udword;
00127 unsigned int _sdword;
00128 float _float;
00129 };
00130
00131
00132
00133 unsigned int _size;
00134
00135
00136 unsigned int _flag;
00137 };
00138 #endif // DOXYGEN_IGNORE
00139
00140 #endif // _nv_attribute_h_