File: nextfield1.cc

package info (click to toggle)
bobcat 1.18.1-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,920 kB
  • ctags: 575
  • sloc: makefile: 12,973; cpp: 6,284; perl: 401; ansic: 68; sh: 52
file content (35 lines) | stat: -rw-r--r-- 1,478 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "string.ih"

String::Type String::nextField(string const &str, 
                    const_iterator *until, const_iterator from,
                    string const &separators)
{
    if (separators.find(*from) != string::npos) // saw a separator
    {                                           // get it, `*until' points 
        *until = separator(str, from, separators);   
                                                // beyond it.
        return SEPARATOR;
    }

    switch (*from)                              // handle all other cases
    {
        case '"':                               // d-quoted string
            *until = quoted(str, from, '"');
                                                // if pointing at the matching
                                                // " then it's ok, otherwise
                                                // an error was encountered
        return *until != str.end() ? DQUOTE : DQUOTE_UNTERMINATED;

        case '\'':    
            *until = quoted(str, from, '\'');
                                                // if pointing at the matching
                                                // ' then it's ok, otherwise
                                                // an error was encountered

        return *until != str.end() ? SQUOTE : SQUOTE_UNTERMINATED;

        default:                                // otherwise get the next word
        return word(str, until, from, separators);
    }
}