Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

orxonox/std: less char*

Location:
branches/std/src/lib
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/lib/coord/p_node.cc

    r7216 r7219  
    680680 * @param bias the speed to iterate to this new Positions
    681681 */
    682 void PNode::setParentSoft(const char* parentName, float bias)
     682void PNode::setParentSoft(const std::string& parentName, float bias)
    683683{
    684684  PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
     
    701701void PNode::setParentMode (const std::string& parentingMode)
    702702{
    703   this->setParentMode(PNode::charToParentingMode(parentingMode));
     703  this->setParentMode(PNode::stringToParentingMode(parentingMode));
    704704}
    705705
     
    927927           this->getAbsDirV().y,
    928928           this->getAbsDirV().z,
    929            this->parentingModeToChar(parentMode),
     929           this->parentingModeToString(parentMode),
    930930           childNodeCount);
    931931  if (depth >= 2 || depth == 0)
     
    10491049 * @return the converted string
    10501050 */
    1051 const char* PNode::parentingModeToChar(int parentingMode)
     1051const char* PNode::parentingModeToString(int parentingMode)
    10521052{
    10531053  if (parentingMode == PNODE_LOCAL_ROTATE)
     
    10681068 * @return the int corresponding to the named parentingMode
    10691069 */
    1070 PARENT_MODE PNode::charToParentingMode(const std::string& parentingMode)
     1070PARENT_MODE PNode::stringToParentingMode(const std::string& parentingMode)
    10711071{
    10721072  if (parentingMode == "local-rotate")
  • branches/std/src/lib/coord/p_node.h

    r7216 r7219  
    158158
    159159  void setParentSoft(PNode* parentNode, float bias = 1.0);
    160   void setParentSoft(const char* parentName, float bias = 1.0);
     160  void setParentSoft(const std::string& parentName, float bias = 1.0);
    161161
    162162  // PARENTING_MODE AND OTHER FLAGS //
     
    183183
    184184  // HELPER_FUNCTIONS //
    185   static const char* parentingModeToChar(int parentingMode);
    186   static PARENT_MODE charToParentingMode(const std::string& parentingMode);
     185  static const char* parentingModeToString(int parentingMode);
     186  static PARENT_MODE stringToParentingMode(const std::string& parentingMode);
    187187  float distance(const PNode* node) const { return (this->getAbsCoor() - node->getAbsCoor()).len(); };
    188188
  • branches/std/src/lib/graphics/graphics_engine.cc

    r7211 r7219  
    7878  this->screen = NULL;
    7979
    80 
    81   // Hardware
    82   this->hwRenderer = NULL;
    83   this->hwVendor = NULL;
    84   this->hwVersion = NULL;
    85   this->hwExtensions = NULL;
    86 
    8780  // initialize the Modules
    8881  TextEngine::getInstance();
     
    10396  // delete what has to be deleted here
    10497  this->displayFPS( false );
    105 
    106   delete[] this->hwRenderer;
    107   delete[] this->hwVendor;
    108   delete[] this->hwVersion;
    109   delete this->hwExtensions;
    11098
    11199  //TextEngine
     
    312300  //  printf("%s %s %s\n %s", renderer, vendor, version, extensions);
    313301
    314   if (this->hwRenderer == NULL && renderer != NULL)
    315   {
    316     this->hwRenderer = new char[strlen(renderer)+1];
    317     strcpy(this->hwRenderer, renderer);
    318   }
    319   if (this->hwVendor == NULL && vendor != NULL)
    320   {
    321     this->hwVendor = new char[strlen(vendor)+1];
    322     strcpy(this->hwVendor, vendor);
    323   }
    324   if (this->hwVersion == NULL && version != NULL)
    325   {
    326     this->hwVersion = new char[strlen(version)+11];
    327     strcpy(this->hwVersion, version);
    328   }
    329 
    330   if (this->hwExtensions == NULL && extensions != NULL)
    331     this->hwExtensions = new SubString((char*)glGetString(GL_EXTENSIONS), " \n\t,");
     302  if (renderer != NULL)
     303  {
     304    this->hwRenderer == renderer;
     305  }
     306  if (vendor != NULL)
     307  {
     308    this->hwVendor == vendor;
     309  }
     310  if (version != NULL)
     311  {
     312    this->hwVersion == version;
     313  }
     314
     315  if (extensions != NULL)
     316    this->hwExtensions.split(extensions, " \n\t,");
    332317
    333318  PRINT(4)("Running on : vendor: %s,  renderer: %s,  version:%s\n", vendor, renderer, version);
    334319  PRINT(4)("Extensions:\n");
    335   if (this->hwExtensions != NULL)
    336     for (unsigned int i = 0; i < this->hwExtensions->getCount(); i++)
    337       PRINT(4)("%d: %s\n", i, this->hwExtensions->getString(i));
     320  for (unsigned int i = 0; i < this->hwExtensions.getCount(); i++)
     321    PRINT(4)("%d: %s\n", i, this->hwExtensions.getString(i).c_str());
    338322
    339323
     
    529513 * @return true if it is, false otherwise
    530514 */
    531 bool GraphicsEngine::hwSupportsEXT(const char* extension)
    532 {
    533   if (this->hwExtensions != NULL)
    534     for (unsigned int i = 0; i < this->hwExtensions->getCount(); i++)
    535       if ( this->hwExtensions->getString(i) == extension)
    536         return true;
     515bool GraphicsEngine::hwSupportsEXT(const std::string& extension)
     516{
     517  for (unsigned int i = 0; i < this->hwExtensions.getCount(); i++)
     518    if ( this->hwExtensions.getString(i) == extension)
     519      return true;
    537520  return false;
    538521}
     
    587570void GraphicsEngine::draw() const
    588571{
    589 //  LightManager::getInstance()->draw();
     572  //  LightManager::getInstance()->draw();
    590573
    591574  GraphicsEngine::storeMatrices();
     
    668651  switch (event.type)
    669652  {
    670       case EV_VIDEO_RESIZE:
    671       this->resolutionChanged(event.resize);
    672       break;
    673   }
    674 }
     653  case EV_VIDEO_RESIZE:
     654    this->resolutionChanged(event.resize);
     655    break;
     656  }
     657}
  • branches/std/src/lib/graphics/graphics_engine.h

    r7203 r7219  
    1414#include "sdlincl.h"
    1515#include "glincl.h"
     16#include <list>
    1617
    17 #include <list>
     18#include "substring.h"
    1819
    1920// Forward Declaration
    2021class Text;
    2122class IniParser;
    22 class SubString;
    2323class WorldEntity;
    2424class GraphicsEffect;
     
    7474
    7575    void listModes();
    76     bool hwSupportsEXT(const char* extension);
     76    bool hwSupportsEXT(const std::string& extension);
    7777
    7878    /** @brief swaps the GL_BUFFERS */
     
    116116
    117117    // HARDWARE-Settings:
    118     char*                      hwRenderer;         //!< HW-renderer-string
    119     char*                      hwVendor;           //!< HW-vendor-string
    120     char*                      hwVersion;          //!< HW-version-string
    121     SubString*                 hwExtensions;       //!< All suported Extensions.
     118    std::string                hwRenderer;         //!< HW-renderer-string
     119    std::string                hwVendor;           //!< HW-vendor-string
     120    std::string                hwVersion;          //!< HW-version-string
     121    SubString                  hwExtensions;       //!< All suported Extensions.
    122122
    123123    // FPS-related
  • branches/std/src/lib/graphics/render2D/element_2d.cc

    r7216 r7219  
    726726void Element2D::setParentMode2D (const std::string& parentingMode)
    727727{
    728   this->setParentMode2D(Element2D::charToParentingMode2D(parentingMode));
     728  this->setParentMode2D(Element2D::stringToParentingMode2D(parentingMode));
    729729}
    730730
     
    952952            this->relCoordinate.y,
    953953            this->getAbsDir2D(),
    954             Element2D::parentingModeToChar2D(parentMode),
     954            Element2D::parentingModeToString2D(parentMode),
    955955            Element2D::layer2DToChar(this->layer));
    956956
     
    10741074 * @return the converted string
    10751075 */
    1076 const char* Element2D::parentingModeToChar2D(int parentingMode)
     1076const char* Element2D::parentingModeToString2D(int parentingMode)
    10771077{
    10781078  if (parentingMode == E2D_PARENT_LOCAL_ROTATE)
     
    10931093 * @return the int corresponding to the named parentingMode
    10941094 */
    1095 E2D_PARENT_MODE Element2D::charToParentingMode2D(const std::string& parentingMode)
     1095E2D_PARENT_MODE Element2D::stringToParentingMode2D(const std::string& parentingMode)
    10961096{
    10971097  if (parentingMode == "local-rotate")
  • branches/std/src/lib/graphics/render2D/element_2d.h

    r7216 r7219  
    212212
    213213    // helper functions //
    214     static const char* parentingModeToChar2D(int parentingMode);
    215     static E2D_PARENT_MODE charToParentingMode2D(const std::string& parentingMode);
     214    static const char* parentingModeToString2D(int parentingMode);
     215    static E2D_PARENT_MODE stringToParentingMode2D(const std::string& parentingMode);
    216216
    217217    static const char* layer2DToChar(E2D_LAYER layer);
  • branches/std/src/lib/shell/shell_command.cc

    r7218 r7219  
    4141  PRINTF(5)("create shellcommand %s %s\n", commandName, className);
    4242  this->setName(commandName);
    43   this->description = NULL;
    44   this->alias = NULL;
    4543  this->executor = executor.clone();
    4644  this->executor->setName(commandName);
     
    177175      for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++ )
    178176      {
    179         if ((*alias)->getName() != NULL && inputSplits.getString(0) == (*alias)->getName() && (*alias)->getCommand() != NULL &&
     177        if (inputSplits.getString(0) == (*alias)->getName() && (*alias)->getCommand() != NULL &&
    180178            (*alias)->getCommand()->shellClass != NULL )
    181179        {
     
    258256 * @param description the description of the Given command
    259257 */
    260 ShellCommand* ShellCommand::describe(const char* description)
     258ShellCommand* ShellCommand::describe(const std::string& description)
    261259{
    262260  if (this == NULL)
     
    338336      /*      for (unsigned int i = 0; i< elem->paramCount; i++)
    339337       printf("%s ", ShellCommand::paramToString(elem->parameters[i]));*/
    340       if ((*cmdIT)->description != NULL)
    341        printf("- %s", (*cmdIT)->description);
     338      if (!(*cmdIT)->description.empty())
     339        printf("- %s", (*cmdIT)->description.c_str());
    342340      printf("\n");
    343341
  • branches/std/src/lib/shell/shell_command.h

    r7216 r7219  
    6363    static bool execute (const std::string& executionString);
    6464
    65     ShellCommand* describe(const char* description);
     65    ShellCommand* describe(const std::string& description);
    6666    ShellCommand* setAlias(const char* alias);
    6767    ShellCommand* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
     
    8989    ShellCommandAlias*               alias;                                //!< An Alias for the Class.
    9090
    91     const char*                      description;                          //!< A description for this commnand. (initially NULL). Assigned with (create)->describe("blablabla");
     91    std::string                      description;                          //!< A description for this commnand. (initially NULL). Assigned with (create)->describe("blablabla");
    9292    Executor*                        executor;                             //!< The Executor, that really executes the Function.
    9393
     
    100100  public:
    101101    /** @returns the Name of the Alias. */
    102     const char* getName() const { return this->aliasName; };
     102    const std::string& getName() const { return this->aliasName; };
    103103    /** @returns the Command, this Alias is asociated with */
    104104    ShellCommand* getCommand() const { return this->command; };
     
    106106  private:
    107107    /** @param aliasName the name of the Alias @param command the Command, to associate this alias with */
    108     ShellCommandAlias(const char* aliasName, ShellCommand* command) { this->aliasName = aliasName; this->command = command; };
     108    ShellCommandAlias(const std::string& aliasName, ShellCommand* command) { this->aliasName = aliasName; this->command = command; };
    109109
    110110  private:
    111     const char*     aliasName;       //!< the name of the Alias
     111    std::string     aliasName;       //!< the name of the Alias
    112112    ShellCommand*   command;         //!< a pointer to the command, this alias executes.
    113113};
  • branches/std/src/lib/shell/shell_command_class.cc

    r7216 r7219  
    130130 * @returns the CommandClass if found, NULL otherwise
    131131 */
    132 const ShellCommandClass* ShellCommandClass::isRegistered(const char* className)
     132const ShellCommandClass* ShellCommandClass::isRegistered(const std::string& className)
    133133{
    134134  if (ShellCommandClass::commandClassList == NULL)
     
    203203          /*          for (unsigned int i = 0; i< elem->paramCount; i++)
    204204            PRINT(0)("%s ", ShellCommand::paramToString(elem->parameters[i]));*/
    205           if ((*cmdIT)->description != NULL)
    206             PRINT(0)("- %s", (*cmdIT)->description);
     205          if (!(*cmdIT)->description.empty())
     206            PRINT(0)("- %s", (*cmdIT)->description.c_str());
    207207          PRINT(0)("\n");
    208208        }
  • branches/std/src/lib/shell/shell_command_class.h

    r7216 r7219  
    3939    virtual ~ShellCommandClass();
    4040
    41     static const ShellCommandClass* isRegistered(const char* className);
     41    static const ShellCommandClass* isRegistered(const std::string& className);
    4242    static void initCommandClassList();
    4343
  • 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.