2 Copyright (C) 2011 Grame
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
24 #include "OSCAddress.h"
31 #define kAddressSep '/'
32 //--------------------------------------------------------------------------
33 string
OSCAddress::addressFirst (const string
& a
)
35 if (a
[0] == kAddressSep
) {
36 size_t n
= a
.find_first_of(kAddressSep
, 1);
37 if (n
== string::npos
) n
= a
.size();
38 return a
.substr(1, n
-1);
43 //--------------------------------------------------------------------------
44 string
OSCAddress::addressLast (const string
& a
)
46 size_t n
= a
.find_last_of(kAddressSep
);
47 if (n
== string::npos
) return "";
51 //--------------------------------------------------------------------------
52 string
OSCAddress::addressTail (const string
& a
)
54 if (a
[0] == kAddressSep
) {
55 size_t n
= a
.find_first_of(kAddressSep
, 1);
56 if (n
!= string::npos
) {
57 return a
.substr(n
, a
.size() - n
);