Logo Search packages:      
Sourcecode: inkscape version File versions

String buildtool::MakeBase::trim ( const String &  s  )  [protected, inherited]

remove leading and trailing whitespace from string

Removes whitespace from beginning and end of a string

Definition at line 3361 of file buildtool.cpp.

Referenced by buildtool::MakeBase::getSubstitutions().

{
    if (s.size() < 1)
        return s;
    
    //Find first non-ws char
    unsigned int begin = 0;
    for ( ; begin < s.size() ; begin++)
        {
        if (!isspace(s[begin]))
            break;
        }

    //Find first non-ws char, going in reverse
    unsigned int end = s.size() - 1;
    for ( ; end > begin ; end--)
        {
        if (!isspace(s[end]))
            break;
        }
    //trace("begin:%d  end:%d", begin, end);

    String res = s.substr(begin, end-begin+1);
    return res;
}


Generated by  Doxygen 1.6.0   Back to index