Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7219 in orxonox.OLD for branches/std/src/lib/util


Ignore:
Timestamp:
Mar 12, 2006, 5:14:44 PM (19 years ago)
Author:
bensch
Message:

orxonox/std: less char*

Location:
branches/std/src/lib/util
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/lib/util/executor/functor_list.h

    r7218 r7219  
    2121   l_SHORT:     short
    2222   l_FLOAT:     float
    23    l_CSTRING:    const char*
     23   l_STRING:    const std::string&
    2424   l_XML_ELEM:  TiXmlElement*
    2525 */
  • branches/std/src/lib/util/loading/load_param_description.cc

    r7203 r7219  
    134134 * @param className the name of the class to be loadable
    135135 */
    136 LoadClassDescription::LoadClassDescription(const char* className)
    137 {
    138   this->className = new char[strlen(className)+1];
    139   strcpy(this->className, className);
     136LoadClassDescription::LoadClassDescription(const std::string& className)
     137{
     138  this->className = className;
    140139
    141140  if (LoadClassDescription::classList == NULL)
     
    156155    this->paramList.pop_front();
    157156  }
    158 
    159   delete[] this->className;
    160157}
    161158
     
    182179   Otherwise it returns a new classDescription
    183180 */
    184 LoadClassDescription* LoadClassDescription::addClass(const char* className)
     181LoadClassDescription* LoadClassDescription::addClass(const std::string& className)
    185182{
    186183  if (LoadClassDescription::classList != NULL)
     
    189186    while (it != LoadClassDescription::classList->end())
    190187    {
    191       if (!strcmp((*it)->className, className))
     188      if ((*it)->className == className)
    192189      {
    193190        return (*it);
     
    200197
    201198/**
    202  *  does the same as addClass(const char* className), but with params
     199 *  does the same as addClass(const std::string& className), but with params
    203200 * @param paramName the name of the parameter to add.
    204201 */
    205 LoadParamDescription* LoadClassDescription::addParam(const char* paramName)
     202LoadParamDescription* LoadClassDescription::addParam(const std::string& paramName)
    206203{
    207204  std::list<LoadParamDescription*>::iterator it = this->paramList.begin();
     
    226223 * @todo implement it
    227224 */
    228 void LoadClassDescription::printAll(const char* fileName)
     225void LoadClassDescription::printAll(const std::string& fileName)
    229226{
    230227  PRINT(3)("===============================================================\n");
     
    235232    while (classDesc != LoadClassDescription::classList->end())
    236233    {
    237       PRINT(3)("<%s>\n", (*classDesc)->className);
     234      PRINT(3)("<%s>\n", (*classDesc)->className.c_str());
    238235      std::list<LoadParamDescription*>::iterator param = (*classDesc)->paramList.begin();
    239236      while (param != (*classDesc)->paramList.end())
     
    242239        param++;
    243240      }
    244       PRINT(3)("</%s>\n\n", (*classDesc)->className);
     241      PRINT(3)("</%s>\n\n", (*classDesc)->className.c_str());
    245242      classDesc++;
    246243    }
     
    257254 * !! The strings MUST NOT be deleted !!
    258255 */
    259 std::list<const char*> LoadClassDescription::searchClassWithShort(const char* classNameBegin)
     256std::list<std::string> LoadClassDescription::searchClassWithShort(const std::string& classNameBegin)
    260257{
    261258  /// FIXME
    262259  // NOT USED
    263260/*  unsigned int searchLength = strlen(classNameBegin);
    264   std::list<const char*> retVal;
     261  std::list<const std::string&> retVal;
    265262
    266263  tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
  • branches/std/src/lib/util/loading/load_param_description.h

    r7203 r7219  
    5959  friend class CLoadParam;
    6060public:
    61   LoadClassDescription(const char* className);
     61  LoadClassDescription(const std::string& className);
    6262  ~LoadClassDescription();
    6363
    64   static LoadClassDescription* addClass(const char* className);
    65   LoadParamDescription* addParam(const char* paramName);
     64  static LoadClassDescription* addClass(const std::string& className);
     65  LoadParamDescription* addParam(const std::string& paramName);
    6666
    6767  static void deleteAllDescriptions();
    6868
    69   static void printAll(const char* fileName = NULL);
    70   static std::list<const char*> searchClassWithShort(const char* classNameBegin);
    71   //  static const LoadParamDescription* getClass(const char* className);
     69  static void printAll(const std::string& fileName = "");
     70  static std::list<std::string> searchClassWithShort(const std::string& classNameBegin);
     71  //  static const LoadParamDescription* getClass(const std::string& className);
    7272
    7373private:
    7474  static bool                              parametersDescription;  //!< if parameter-description should be enabled.
    7575  static std::list<LoadClassDescription*>* classList;              //!< a list, that stores all the loadable classes. (after one instance has been loaded)
    76   char*                                    className;              //!< name of the class
     76  std::string                              className;              //!< name of the class
    7777
    7878  std::list<LoadParamDescription*>         paramList;              //!< List of parameters this class knows.
  • branches/std/src/lib/util/multi_type.cc

    r7218 r7219  
    9393{
    9494  this->setChar(value);
    95 }
    96 
    97 /**
    98  * @brief creates a multiType out of a C-String
    99  * @param value the Value of this MulitType
    100  */
    101 MultiType::MultiType(const char* value)
    102 {
    103   this->setString(value);
    10495}
    10596
     
    485476 * @returns: the Type as MT_Type
    486477 */
    487 MT_Type MultiType::StringToMultiType(const char* type)
    488 {
    489   if (!strncmp(type, "bool", 4))
     478MT_Type MultiType::StringToMultiType(const std::string& type)
     479{
     480  if (type == "bool")
    490481    return MT_BOOL;
    491   if (!strncmp(type, "int", 3))
     482  if (type == "int")
    492483    return MT_INT;
    493   if (!strncmp(type, "float", 5))
     484  if (type, "float")
    494485    return MT_FLOAT;
    495   if (!strncmp(type, "char", 4))
     486  if (type == "char")
    496487    return MT_CHAR;
    497   if (!strncmp(type, "string", 6))
     488  if (type == "string")
    498489    return MT_STRING;
    499490
  • branches/std/src/lib/util/multi_type.h

    r7218 r7219  
    3939    MultiType(double value);
    4040    MultiType(char value);
    41     MultiType(const char* value);
    4241    MultiType(const std::string& value);
    4342    MultiType(const MultiType& multiType);
     
    9594
    9695    static const char* MultiTypeToString(MT_Type type);
    97     static MT_Type StringToMultiType(const char* type);
     96    static MT_Type StringToMultiType(const std::string& type);
    9897
    9998  private:
Note: See TracChangeset for help on using the changeset viewer.