Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 10, 2008, 1:24:29 AM (16 years ago)
Author:
landauf
Message:

started implementing a config-file manager, but this is still unfinished.

Location:
code/branches/core2/src/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/util/String.cc

    r994 r1006  
    5353    strip(&output);
    5454    return output;
     55}
     56
     57/**
     58    @brief Returns a copy of a string without trailing whitespaces.
     59    @param str The string
     60    @return The modified copy
     61*/
     62std::string removeTrailingWhitespaces(const std::string& str)
     63{
     64}
     65
     66/**
     67    @brief Returns true if the string contains something like '..."between quotes"...'
     68    @param The string
     69    @return True if there is something between quotes
     70*/
     71bool hasStringBetweenQuotes(const std::string& str)
     72{
     73}
     74
     75/**
     76    @brief If the string contains something like '..."between quotes"...' then 'between quotes' gets returned (without quotes).
     77    @param The string
     78    @param The string between the quotes
     79*/
     80std::string getStringBetweenQuotes(const std::string& str)
     81{
    5582}
    5683
     
    218245
    219246/**
    220  * @brief compares two strings without ignoring the case
    221  * @param s1 first string
    222  * @param s2 second string
    223  */
     247   @brief compares two strings without ignoring the case
     248   @param s1 first string
     249   @param s2 second string
     250*/
    224251int nocaseCmp(const std::string& s1, const std::string& s2)
    225252{
     
    246273
    247274/**
    248  * @brief compares two strings without ignoring the case
    249  * @param s1 first string
    250  * @param s2 second string
    251  * @param len how far from the beginning to start.
    252  */
     275   @brief compares two strings without ignoring the case
     276   @param s1 first string
     277   @param s2 second string
     278   @param len how far from the beginning to start.
     279*/
    253280int nocaseCmp(const std::string& s1, const std::string& s2, unsigned int len)
    254281{
     
    270297    return 0;
    271298}
     299
     300/**
     301    @brief Returns true if the string contains a comment, introduced by #, %, ; or //.
     302    @param str The string
     303    @return True if the string contains a comment
     304*/
     305bool hasComment(const std::string& str)
     306{
     307    return (getCommentPosition(str) != std::string::npos);
     308}
     309
     310/**
     311    @brief If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
     312    @param str The string
     313    @return The comment
     314*/
     315std::string getComment(const std::string& str)
     316{
     317    return str.substr(getCommentPosition(str));
     318}
     319
     320/**
     321    @brief If the string contains a comment, the position of the comment-symbol gets returned, std::string::npos otherwise.
     322    @param str The string
     323    @return The position
     324*/
     325unsigned int getCommentPosition(const std::string& str)
     326{
     327    for (unsigned int i = 0; i < str.size(); i++)
     328        if (isComment(str.substr(i)))
     329            return i;
     330
     331    return std::string::npos;
     332}
  • code/branches/core2/src/util/String.h

    r994 r1006  
    3434#include "UtilPrereqs.h"
    3535
    36 _UtilExport void        strip(std::string* str);
    37 _UtilExport std::string getStripped(const std::string& str);
     36_UtilExport void         strip(std::string* str);
     37_UtilExport std::string  getStripped(const std::string& str);
    3838
    39 _UtilExport void        stripEnclosingQuotes(std::string* str);
    40 _UtilExport std::string getStrippedEnclosingQuotes(const std::string& str);
     39_UtilExport std::string  removeTrailingWhitespaces(const std::string& str);
    4140
    42 _UtilExport bool        isEmpty(const std::string& str);
    43 _UtilExport bool        isComment(const std::string& str);
    44 _UtilExport bool        isNumeric(const std::string& str);
     41_UtilExport bool         hasStringBetweenQuotes(const std::string& str);
     42_UtilExport std::string  getStringBetweenQuotes(const std::string& str);
    4543
    46 _UtilExport void        lowercase(std::string* str);
    47 _UtilExport std::string getLowercase(const std::string& str);
     44_UtilExport void         stripEnclosingQuotes(std::string* str);
     45_UtilExport std::string  getStrippedEnclosingQuotes(const std::string& str);
    4846
    49 _UtilExport void        uppercase(std::string* str);
    50 _UtilExport std::string getUppercase(const std::string& str);
     47_UtilExport bool         isEmpty(const std::string& str);
     48_UtilExport bool         isComment(const std::string& str);
     49_UtilExport bool         isNumeric(const std::string& str);
    5150
    52 _UtilExport int         nocaseCmp(const std::string& s1, const std::string& s2);
    53 _UtilExport int         nocaseCmp(const std::string& s1, const std::string& s2, unsigned int len);
     51_UtilExport void         lowercase(std::string* str);
     52_UtilExport std::string  getLowercase(const std::string& str);
     53
     54_UtilExport void         uppercase(std::string* str);
     55_UtilExport std::string  getUppercase(const std::string& str);
     56
     57_UtilExport int          nocaseCmp(const std::string& s1, const std::string& s2);
     58_UtilExport int          nocaseCmp(const std::string& s1, const std::string& s2, unsigned int len);
     59
     60_UtilExport bool         hasComment(const std::string& str);
     61_UtilExport std::string  getComment(const std::string& str);
     62_UtilExport unsigned int getCommentPosition(const std::string& str);
    5463
    5564//! The Convert class has some static member functions to convert strings to values and values to strings.
Note: See TracChangeset for help on using the changeset viewer.