Changes

Jump to navigation Jump to search
2,477 bytes added ,  17:37, 17 June 2017
→‎Id: Added class description of CMwId
Line 74: Line 74:  
Everytime a string is assigned to an Id, this string is placed into a global 2-dimensional table with its position depending on its hash (if it wasn't already in the table). This position is then stored in the Id. Because of this mechanism, Ids can be used for very fast string comparisons (like a hash) while still being reversible.
 
Everytime a string is assigned to an Id, this string is placed into a global 2-dimensional table with its position depending on its hash (if it wasn't already in the table). This position is then stored in the Id. Because of this mechanism, Ids can be used for very fast string comparisons (like a hash) while still being reversible.
   −
  struct MwId
+
  struct Id
 
  {
 
  {
 
     int value;
 
     int value;
Line 83: Line 83:  
* If bits 30 and 31 are set, the Id is empty (null). Typically ''value'' is -1 in this case.
 
* If bits 30 and 31 are set, the Id is empty (null). Typically ''value'' is -1 in this case.
   −
Ids are managed by the class CMwId.
+
<div class="mw-collapsible mw-collapsed">
 +
Ids are managed by the class CMwId:
 +
<div class="mw-collapsible-content">
 +
class CMwId
 +
{
 +
public:
 +
    __thiscall CMwId(void);  // Initializes the ID with the value -1 (Unassigned)
 +
    __thiscall CMwId(class CMwId const &);  // Initializes the id with the ID of the passed class
 +
    __thiscall ~CMwId(void);
 +
 +
    static class CMwId * Unassigned;  // Points to the first entry in the table (Unassigned)
 +
    static void __cdecl StaticInit(void);  // Called from CGbxApp::Init. Creates the name table. Creates a first ID with the value -1 (Unassigned) and adds it to the table.
 +
    static void __cdecl StaticRelease(void);  // Called from CGbxApp::Destroy. Releases the name table.
 +
 +
    static class CMwId __cdecl CreateFromLocalIndex(unsigned long);  // Calls CMwId::CMwId and sets the ID to the passed index.
 +
    static class CMwId __cdecl CreateFromTypeAndIndex(unsigned long);  // Calls CMwId::CMwId and sets the ID to the passed index.
 +
    static class CMwId __cdecl CreateFromLocalName(char const *);  // Calls CMwId::CMwId and adds the passed name to the name table using SetLocalName (bit 30 of the ID is set).
 +
    static class CMwId __cdecl CreateFromUUIdName(char const *);  // Calls CMwId::CMwId and adds the passed name to the name table using AddName (bit 31 of the ID is set).
 +
 +
    void __thiscall SetLocalName(char const *);  // Sets the ID to -1 if the name is "Unassigned"; otherwise, adds the name to the table using AddName and sets bit 30 of the ID.
 +
    void __thiscall SetLocalName(class CFastStringInt const &);  // Calls CFastStringInt::GetUtf8 and than SetLocalName.
 +
 +
    char const * __thiscall GetString(void)const;  // Gets the string to the ID if bit 30 or 31 is set; otherwise, NULL is returned.
 +
 +
    void __thiscall GetName(class CFastString &)const;  // Returns either the name of the ID using GetString, "Unassigned" if the ID is -1 or "Id<number>" if ID represents a number.
 +
    void __thiscall GetName(class CFastStringInt &)const;
 +
    class CFastString const __thiscall GetName(void)const;
 +
 +
    void __thiscall Archive(class CClassicArchive &);  // Serializes the ID. See "[[GBX#Primitives|lookbackstring]]" on the [[GBX]] page for some details.
 +
 +
private:
 +
    static struct SMwIdInternal * s_NameTable;  // Points to the name table
 +
    static unsigned long __cdecl AddName(char const *);  // Adds the name to the name table
 +
    static void __cdecl DeleteArchiveUserData(class CClassicArchive *);
 +
};
 +
</div>
 +
</div>
    
===Identifier===
 
===Identifier===

Navigation menu