From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03449.html | 825 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 825 insertions(+) create mode 100644 docs/doxygen/nel/a03449.html (limited to 'docs/doxygen/nel/a03449.html') diff --git a/docs/doxygen/nel/a03449.html b/docs/doxygen/nel/a03449.html new file mode 100644 index 00000000..6267c957 --- /dev/null +++ b/docs/doxygen/nel/a03449.html @@ -0,0 +1,825 @@ + + +NeL: NLMISC::CStringIdArray class Reference + + + +
+

NLMISC::CStringIdArray Class Reference

#include <string_id_array.h> +

+


Detailed Description

+The goal of this class is to associate number and string. It is used in the CCallbackNetBase for message id<->string associations.
Author:
Vianney Lecroart

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 50 of file string_id_array.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Types

typedef sint16 TStringId

Public Member Functions

void addString (const std::string &str)
 Adds a string in the string at the end of the array.

void addString (const std::string &str, TStringId id)
 Adds a string in the string in the array.

void clear ()
 Clears the string id array.

 CStringIdArray ()
void display ()
 Displays all association of the array in a C style (useful to copy/paste in your C code).

const std::set< std::string > & getAskedStringArray () const
 Returns all string in the _AskedStringArray.

TStringId getId (const std::string &str, bool IgnoreIfUnknown=false)
const std::set< std::string > & getNeedToAskedStringArray () const
 Returns all string in the _NeedToAskStringArray.

std::string getString (TStringId id) const
 Returns the string associated to this id.

void ignoreAllUnknownId (bool b)
 If set to true, when we ask a string with no id, we don't put it in the _NeedToAskStringArray array.

void moveNeedToAskToAskedStringArray ()
 Moves string from _NeedToAskStringArray to _AskedStringArray.

void resize (TStringId size)
 Set the size of the _StringArray.

TStringId size () const
 Returns the size of the _StringArray.


Private Attributes

std::set< std::string > _AskedStringArray
bool _IgnoreAllUnknownId
std::set< std::string > _NeedToAskStringArray
std::vector< std::string > _StringArray
+


Member Typedef Documentation

+

+ + + + +
+ + +
typedef sint16 NLMISC::CStringIdArray::TStringId +
+
+ + + + + +
+   + + +

+ +

+Definition at line 54 of file string_id_array.h. +

+Referenced by NLNET::CUnifiedNetwork::addCallbackArray(), NLNET::CNetManager::addCallbackArray(), NLNET::CCallbackNetBase::addCallbackArray(), addString(), NLNET::CCallbackNetBase::baseUpdate(), NLNET::cbnbMessageAskAssociations(), NLNET::cbnbMessageRecvAssociations(), getId(), NLNET::CMessage::getId(), getString(), NLNET::CCallbackNetBase::processOneMessage(), NLNET::CMessage::readType(), resize(), NLNET::CCallbackServer::sendAllMyAssociations(), NLNET::CCallbackNetBase::setOtherSideAssociations(), NLNET::CMessage::setType(), and size().

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NLMISC::CStringIdArray::CStringIdArray  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 56 of file string_id_array.h. +

+References _IgnoreAllUnknownId. +

+

00056 : _IgnoreAllUnknownId(false) { }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CStringIdArray::addString const std::string &  str  )  [inline]
+
+ + + + + +
+   + + +

+Adds a string in the string at the end of the array. +

+ +

+Definition at line 77 of file string_id_array.h. +

+References _StringArray, addString(), nlassert, and TStringId. +

+

00078         {
+00079                 nlassert (_StringArray.size () < pow(2, sizeof (TStringId)*8));
+00080                 nlassert (!str.empty());
+00081 
+00082                 // add at the end
+00083                 addString (str, _StringArray.size ());
+00084         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLMISC::CStringIdArray::addString const std::string &  str,
TStringId  id
[inline]
+
+ + + + + +
+   + + +

+Adds a string in the string in the array. +

+ +

+Definition at line 59 of file string_id_array.h. +

+References _AskedStringArray, _IgnoreAllUnknownId, _NeedToAskStringArray, _StringArray, nlassert, sint32, and TStringId. +

+Referenced by NLNET::CCallbackNetBase::addCallbackArray(), addString(), NLNET::cbnbMessageRecvAssociations(), and NLNET::CCallbackNetBase::setOtherSideAssociations(). +

+

00060         {
+00061                 nlassert (id >= 0 && id < pow(2, sizeof (TStringId)*8));
+00062                 nlassert (!str.empty());
+00063 
+00064                 if (id >= (sint32) _StringArray.size())
+00065                         _StringArray.resize(id+1);
+00066 
+00067                 _StringArray[id] = str;
+00068 
+00069                 if (!_IgnoreAllUnknownId)
+00070                 {
+00071                         _AskedStringArray.erase (str);
+00072                         _NeedToAskStringArray.erase (str);
+00073                 }
+00074         }
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CStringIdArray::clear void   )  [inline]
+
+ + + + + +
+   + + +

+Clears the string id array. +

+ +

+Definition at line 179 of file string_id_array.h. +

+References _AskedStringArray, _NeedToAskStringArray, and _StringArray. +

+

00180         {
+00181                 _StringArray.clear ();
+00182                 _NeedToAskStringArray.clear ();
+00183                 _AskedStringArray.clear ();
+00184         }
+
+

+ + + + +
+ + + + + + + + + +
void NLMISC::CStringIdArray::display  )  [inline]
+
+ + + + + +
+   + + +

+Displays all association of the array in a C style (useful to copy/paste in your C code). +

+ +

+Definition at line 187 of file string_id_array.h. +

+References _StringArray, nlinfo, and uint. +

+Referenced by NLNET::CCallbackNetBase::displayAllMyAssociations(). +

+

00188         {
+00189                 nlinfo ("static const char *OtherSideAssociations[] = {");
+00190                 for (uint i = 0; i < _StringArray.size(); i++)
+00191                 {
+00192                         nlinfo(" \"%s\",", _StringArray[i].c_str());
+00193                 }
+00194                 nlinfo ("};");
+00195         }
+
+

+ + + + +
+ + + + + + + + + +
const std::set<std::string>& NLMISC::CStringIdArray::getAskedStringArray  )  const [inline]
+
+ + + + + +
+   + + +

+Returns all string in the _AskedStringArray. +

+ +

+Definition at line 160 of file string_id_array.h. +

+References _AskedStringArray. +

+Referenced by NLNET::CCallbackNetBase::baseUpdate(). +

+

00161         {
+00162                 return _AskedStringArray;
+00163         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
TStringId NLMISC::CStringIdArray::getId const std::string &  str,
bool  IgnoreIfUnknown = false
[inline]
+
+ + + + + +
+   + + +

+Returns the id associated to string str. If the id is not found, the string will be added in _NeedToAskStringArray if ignoreAllUnknownId is false and IgnoreIfUnknown is false too. +

+Definition at line 89 of file string_id_array.h. +

+References _AskedStringArray, _IgnoreAllUnknownId, _NeedToAskStringArray, _StringArray, nlassert, and TStringId. +

+Referenced by NLNET::cbnbMessageAskAssociations(), and NLNET::CMessage::toString(). +

+

00090         {
+00091                 nlassert (!str.empty());
+00092 
+00093                 // sorry for this bullshit but it's the simplest way ;)
+00094                 if (this == NULL) return -1;
+00095 
+00096                 for (TStringId i = 0; i < (TStringId) _StringArray.size(); i++)
+00097                 {
+00098                         if (_StringArray[i] == str)
+00099                                 return i;
+00100                 }
+00101 
+00102                 if (!_IgnoreAllUnknownId && !IgnoreIfUnknown)
+00103                 {
+00104                         // the string is not found, add it to the _AskedStringArray if necessary
+00105                         if (_NeedToAskStringArray.find (str) == _NeedToAskStringArray.end ())
+00106                         {
+00107                                 if (_AskedStringArray.find (str) == _AskedStringArray.end ())
+00108                                 {
+00109                                         //nldebug ("String '%s' not found, add it to _NeedToAskStringArray", str.c_str ());     
+00110                                         _NeedToAskStringArray.insert (str);
+00111                                 }
+00112                                 else
+00113                                 {
+00114                                         //nldebug ("Found '%s' in the _AskedStringArray", str.c_str ());        
+00115                                 }
+00116                         }
+00117                         else
+00118                         {
+00119                                 //nldebug ("Found '%s' in the _NeedToAskStringArray", str.c_str ());    
+00120                         }
+00121                 }
+00122                 else
+00123                 {
+00124                         //nldebug ("Ignoring unknown association ('%s')", str.c_str ());        
+00125                 }
+00126 
+00127                 return -1;
+00128         }
+
+

+ + + + +
+ + + + + + + + + +
const std::set<std::string>& NLMISC::CStringIdArray::getNeedToAskedStringArray  )  const [inline]
+
+ + + + + +
+   + + +

+Returns all string in the _NeedToAskStringArray. +

+ +

+Definition at line 154 of file string_id_array.h. +

+References _NeedToAskStringArray. +

+Referenced by NLNET::CCallbackNetBase::baseUpdate(). +

+

00155         {
+00156                 return _NeedToAskStringArray;
+00157         }
+
+

+ + + + +
+ + + + + + + + + + +
std::string NLMISC::CStringIdArray::getString TStringId  id  )  const [inline]
+
+ + + + + +
+   + + +

+Returns the string associated to this id. +

+ +

+Definition at line 131 of file string_id_array.h. +

+References _StringArray, nlassert, and TStringId. +

+Referenced by NLNET::CCallbackServer::sendAllMyAssociations(), NLNET::CMessage::setType(), and NLNET::CMessage::toString(). +

+

00132         {
+00133                 // sorry for this bullshit but it's the simplest way ;)
+00134                 if (this == NULL) return "<NoSIDA>";
+00135 
+00136                 nlassert (id >= 0 && id < (TStringId)_StringArray.size());
+00137 
+00138                 return _StringArray[id];
+00139         }
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CStringIdArray::ignoreAllUnknownId bool  b  )  [inline]
+
+ + + + + +
+   + + +

+If set to true, when we ask a string with no id, we don't put it in the _NeedToAskStringArray array. +

+ +

+Definition at line 176 of file string_id_array.h. +

+References _IgnoreAllUnknownId. +

+Referenced by NLNET::cbcMessageRecvAllAssociations(), NLNET::CCallbackClient::CCallbackClient(), and NLNET::CCallbackNetBase::ignoreAllUnknownId(). +

+

00176 { _IgnoreAllUnknownId = b; }
+
+

+ + + + +
+ + + + + + + + + +
void NLMISC::CStringIdArray::moveNeedToAskToAskedStringArray  )  [inline]
+
+ + + + + +
+   + + +

+Moves string from _NeedToAskStringArray to _AskedStringArray. +

+ +

+Definition at line 166 of file string_id_array.h. +

+References _AskedStringArray, _IgnoreAllUnknownId, and _NeedToAskStringArray. +

+Referenced by NLNET::CCallbackNetBase::baseUpdate(). +

+

00167         {
+00168                 if (!_IgnoreAllUnknownId)
+00169                 {
+00170                         _AskedStringArray.insert (_NeedToAskStringArray.begin(), _NeedToAskStringArray.end());
+00171                         _NeedToAskStringArray.clear ();
+00172                 }
+00173         }
+
+

+ + + + +
+ + + + + + + + + + +
void NLMISC::CStringIdArray::resize TStringId  size  )  [inline]
+
+ + + + + +
+   + + +

+Set the size of the _StringArray. +

+ +

+Definition at line 142 of file string_id_array.h. +

+References _StringArray, size, and TStringId. +

+Referenced by NLNET::CCallbackNetBase::addCallbackArray(). +

+

00143         {
+00144                 _StringArray.resize (size);
+00145         }
+
+

+ + + + +
+ + + + + + + + + +
TStringId NLMISC::CStringIdArray::size  )  const [inline]
+
+ + + + + +
+   + + +

+Returns the size of the _StringArray. +

+ +

+Definition at line 148 of file string_id_array.h. +

+References _StringArray, and TStringId. +

+Referenced by NLNET::CCallbackNetBase::addCallbackArray(), and NLNET::CCallbackServer::sendAllMyAssociations(). +

+

00149         {
+00150                 return _StringArray.size ();
+00151         }
+
+


Field Documentation

+

+ + + + +
+ + +
std::set<std::string> NLMISC::CStringIdArray::_AskedStringArray [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 205 of file string_id_array.h. +

+Referenced by addString(), clear(), getAskedStringArray(), getId(), and moveNeedToAskToAskedStringArray().

+

+ + + + +
+ + +
bool NLMISC::CStringIdArray::_IgnoreAllUnknownId [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 199 of file string_id_array.h. +

+Referenced by addString(), CStringIdArray(), getId(), ignoreAllUnknownId(), and moveNeedToAskToAskedStringArray().

+

+ + + + +
+ + +
std::set<std::string> NLMISC::CStringIdArray::_NeedToAskStringArray [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 203 of file string_id_array.h. +

+Referenced by addString(), clear(), getId(), getNeedToAskedStringArray(), and moveNeedToAskToAskedStringArray().

+

+ + + + +
+ + +
std::vector<std::string> NLMISC::CStringIdArray::_StringArray [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 201 of file string_id_array.h. +

+Referenced by addString(), clear(), display(), getId(), getString(), resize(), and size().

+


The documentation for this class was generated from the following file: +
Generated on Tue Mar 16 13:35:36 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1