Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9406 in orxonox.OLD for trunk/src/lib/util/substring.h


Ignore:
Timestamp:
Jul 24, 2006, 11:09:47 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/substring.h

    r8408 r9406  
    22 * @file substring.h
    33 * @brief a small class to get the parts of a string separated by commas
     4 *
     5 * This class is also identified as a Tokenizer. It splits up one long
     6 * String into multiple small ones by a designated Delimiter.
     7 *
     8 * Substring is Advanced, and it is possible, to split a string by ','
     9 * but also removing leading and trailing spaces around the comma.
     10 *
     11 * @example
     12 * Split the String std::string st = "1345, The new empire   , is , orxonox"
     13 * is splitted with:
     14 * SubString(st, ',', " \n\t")
     15 * into
     16 * "1345", "The new empire", "is", "orxonox"
     17 * As you can see, the useless spaces around ',' were removed.
    418 */
    519
    6 #ifndef _SUBSTRING_H
    7 #define _SUBSTRING_H
     20#ifndef __SUBSTRING_H__
     21#define __SUBSTRING_H__
    822
    923#include <vector>
     
    6175
    6276  // retrieve a SubSet from the String
    63   SubString getSubSet(unsigned int subSetBegin) const;
    64   SubString getSubSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
     77  SubString subSet(unsigned int subSetBegin) const;
     78  SubString subSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
    6579
    6680  // retrieve Information from within
     
    7084  inline unsigned int size() const { return this->strings.size(); };
    7185  /** @param i the i'th String @returns the i'th string from the subset of Strings */
    72   inline const std::string& operator[](unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; };
     86  inline const std::string& operator[](unsigned int i) const { return this->strings[i]; };
    7387  /** @param i the i'th String @returns the i'th string from the subset of Strings */
    7488  inline const std::string& getString(unsigned int i) const { return (*this)[i]; };
     89  /** @returns the front of the StringList. */
     90  inline const std::string& front() const { return this->strings.front(); };
     91  /** @returns the back of the StringList. */
     92  inline const std::string& back() const { return this->strings.back(); };
     93  /** @brief removes the back of the strings list. */
     94  inline void pop_back() { this->strings.pop_back(); };
    7595
    7696  // the almighty algorithm.
     
    93113private:
    94114  std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
    95 
    96   static const std::string emptyString;
    97115};
    98116
    99 #endif /* _SUBSTRING_H */
     117#endif /* __SUBSTRING_H__ */
Note: See TracChangeset for help on using the changeset viewer.