// NAme.h #ifndef hes_Name_H #define hes_Name_H // David Adams // February 2002 // // A name is an immutable character string with a representation as // an array of 32-bit integers. // The first byte in the array holds the length of the character string. // There is one character/byte (ASCII coding) in the following bytes. // The highest bit in the length is reserved to allow longer strings. // This implies a maximum string length of 127 characters. // A string of length zero or length greter than 127 is invalid. // The length of the array nidx in terms of the number of characters is: // nidx = nch/4 #include "IndexVector.h" #include #include #include namespace hes { class Name { public: // static functions // Version. static int version(); private: // data std::string m_name; IndexVector m_idx; public: // methods // Default constructor. // Key is invalid. Name(); // Constructor from a string. Name(std::string key); // Constructor from a character array. Name(const char* key); // Constructor from an array of indices. // Data is taken starting and the input value of the pointer. // Output value points after the last value used. explicit Name(const Index*& pidx); // Is this a valid name? bool is_valid() const; // Return the name; std::string name() const; // Return the indices. const IndexVector& indices() const; }; } // end namespace // Ordering. bool operator<(const hes::Name& lhs, const hes::Name& rhs); // Equality. bool operator==(const hes::Name& lhs, const hes::Name& rhs); // Inequality bool operator!=(const hes::Name& lhs, const hes::Name& rhs); // Output stream. std::ostream& operator<<(std::ostream& lhs, const hes::Name& rhs); #endif