identifier.h

Go to the documentation of this file.
00001 /**
00002  * \file identifier.h <mi32/identifier.h>
00003  * \brief IDENTIFIER class definition
00004  *
00005  * \if NODOC
00006  * $Id: identifier.h_v 1.12 2004/07/20 16:38:41 mju Exp $
00007  *
00008  * $Log: identifier.h_v $
00009  * Revision 1.12  2004/07/20 16:38:41  mju
00010  * Add set methods.
00011  *
00012  * Revision 1.11  2004/04/20 13:48:30  mju
00013  * Change IDENTIFIERLIST to class and add FindId method.
00014  *
00015  * Revision 1.10  2004/04/01 21:28:02  mju
00016  * Include mistring hdr.
00017  *
00018  * Revision 1.9  2004/04/01 20:43:15  mju
00019  * Add Assign methods using Latin1 and UTF8 strings.
00020  *
00021  * Revision 1.8  2003/09/29 16:25:56  mju
00022  * Add ctor/op= from string.
00023  *
00024  * Revision 1.7  2003/09/18 16:04:48  mju
00025  * Add getfullstr.
00026  *
00027  * Revision 1.6  2003/09/15 13:49:56  fileserver!dwilliss
00028  * Doxygen
00029  *
00030  * Revision 1.5  2003/09/03 20:13:04  mju
00031  * Add operator<.
00032  *
00033  * Revision 1.4  2003/08/20 19:25:10  mju
00034  * Add default ctor and CreateFromXML method.
00035  *
00036  * Revision 1.3  2003/08/18 20:01:50  mju
00037  * Fix template instantiation.
00038  *
00039  * Revision 1.2  2003/08/18 17:43:50  mju
00040  * Add op==/op!=.
00041  *
00042  * Revision 1.1  2003/08/18 14:37:05  mju
00043  * Initial revision
00044  * \endif
00045 **/
00046 
00047 #ifndef  INC_MI32_IDENTIFIER_H
00048 #define  INC_MI32_IDENTIFIER_H
00049 
00050 #ifndef  INC_MI32_CODESPACE_H
00051 #include <mi32/codespace.h>
00052 #endif
00053 
00054 #ifndef  INC_MI32_MISTRING_H
00055 #include <mi32/mistring.h>
00056 #endif
00057 
00058 #ifndef  INC_MI32_STRUTF8_H
00059 #include <mi32/strutf8.h>
00060 #endif
00061 
00062 #ifndef  INC_MI32_MILIST_H
00063 #include <mi32/milist.h>
00064 #endif
00065 
00066 #ifndef GENERATING_DOXYGEN_OUTPUT
00067 class XMLNODE;
00068 #endif // GENERATING_DOXYGEN_OUTPUT
00069 
00070 #ifdef MISYSTEMDLL
00071    #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00072 #else
00073    #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00074 #endif
00075 
00076 
00077 //! Identifier container used to reference specific persistent object instance.
00078 class CLASSLIBEXPORT IDENTIFIER {
00079    public:
00080 
00081       //! Default constructor.
00082       IDENTIFIER (
00083          );
00084 
00085       //! Construct using numeric code.
00086       IDENTIFIER (
00087          CODESPACE codespace,
00088          INT32 codenum
00089          );
00090 
00091       //! Construct using string code in specified codespace.
00092       //! If string contains a single integer value it will be converted to a number.
00093       IDENTIFIER (
00094          CODESPACE codespace,
00095          const char *codestr
00096          );
00097 
00098       //! Construct using string code.
00099       //! If string contains a single integer value it will be converted to a number.
00100       IDENTIFIER (
00101          const char *codestr
00102          );
00103 
00104       //! Destructor.
00105       ~IDENTIFIER (
00106          );
00107 
00108       //! Assign from  string code.
00109       //! If string contains a single integer value it will be converted to a number.
00110       IDENTIFIER& operator= (
00111          const char *codestr              //!< Code string in form "codespacename:code", Latin1 encoding
00112          );
00113 
00114       #ifndef GENERATING_DOXYGEN_OUTPUT
00115       //! Used by MILIST::Sort().
00116       bool operator< (
00117          const IDENTIFIER& rhs
00118          ) const;
00119       #endif
00120 
00121       //! Assign from string code.
00122       //! If string contains a single integer value it will be converted to a number.
00123       ERRVALUE Assign (
00124          const char *codestr              //!< Code string in form "codespacename:code", Latin1 encoding
00125          );
00126 
00127       //! Assign from string code.
00128       //! If string contains a single integer value it will be converted to a number.
00129       ERRVALUE Assign (
00130          const UINT8 *codestr             //!< Code string in form "codespacename:code", UTF8 encoding
00131          );
00132 
00133    #ifndef NODLLLINKAGE
00134       //! Create identifier from XML node.
00135       //! Node must be in the form:
00136       //! <tt>
00137       //!  <nodename>codespacename:code</nodename>
00138       //! </tt>
00139       //! The nodename itself is not relevent.
00140       //! If the codespace is not specified the CODESPACE_MicroImages will be used.
00141       ERRVALUE CreateFromXML (
00142          const XMLNODE *xmlnode
00143          );
00144    #endif
00145 
00146       //! Get codespace enumeration.
00147       CODESPACE GetCodespace (
00148          ) const;
00149 
00150       //! Get full identifier string in form "codespace:id".
00151       MISTRING GetFullStr (
00152          ) const;
00153 
00154       //! Get code number.
00155       //! @return Code number, 0 if not numeric.
00156       INT32 GetNum (
00157          ) const;
00158 
00159       //! Get code string.
00160       //! @return Code string
00161       const STRUTF8& GetStr (
00162          ) const;
00163 
00164       //! Set codespace and numeric code.
00165       void Set (
00166          CODESPACE codespace,
00167          INT32 num
00168          );
00169 
00170       //! Set codespace and string code.
00171       void Set (
00172          CODESPACE codespace,
00173          const char *code
00174          );
00175 
00176       #ifndef GENERATING_DOXYGEN_OUTPUT
00177       // Comparison for equality.
00178       bool IsEqual (const IDENTIFIER& rhs) const;
00179       #endif
00180 
00181    private:
00182       #ifndef GENERATING_DOXYGEN_OUTPUT
00183       CODESPACE m_codespace;
00184       INT32 m_num;
00185       STRUTF8 m_str;
00186 
00187       void SetNumFromStr ();
00188       #endif // GENERATING_DOXYGEN_OUTPUT
00189    };
00190 
00191 inline bool operator== (
00192    const IDENTIFIER& lhs,
00193    const IDENTIFIER& rhs
00194    ) { return (lhs.IsEqual(rhs)); }
00195 
00196 inline bool operator!= (
00197    const IDENTIFIER& lhs,
00198    const IDENTIFIER& rhs
00199    ) { return (!lhs.IsEqual(rhs)); }
00200 
00201 /*
00202 #if defined(WIN32) && !defined(MISYSTEMDLL) && !defined(NODLLLINKAGE)
00203 #pragma warning(disable:4231)
00204 extern template class CLASSLIBEXPORT MILIST<IDENTIFIER>;    // Template instantiation
00205 #pragma warning(default:4231)
00206 #endif
00207 typedef MILIST<IDENTIFIER> IDENTIFIERLIST;
00208 */
00209 
00210 class CLASSLIBEXPORT IDENTIFIERLIST : public MILIST<IDENTIFIER> {
00211    public:
00212       //! Find identifier in list with specified codespace.
00213       //! @return true if match found, false if not
00214       bool FindId (
00215          CODESPACE codespace,
00216          IDENTIFIER& id
00217          ) const;
00218    };
00219 
00220 #undef   CLASSLIBEXPORT
00221 
00222 #endif   // INC_MI32_IDENTIFIER_H

Generated on Tue Dec 14 13:18:24 2004 for TNTsdk by  doxygen 1.3.8-20040913