Jamoma API  0.6.0.a19
TTAddress.cpp
1 /*
2  * Jamoma Class for accessing Addresses
3  * Copyright © 2012, Timothy Place
4  *
5  * License: This code is licensed under the terms of the "New BSD License"
6  * http://creativecommons.org/licenses/BSD/
7  */
8 
9 
10 #include "TTFoundationAPI.h"
11 
12 #if BOOST_REGEX
13 #include <boost/regex.hpp>
14 using namespace boost;
15 #else
16 #include <regex>
17 using namespace std;
18 #endif
19 
20 TTFOUNDATION_EXPORT TTRegex* ttRegexForInstanceZero = NULL;
21 
22 TTErr TTAddress::parseInstanceZero(const char* cstr, TTString& parsed)
23 {
24  // filter single "0" string
25  TTString toParse(cstr);
26  if (toParse.size() > 1) {
27 
28  parsed = toParse;
29 
30  TTStringIter begin = parsed.begin();
31  TTStringIter end = parsed.end();
32 
33  // parse and remove ".0"
34  while (!ttRegexForInstanceZero->parse(begin, end)) {
35  TTStringIter z_begin = ttRegexForInstanceZero->begin();
36  TTStringIter z_end = ttRegexForInstanceZero->end();
37 
38  TTString a(begin, z_begin);
39  TTString b(z_end, end);
40  parsed = a+b;
41 
42  begin = parsed.begin();
43  end = parsed.end();
44  }
45  }
46 
47  return kTTErrNone;
48 }
STL namespace.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
No Error.
Definition: TTBase.h:343
The TTString class is used to represent a string.
Definition: TTString.h:34