Rev 55 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 55 | Rev 67 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | /**
|
3 | /**
|
4 | * \file strtok.cpp
|
4 | * \file strtok.cpp
|
5 | *
|
5 | *
|
6 | * string tokenizer
|
6 | * string tokenizer
|
7 | *
|
7 | *
|
8 | * Copyright (C) 2006 Lukas Jelinek, <lukas@aiken.cz>
|
8 | * Copyright (C) 2006, 2007 Lukas Jelinek, <lukas@aiken.cz>
|
9 | *
|
9 | *
|
10 | * This program is free software; you can redistribute it and/or
|
10 | * This program is free software; you can redistribute it and/or
|
11 | * modify it under the terms of one of the following licenses:
|
11 | * modify it under the terms of one of the following licenses:
|
12 | *
|
12 | *
|
13 | * \li 1. X11-style license (see LICENSE-X11)
|
13 | * \li 1. X11-style license (see LICENSE-X11)
|
Line 95... | Line 95... | ||
95 | }
|
95 | }
|
96 | }
|
96 | }
|
97 | 97 | ||
98 | void StringTokenizer::_GetNextTokenNoPrefix(std::string& rToken) |
98 | void StringTokenizer::_GetNextTokenNoPrefix(std::string& rToken) |
99 | {
|
99 | {
|
- | 100 | const char* s = m_str.c_str(); |
|
100 | for (SIZE i=m_pos; i<m_len; i++) { |
101 | for (SIZE i=m_pos; i<m_len; i++) { |
101 | if (m_str[i] == m_cDelim) { |
102 | if (s[i] == m_cDelim) { |
102 | rToken = m_str.substr(m_pos, i - m_pos); |
103 | rToken = m_str.substr(m_pos, i - m_pos); |
103 | m_pos = i + 1; |
104 | m_pos = i + 1; |
104 | return; |
105 | return; |
105 | }
|
106 | }
|
106 | }
|
107 | }
|
Line 110... | Line 111... | ||
110 | }
|
111 | }
|
111 | 112 | ||
112 | void StringTokenizer::_GetNextTokenWithPrefix(std::string& rToken) |
113 | void StringTokenizer::_GetNextTokenWithPrefix(std::string& rToken) |
113 | {
|
114 | {
|
114 | int pref = 0; |
115 | int pref = 0; |
- | 116 | const char* s = m_str.c_str(); |
|
115 | for (SIZE i=m_pos; i<m_len; i++) { |
117 | for (SIZE i=m_pos; i<m_len; i++) { |
116 | if (m_str[i] == m_cDelim) { |
118 | if (s[i] == m_cDelim) { |
117 | if (pref == 0) { |
119 | if (pref == 0) { |
118 | rToken = m_str.substr(m_pos, i - m_pos); |
120 | rToken = m_str.substr(m_pos, i - m_pos); |
119 | m_pos = i + 1; |
121 | m_pos = i + 1; |
120 | return; |
122 | return; |
121 | }
|
123 | }
|
122 | else { |
124 | else { |
123 | pref = 0; |
125 | pref = 0; |
124 | }
|
126 | }
|
125 | }
|
127 | }
|
126 | else if (m_str[i] == m_cPrefix) { |
128 | else if (s[i] == m_cPrefix) { |
127 | if (pref == 1) |
129 | if (pref == 1) |
128 | pref = 0; |
130 | pref = 0; |
129 | else
|
131 | else
|
130 | pref = 1; |
132 | pref = 1; |
131 | }
|
133 | }
|