Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7225 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Mar 18, 2006, 12:04:39 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: more std::string

Location:
trunk/src/lib
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/particles/engine/particle_engine.cc

    r7193 r7225  
    122122* @param system the System to connect to the Emitter
    123123*/
    124 void ParticleEngine::addConnection(const char* emitter, const char* system)
     124void ParticleEngine::addConnection(const std::string& emitter, const std::string& system)
    125125{
    126126  ParticleEmitter* tmpEmit = dynamic_cast<ParticleEmitter*>(ClassList::getObject(emitter, CL_PARTICLE_EMITTER));//this->getEmitterByName(emitter);
     
    132132  {
    133133    if (tmpEmit == NULL)
    134       PRINTF(2)("Emitter %s not found in the List of emitters, not connecting to %s\n", emitter, system);
     134      PRINTF(2)("Emitter %s not found in the List of emitters, not connecting to %s\n", emitter.c_str(), system.c_str());
    135135    if (tmpEmit == NULL)
    136       PRINTF(2)("System %s not found in the List of emitters, not connecting to %s\n", system, emitter);
     136      PRINTF(2)("System %s not found in the List of emitters, not connecting to %s\n", system.c_str(), emitter.c_str());
    137137  }
    138138}
  • trunk/src/lib/particles/engine/particle_engine.h

    r7130 r7225  
    4545  void addEmitter(ParticleEmitter* emitter);
    4646  void addConnection(ParticleEmitter* emitter, ParticleSystem* system);
    47   void addConnection(const char* emitter, const char* system);
     47  void addConnection(const std::string& emitter, const std::string& system);
    4848
    4949
  • trunk/src/lib/shell/shell_command.cc

    r7221 r7225  
    3636 * @param paramCount the count of parameters this command takes
    3737 */
    38 ShellCommand::ShellCommand(const char* commandName, const char* className, const Executor& executor)
     38ShellCommand::ShellCommand(const std::string& commandName, const std::string& className, const Executor& executor)
    3939{
    4040  this->setClassID(CL_SHELL_COMMAND, "ShellCommand");
     
    6666 * registers a new ShellCommand
    6767 */
    68 ShellCommand* ShellCommand::registerCommand(const char* commandName, const char* className, const Executor& executor)
     68ShellCommand* ShellCommand::registerCommand(const std::string& commandName, const std::string& className, const Executor& executor)
    6969{
    7070  if (ShellCommand::isRegistered(commandName, className))
     
    8080 * @param commandName the name of the command itself
    8181 */
    82 void ShellCommand::unregisterCommand(const char* commandName, const char* className)
     82void ShellCommand::unregisterCommand(const std::string& commandName, const std::string& className)
    8383{
    8484  /// FIXME
     
    118118 * This is checked in the registerCommand-function.
    119119 */
    120 bool ShellCommand::isRegistered(const char* commandName, const char* className)
     120bool ShellCommand::isRegistered(const std::string& commandName, const std::string& className)
    121121{
    122122  if (ShellCommandClass::commandClassList == NULL)
     
    132132    for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++)
    133133    {
    134       if (!strcmp(commandName, (*elem)->getName()))
    135       {
    136         PRINTF(2)("Command '%s::%s' already registered\n", className, commandName);
     134      if (commandName == (*elem)->getName())
     135      {
     136        PRINTF(2)("Command '%s::%s' already registered\n", className.c_str(), commandName.c_str());
    137137        return true;
    138138      }
     
    272272 * @returns itself
    273273 */
    274 ShellCommand* ShellCommand::setAlias(const char* alias)
     274ShellCommand* ShellCommand::setAlias(const std::string& alias)
    275275{
    276276  if (this == NULL)
     
    352352{
    353353  return MultiType::MultiTypeToString((MT_Type)parameter);
    354 // FIXME
    355   /*  switch (parameter)
    356   {
    357     case ParameterBool:
    358       return "BOOL";
    359       break;
    360     case ParameterChar:
    361       return "CHAR";
    362       break;
    363     case ParameterString:
    364       return "STRING";
    365       break;
    366     case ParameterInt:
    367       return "INT";
    368       break;
    369     case ParameterUInt:
    370       return "UINT";
    371       break;
    372     case ParameterFloat:
    373       return "FLOAT";
    374       break;
    375     case ParameterLong:
    376       return "LONG";
    377       break;
    378     default:
    379       return "NULL";
    380       break;
    381   }*/
    382 }
     354}
  • trunk/src/lib/shell/shell_command.h

    r7221 r7225  
    6464
    6565    ShellCommand* describe(const std::string& description);
    66     ShellCommand* setAlias(const char* alias);
     66    ShellCommand* setAlias(const std::string& alias);
    6767    ShellCommand* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
    6868                                const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    6969                                const MultiType& value4 = MT_NULL);
    7070
    71     static ShellCommand* registerCommand(const char* commandName, const char* className, const Executor& executor);
     71    static ShellCommand* registerCommand(const std::string& commandName, const std::string& className, const Executor& executor);
    7272
    73     static void unregisterCommand(const char* commandName, const char* className);
     73    static void unregisterCommand(const std::string& commandName, const std::string& className);
    7474
    7575    static void debug();
    7676
    7777  protected:
    78     ShellCommand(const char* commandName, const char* className, const Executor& executor);
     78    ShellCommand(const std::string& commandName, const std::string& className, const Executor& executor);
    7979    ~ShellCommand();
    8080
    81     static bool isRegistered(const char* commandName, const char* className);
     81    static bool isRegistered(const std::string& commandName, const std::string& className);
    8282    static const char* paramToString(long parameter);
    8383
  • trunk/src/lib/shell/shell_completion.cc

    r7221 r7225  
    142142 * @return true on success, false otherwise
    143143 */
    144 bool ShellCompletion::classComplete(const char* classBegin)
    145 {
    146   if (unlikely(classBegin == NULL))
    147     return false;
     144bool ShellCompletion::classComplete(const std::string& classBegin)
     145{
    148146  const std::list<std::string>* clList = ClassList::getClassNames();
    149147  if (clList != NULL)
     
    163161 * @return true on success, false otherwise
    164162 */
    165 bool ShellCompletion::objectComplete(const char* objectBegin, long classID)
    166 {
    167   if (unlikely(objectBegin == NULL))
    168     return false;
     163bool ShellCompletion::objectComplete(const std::string& objectBegin, long classID)
     164{
    169165  const std::list<BaseObject*>* boList = ClassList::getList((ClassID)classID);
    170166  if (boList != NULL)
     
    186182 * @param classID the class' ID to complete the function of
    187183 */
    188 bool ShellCompletion::functionComplete(const char* functionBegin, const char* className)
    189 {
    190   if (unlikely(functionBegin == NULL))
    191     return false;
     184bool ShellCompletion::functionComplete(const std::string& functionBegin, const std::string& className)
     185{
    192186  std::list<std::string> fktList;
    193187  ShellCommandClass::getCommandListOfClass(className, &fktList);
     
    203197 * @returns true on succes, false if something went wrong
    204198 */
    205 bool ShellCompletion::aliasComplete(const char* aliasBegin)
    206 {
    207   if (unlikely(aliasBegin == NULL))
    208     return false;
     199bool ShellCompletion::aliasComplete(const std::string& aliasBegin)
     200{
    209201  std::list<std::string> aliasList;
    210202  ShellCommandClass::getCommandListOfAlias(&aliasList);
     
    224216 * @return true if ok, false otherwise
    225217 */
    226 bool ShellCompletion::generalComplete(const char* begin, const char* displayAs, const char* addBack, const char* addFront)
     218bool ShellCompletion::generalComplete(const std::string& begin, const std::string& displayAs, const std::string& addBack, const std::string& addFront)
    227219{
    228220  if (this->input == NULL )
     
    232224
    233225  ShellC_Element addElem = completionList.front();
    234   const char* addString = addElem.name;
     226  const std::string& addString = addElem.name;
    235227  unsigned int addLength = 0;
    236   unsigned int inputLenght = strlen(begin);
     228  unsigned int inputLenght = begin.size();
    237229
    238230  // Determin the longest Match
    239   if (addString != NULL)
    240     addLength = strlen(addString);
     231  addLength = addString.size();
    241232
    242233  SHELLC_TYPE changeType = SHELLC_NONE;
     
    251242      changeType = (*charIT).type;
    252243    }
    253     PRINTF(0)("%s ", (*charIT).name);
     244    PRINTF(0)("%s ", (*charIT).name.c_str());
    254245    for (unsigned int i = inputLenght; i < addLength; i++)
    255246      if (addString[i] != (*charIT).name[i])
     
    263254  if (addLength >= inputLenght)
    264255  {
    265     char* adder = new char[addLength+1];
    266     strncpy(adder, addString, addLength);
    267     adder[addLength] = '\0';
     256    std::string adder = addString;
     257    adder.resize(addLength);
    268258
    269259    if (this->input)
     
    274264      if (completionList.size() == 1)
    275265      {
    276         if ( addBack != NULL )
     266        if ( addBack != "")
    277267         this->input->addCharacters(addBack);
    278268        this->input->addCharacter(' ');
    279269      }
    280      delete[] adder;
    281270    }
    282271  }
     
    290279 * !! The strings MUST NOT be deleted !!
    291280 */
    292 bool ShellCompletion::addToCompleteList(const std::list<std::string>* inputList, const char* completionBegin, SHELLC_TYPE type)
    293 {
    294   if (inputList == NULL || completionBegin == NULL)
    295     return false;
    296   unsigned int searchLength = strlen(completionBegin);
     281bool ShellCompletion::addToCompleteList(const std::list<std::string>* inputList, const std::string& completionBegin, SHELLC_TYPE type)
     282{
     283  if (inputList == NULL)
     284    return false;
     285  unsigned int searchLength = completionBegin.size();
    297286
    298287  list<std::string>::const_iterator string;
     
    300289  {
    301290    if ((*string).size() >= searchLength &&
    302           !strncasecmp((*string).c_str(), completionBegin, searchLength))
     291          !strncasecmp((*string).c_str(), completionBegin.c_str(), searchLength))
    303292    {
    304293      ShellC_Element newElem;
     
    317306 * !! The strings MUST NOT be deleted !!
    318307 */
    319 bool ShellCompletion::addToCompleteList(const std::list<BaseObject*>* inputList, const char* completionBegin, SHELLC_TYPE type)
    320 {
    321   if (inputList == NULL || completionBegin == NULL)
    322     return false;
    323   unsigned int searchLength = strlen(completionBegin);
     308bool ShellCompletion::addToCompleteList(const std::list<BaseObject*>* inputList, const std::string& completionBegin, SHELLC_TYPE type)
     309{
     310  if (inputList == NULL)
     311    return false;
     312  unsigned int searchLength = completionBegin.size();
    324313
    325314  list<BaseObject*>::const_iterator bo;
     
    328317    if ((*bo)->getName() != NULL &&
    329318        strlen((*bo)->getName()) >= searchLength &&
    330         !strncasecmp((*bo)->getName(), completionBegin, searchLength))
     319          !strncasecmp((*bo)->getName(), completionBegin.c_str(), searchLength))
    331320    {
    332321      ShellC_Element newElem;
  • trunk/src/lib/shell/shell_completion.h

    r7221 r7225  
    1111
    1212#include <list>
     13#include <string>
    1314
    1415// FORWARD DECLARATION
     
    3031//! A struct for ShellElements (these are used as containers to identify an Input for what it is)
    3132struct ShellC_Element{
    32   const char*     name;     //!< the Name of the Element to be completed.
     33  std::string     name;     //!< the Name of the Element to be completed.
    3334  SHELLC_TYPE     type;     //!< the type of the Element
    3435};
     
    4243
    4344  bool autoComplete(ShellInput* input = NULL);
    44   bool classComplete(const char* classBegin);
     45  bool classComplete(const std::string& classBegin);
    4546//  long classMatch(const char* input, unsigned int* length);
    46   bool objectComplete(const char* objectBegin, long classID);
     47  bool objectComplete(const std::string& objectBegin, long classID);
    4748//  bool objectMatch(const char* objectBegin, long classID, unsigned int* length);
    48   bool functionComplete(const char* functionBegin, const char* className);
     49  bool functionComplete(const std::string& functionBegin, const std::string& className);
    4950//  bool functionMatch(const char* functionBegin, long classID, unsigned int* length);
    50   bool aliasComplete(const char* aliasBegin);
     51  bool aliasComplete(const std::string& aliasBegin);
    5152
    52   bool generalComplete(const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL);
     53  bool generalComplete(const std::string& begin, const std::string& displayAs = "%s",
     54                       const std::string& addBack = "", const std::string& addFront = "");
    5355
    54   bool addToCompleteList(const std::list<std::string>* inputList, const char* completionBegin, SHELLC_TYPE type);
    55   bool addToCompleteList(const std::list<BaseObject*>* inputList, const char* completionBegin, SHELLC_TYPE type);
     56  bool addToCompleteList(const std::list<std::string>* inputList, const std::string& completionBegin, SHELLC_TYPE type);
     57  bool addToCompleteList(const std::list<BaseObject*>* inputList, const std::string& completionBegin, SHELLC_TYPE type);
    5658  void emptyCompletionList();
    5759
  • trunk/src/lib/sound/sound_engine.cc

    r7221 r7225  
    352352}
    353353
    354 bool SoundEngine::checkError(const char* error, unsigned int line)
     354bool SoundEngine::checkError(const std::string& error, unsigned int line)
    355355{
    356356  ALenum errorCode;
    357357  if ((errorCode = alGetError()) != AL_NO_ERROR)
    358358  {
    359     PRINTF(1)("Error %s (line:%d): '%s'\n", error, line, SoundEngine::getALErrorString(errorCode));
     359    PRINTF(1)("Error %s (line:%d): '%s'\n", error.c_str(), line, SoundEngine::getALErrorString(errorCode));
    360360    return false;
    361361  }
     
    364364}
    365365
    366 bool SoundEngine::checkALCError(const char* error, unsigned int line)
     366bool SoundEngine::checkALCError(const std::string& error, unsigned int line)
    367367{
    368368  ALenum errorCode;
    369369  if ((errorCode = alcGetError(this->device)) != ALC_NO_ERROR)
    370370  {
    371     PRINTF(1)("Error %s (line:%d): '%s'\n", error, line, SoundEngine::getALCErrorString(errorCode));
     371    PRINTF(1)("Error %s (line:%d): '%s'\n", error.c_str(), line, SoundEngine::getALCErrorString(errorCode));
    372372    return false;
    373373  }
  • trunk/src/lib/sound/sound_engine.h

    r7221 r7225  
    5959
    6060  // error handling:
    61     static bool checkError(const char* error, unsigned int line);
    62     bool checkALCError(const char* error, unsigned int line);
     61    static bool checkError(const std::string& error, unsigned int line);
     62    bool checkALCError(const std::string& error, unsigned int line);
    6363    static const char* getALErrorString(ALenum err);
    6464    static const char* getALCErrorString(ALenum err);
  • trunk/src/lib/util/loading/resource_manager.cc

    r7221 r7225  
    10091009 * @returns the Number of the Type, or 0 (defautl) if not found.
    10101010 */
    1011 ResourceType ResourceManager::stringToResourceType(const char* resourceType)
    1012 {
    1013   assert(resourceType != NULL);
     1011ResourceType ResourceManager::stringToResourceType(const std::string& resourceType)
     1012{
    10141013  for (unsigned int i = 0; i < RESOURCE_TYPE_SIZE; i++)
    1015     if (!strcmp(resourceType, ResourceManager::resourceNames[i]))
     1014    if (resourceType == ResourceManager::resourceNames[i])
    10161015      return (ResourceType)i;
    10171016  return (ResourceType)0;
  • trunk/src/lib/util/loading/resource_manager.h

    r7221 r7225  
    141141
    142142  static const char* ResourceTypeToChar(ResourceType type);
    143   static ResourceType stringToResourceType(const char* resourceType);
     143  static ResourceType stringToResourceType(const std::string& resourceType);
    144144
    145145 private:
  • trunk/src/lib/util/multi_type.h

    r7221 r7225  
    4848    MultiType& operator=(float value) { this->setFloat(value); return *this; };
    4949    MultiType& operator=(char value) { this->setChar(value); return *this; };
    50     MultiType& operator=(const char* value) { this->setString(value); return *this; };
    5150    MultiType& operator=(const std::string& value) { this->setString(value); return *this; };
    5251
Note: See TracChangeset for help on using the changeset viewer.