Line | |
---|
1 | // ================================================================ // |
---|
2 | // // |
---|
3 | // File : tools.cxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Coded by Ralf Westram (coder@reallysoft.de) in November 2006 // |
---|
7 | // Institute of Microbiology (Technical University Munich) // |
---|
8 | // http://www.arb-home.de/ // |
---|
9 | // // |
---|
10 | // ================================================================ // |
---|
11 | #include "tools.h" |
---|
12 | |
---|
13 | using namespace std; |
---|
14 | |
---|
15 | |
---|
16 | bool parseInfix(const string &str, const string& prefix, const string& postfix, string& foundInfix) { |
---|
17 | bool parsed = false; |
---|
18 | if (beginsWith(str, prefix) && endsWith(str, postfix)) { |
---|
19 | size_t strlen = str.length(); |
---|
20 | size_t prelen = prefix.length(); |
---|
21 | size_t postlen = postfix.length(); |
---|
22 | |
---|
23 | if (strlen >= (prelen+postlen)) { // otherwise str is to short (prefix and postfix overlap) |
---|
24 | foundInfix = str.substr(prelen, strlen-(prelen+postlen)); |
---|
25 | parsed = true; |
---|
26 | } |
---|
27 | } |
---|
28 | return parsed; |
---|
29 | } |
---|
30 | |
---|
31 | |
---|
32 | |
---|
Note: See
TracBrowser
for help on using the repository browser.