X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/1059e1cc0c2ecfa237406949aa26155b6a5b9154..66f23d4fabf89ad09adbd4dfc15ac6b5b2b7da83:/interpreter/preprocessor/faust-0.9.47mr3/architecture/osclib/faust/src/osc/OSCAddress.cpp diff --git a/interpreter/preprocessor/faust-0.9.47mr3/architecture/osclib/faust/src/osc/OSCAddress.cpp b/interpreter/preprocessor/faust-0.9.47mr3/architecture/osclib/faust/src/osc/OSCAddress.cpp new file mode 100644 index 0000000..d04e092 --- /dev/null +++ b/interpreter/preprocessor/faust-0.9.47mr3/architecture/osclib/faust/src/osc/OSCAddress.cpp @@ -0,0 +1,64 @@ +/* + Copyright (C) 2011 Grame + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France + research@grame.fr + +*/ + + +#include "OSCAddress.h" + +using namespace std; + +namespace oscfaust +{ + +#define kAddressSep '/' +//-------------------------------------------------------------------------- +string OSCAddress::addressFirst (const string& a) +{ + if (a[0] == kAddressSep) { + size_t n = a.find_first_of(kAddressSep, 1); + if (n == string::npos) n = a.size(); + return a.substr(1, n-1); + } + return ""; +} + +//-------------------------------------------------------------------------- +string OSCAddress::addressLast (const string& a) +{ + size_t n = a.find_last_of(kAddressSep); + if (n == string::npos) return ""; + return a.substr(n+1); +} + +//-------------------------------------------------------------------------- +string OSCAddress::addressTail (const string& a) +{ + if (a[0] == kAddressSep) { + size_t n = a.find_first_of(kAddressSep, 1); + if (n != string::npos) { + return a.substr(n, a.size() - n); + } + } + return ""; +} + + +} // end namespoace