Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Mar 10, 2006, 5:28:52 AM (19 years ago)
Author:
bensch
Message:

should be better, but hey…. its late

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

Legend:

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

    r7211 r7212  
    192192#define ExecutorExecute1(t1) \
    193193   else if (this->paramCount == 1 && this->defaultValue[0] == t1##_PARAM) \
    194     EXECUTOREXECUTER(_1_##t1)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)))
     194    EXECUTOREXECUTER(_1_##t1)(t1##_FUNC((const char*)parameters, t1##_DEFGRAB(0)))
    195195
    196196//! execute-macro for functions with two parameters
     
    270270    virtual void execute (BaseObject* object, const void* parameters = NULL)
    271271    {
    272       SubString sub((const char*)parameters, " \n\t", '\\');
     272      SubString sub;
     273      printf("===%s\n", (const char*)parameters);
     274      if (parameters != NULL)
     275        sub.split((const char*)parameters, " \n\t,", '\\');
    273276//! FUNCTOR_LIST is the List of Executive Functions
    274277#define FUNCTOR_LIST(x) ExecutorExecute ## x
     
    332335    virtual void execute (BaseObject* object, const void* parameters = NULL)
    333336    {
    334       SubString sub(((const char*)parameters), " \n\t,");
     337      SubString sub;
     338      if (parameters != NULL)
     339        sub.split((const char*)parameters, " \n\t,", '\\');
    335340//! FUNCTOR_LIST is the List of Executive Functions
    336341#define FUNCTOR_LIST(x) ExecutorExecute ## x
  • branches/std/src/lib/util/loading/load_param.cc

    r7211 r7212  
    6666          ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString)))
    6767    {
    68       PRINTF(4)("Loading '%s' with Parameters '%s' onto: '%s'(%s)\n", this->paramName, loadString.c_str(), this->object->getName(), this->object->getClassName());
     68      PRINTF(0)("Loading '%s' with Parameters '%s' onto: '%s'(%s)\n", this->paramName.c_str(), loadString.c_str(), this->object->getName(), this->object->getClassName());
    6969      this->executor->execute(this->object, (const void*)loadString.c_str());
    7070    }
  • branches/std/src/lib/util/substring.cc

    r7211 r7212  
    1414
    1515   2005-06-10: some naming conventions
     16
     17//
     18//  splitLine
     19//  STL string tokenizer
     20//
     21//  Created by Clemens Wacha.
     22//  Version 1.0
     23//  Copyright (c) 2005 Clemens Wacha. All rights reserved.
     24//
     25
    1626*/
    1727
     
    3545                       string, split);
    3646}
    37 
    3847
    3948/**
     
    4857                      string);
    4958}
    50 
    5159SubString::SubString(const std::string& string, const std::string& splitters, char escapeChar,char safemode_char, char comment_char)
    5260{
    5361  SubString::splitLine(this->strings, this->offsets,
    5462                       string, splitters, escapeChar, safemode_char);
     63}
     64
     65
     66unsigned int SubString::split(const std::string& string, char splitter)
     67{
     68  this->offsets.clear();
     69  this->strings.clear();
     70  char split[2];
     71  split[0] = splitter;
     72  split[1] = '\0';
     73  SubString::splitLine(this->strings, this->offsets, string, split);
     74  return strings.size();
     75}
     76
     77
     78/**
     79 * Splits a String into a Substring removing all whiteSpaces
     80 * @param string the String to Split
     81 * @param whiteSpaces MUST BE __TRUE__
     82 *
     83 */
     84unsigned int SubString::split(const std::string& string, bool whiteSpaces)
     85{
     86  this->offsets.clear();
     87  this->strings.clear();
     88  SubString::splitLine(this->strings, this->offsets, string);
     89  return strings.size();
     90}
     91
     92unsigned int SubString::split(const std::string& string, const std::string& splitters, char escapeChar,char safemode_char, char comment_char)
     93{
     94  this->offsets.clear();
     95  this->strings.clear();
     96  SubString::splitLine(this->strings, this->offsets,
     97                       string, splitters, escapeChar, safemode_char);
     98  return strings.size();
    5599}
    56100
  • branches/std/src/lib/util/substring.h

    r7211 r7212  
    2222{
    2323 public:
    24   SubString(const std::string& string, char splitter = ',');
     24  SubString(const std::string& string = "", char splitter = ',');
    2525  SubString(const std::string& string, bool whiteSpaces);
    2626  SubString(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0');
    2727  ~SubString();
    2828
    29   SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,std::vector<unsigned int>& offsets,
    30                              const std::string& line, const std::string& delimiters = " \t\r\n",
    31                              char escape_char = '\\', char safemode_char = '"', char comment_char = '\0',
    32                              SPLIT_LINE_STATE start_state = SL_NORMAL);
     29  unsigned int split(const std::string& string = "", char splitter = ',');
     30  unsigned int split(const std::string& string, bool whiteSpaces);
     31  unsigned int split(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0');
     32
    3333
    3434  const std::string& operator[](unsigned int i) { return this->getString(i); };
     
    3737  const std::string& getString(unsigned int i) { return this->strings[i]; };
    3838  unsigned int getOffset(unsigned int i);
     39
     40  static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,std::vector<unsigned int>& offsets,
     41                                    const std::string& line, const std::string& delimiters = " \t\r\n",
     42                                    char escape_char = '\\', char safemode_char = '"', char comment_char = '\0',
     43                                    SPLIT_LINE_STATE start_state = SL_NORMAL);
    3944
    4045  void debug() const;
Note: See TracChangeset for help on using the changeset viewer.