Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 11, 2010, 12:34:00 AM (14 years ago)
Author:
landauf
Message:

merged doc branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/util/StringUtils.cc

    r7284 r7401  
    4141namespace orxonox
    4242{
     43    /// A blank string (""). Used to return a blank string by reference.
    4344    std::string BLANKSTRING;
    4445
     46    /// Returns a string of a unique number. This function is guaranteed to never return the same string twice.
    4547    std::string getUniqueNumberString()
    4648    {
     
    4850    }
    4951
    50     /**
    51         @brief Removes all whitespaces from a string.
    52         @param str The string to strip
    53     */
     52    /// Removes all whitespaces from a string.
    5453    void strip(std::string* str)
    5554    {
     
    6362    }
    6463
    65     /**
    66         @brief Returns a copy of a string without whitespaces.
    67         @param str The string to strip
    68         @return The stripped line
    69     */
     64    /// Returns a copy of a string without whitespaces.
    7065    std::string getStripped(const std::string& str)
    7166    {
     
    7570    }
    7671
    77     /**
    78         @brief Returns a copy of a string without trailing whitespaces.
    79         @param str The string
    80         @return The modified copy
    81     */
     72    /// Returns a copy of a string without trailing whitespaces.
    8273    std::string removeTrailingWhitespaces(const std::string& str)
    8374    {
     
    9081
    9182    /**
    92         @brief Returns the position of the next quote in the string, starting with start.
     83        @brief Returns the position of the next quotation mark in the string, starting with start.
    9384        @param str The string
    94         @param start The startposition
    95         @return The position of the next quote (std::string::npos if there is no next quote)
     85        @param start The first position to look at
     86        @return The position of the next quotation mark (@c std::string::npos if there is none)
    9687    */
    9788    size_t getNextQuote(const std::string& str, size_t start)
     
    115106
    116107    /**
    117         @brief Returns true if pos is between two quotes.
     108        @brief Returns true if pos is between two quotation marks.
    118109        @param str The string
    119110        @param pos The position to check
    120         @return True if pos is between two quotes
     111        @return True if pos is between two quotation marks
    121112    */
    122113    bool isBetweenQuotes(const std::string& str, size_t pos)
     
    140131    }
    141132
    142     /**
    143         @brief Returns true if the string contains something like '..."between quotes"...'.
    144         @param The string
    145         @return True if there is something between quotes
    146     */
     133    /// Returns true if the string contains something like '..."between quotaton marks"...'.
    147134    bool hasStringBetweenQuotes(const std::string& str)
    148135    {
     
    152139    }
    153140
    154     /**
    155         @brief If the string contains something like '..."between quotes"...' then 'between quotes' gets returned (without quotes).
    156         @param The string
    157         @param The string between the quotes
    158     */
     141    /// If the string contains something like '..."between quotaton marks"...' then 'between quotaton marks' gets returned, otherwise "".
    159142    std::string getStringBetweenQuotes(const std::string& str)
    160143    {
     
    168151
    169152    /**
    170         @brief Removes enclosing quotes if available (including whitespaces at the outside of the quotes).
    171         @brief str The string to strip
    172         @return The string with removed quotes
     153        @brief Removes enclosing quotation marks if available (including whitespaces at the outside of the quotation marks).
     154        @return The striped string without quotation marks
    173155    */
    174156    std::string stripEnclosingQuotes(const std::string& str)
     
    208190
    209191    /**
    210         @brief Removes enclosing {braces} (braces must be exactly on the beginning and the end of the string).
    211         @param str The string to strip
    212         @return The striped string
     192        @brief Removes enclosing braces '{' and '}' (the braces must be exactly on the beginning and the end of the string).
     193        @return The striped string without braces
    213194    */
    214195    std::string stripEnclosingBraces(const std::string& str)
     
    224205    /**
    225206        @brief Determines if a string is a comment (starts with a comment-symbol).
    226         @param str The string to check
    227         @return True = it's a comment
    228207
    229208        A comment is defined by a leading '#', '%', ';' or '//'.
     
    253232    }
    254233
    255     /**
    256         @brief Determines if a string is empty (contains only whitespaces).
    257         @param str The string to check
    258         @return True = it's empty
    259     */
     234    /// Determines if a string is empty (contains only whitespaces).
    260235    bool isEmpty(const std::string& str)
    261236    {
     
    263238    }
    264239
    265     /**
    266         @brief Determines if a string contains only numbers and maximal one '.'.
    267         @param str The string to check
    268         @return True = it's a number
    269     */
     240    /// Determines if a string contains only numbers and maximal one '.'.
    270241    bool isNumeric(const std::string& str)
    271242    {
     
    288259    /**
    289260        @brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled.
    290         @param str The string to manipulate
    291         @return The string with added slashes
     261
     262        This function converts all special chars like line breaks, tabs, quotation marks etc. into
     263        a human readable format by adding a backslash. So for example "\n" will be converted to
     264        "\\" + "n".
     265
     266        This is usually used when a string is written to a file.
     267
     268        @see removeSlashes
    292269    */
    293270    std::string addSlashes(const std::string& str)
     
    320297    /**
    321298        @brief Removes backslashes from the given string. Double backslashes are interpreted as one backslash.
    322         @param str The string to manipulate
    323         @return The string with removed slashes
     299
     300        This function removes all backslashes and converts the human readable equivalents of
     301        special chars like "\\" + "n" into their real meaning (in this case a line break or "\n").
     302
     303        This is usually used when reading a string from a file.
     304
     305        @see addSlashes
    324306    */
    325307    std::string removeSlashes(const std::string& str)
     
    361343    }
    362344
    363     /**
    364         @brief Replaces each char between A and Z with its lowercase equivalent.
    365         @param str The string to convert
    366     */
     345    /// Replaces each char between A and Z with its lowercase equivalent.
    367346    void lowercase(std::string* str)
    368347    {
     
    373352    }
    374353
    375     /**
    376         @brief Returns a copy of the given string without uppercase chars.
    377         @param str The string
    378         @return The copy
    379     */
     354    /// Returns a copy of the given string where all chars are converted to lowercase.
    380355    std::string getLowercase(const std::string& str)
    381356    {
     
    385360    }
    386361
    387     /**
    388         @brief Replaces each char between a and z with its uppercase equivalent.
    389         @param str The string to convert
    390     */
     362    /// Replaces each char between a and z with its uppercase equivalent.
    391363    void uppercase(std::string* str)
    392364    {
     
    397369    }
    398370
    399     /**
    400         @brief Returns a copy of the given string without lowercase chars.
    401         @param str The string
    402         @return The copy
    403     */
     371    /// Returns a copy of the given string where all chars are converted to uppercase.
    404372    std::string getUppercase(const std::string& str)
    405373    {
     
    411379    /**
    412380        @brief Compares two strings ignoring different casing.
    413         @param s1 First string
    414         @param s2 Second string
     381        @return s1 == s1 -> returns 0 / s1 < s2 -> returns -1 / s1 >= s2 -> returns 1
    415382    */
    416383    int nocaseCmp(const std::string& s1, const std::string& s2)
     
    438405
    439406    /**
    440         @brief Compares the first 'len' chars of two strings ignoring different casing.
     407        @brief Compares the first @a len chars of two strings ignoring different casing.
    441408        @param s1 First string
    442409        @param s2 Second string
     
    463430    }
    464431
    465     /**
    466         @brief Returns true if the string contains a comment, introduced by #, %, ; or //.
     432    /// Returns true if the string contains a comment, introduced by #, %, ; or //.
     433    bool hasComment(const std::string& str)
     434    {
     435        return (getCommentPosition(str) != std::string::npos);
     436    }
     437
     438    /// If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
     439    std::string getComment(const std::string& str)
     440    {
     441        return str.substr(getCommentPosition(str));
     442    }
     443
     444    /// If the string contains a comment, the position of the comment-symbol gets returned, @c std::string::npos otherwise.
     445    size_t getCommentPosition(const std::string& str)
     446    {
     447        return getNextCommentPosition(str, 0);
     448    }
     449
     450    /**
     451        @brief Returns the position of the next comment-symbol, starting with @a start.
    467452        @param str The string
    468         @return True if the string contains a comment
    469     */
    470     bool hasComment(const std::string& str)
    471     {
    472         return (getCommentPosition(str) != std::string::npos);
    473     }
    474 
    475     /**
    476         @brief If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
    477         @param str The string
    478         @return The comment
    479     */
    480     std::string getComment(const std::string& str)
    481     {
    482         return str.substr(getCommentPosition(str));
    483     }
    484 
    485     /**
    486         @brief If the string contains a comment, the position of the comment-symbol gets returned, std::string::npos otherwise.
    487         @param str The string
    488         @return The position
    489     */
    490     size_t getCommentPosition(const std::string& str)
    491     {
    492         return getNextCommentPosition(str, 0);
    493     }
    494 
    495     /**
    496         @brief Returns the position of the next comment-symbol, starting with start.
    497         @param str The string
    498         @param start The startposition
    499         @return The position
     453        @param start The first position to look at
    500454    */
    501455    size_t getNextCommentPosition(const std::string& str, size_t start)
Note: See TracChangeset for help on using the changeset viewer.