libxspf  1.2.0
XspfToolbox.h
Go to the documentation of this file.
1 /*
2  * libxspf - XSPF playlist handling library
3  *
4  * Copyright (C) 2006-2008, Sebastian Pipping / Xiph.Org Foundation
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer.
14  *
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials
18  * provided with the distribution.
19  *
20  * * Neither the name of the Xiph.Org Foundation nor the names of
21  * its contributors may be used to endorse or promote products
22  * derived from this software without specific prior written
23  * permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
36  * OF THE POSSIBILITY OF SUCH DAMAGE.
37  *
38  * Sebastian Pipping, sping@xiph.org
39  */
40 
46 #ifndef XSPF_TOOLBOX_H
47 #define XSPF_TOOLBOX_H
48 
49 
50 #include "XspfDefines.h"
51 #include <string>
52 #include <cstring>
53 
54 namespace Xspf {
55 
56 
57 class XspfDateTime;
58 
59 
63 namespace Toolbox {
64 
65 
67 
72 struct XspfStringCompare {
73 
80  bool operator()(XML_Char const * s1, XML_Char const * s2) const;
81 
82 };
83 
85 
86 
95 XML_Char * newAndCopy(XML_Char const * source);
96 
104 void deleteNewAndCopy(XML_Char ** dest, XML_Char const * src);
105 
117 void deleteNewAndCopy(XML_Char const * & dest, bool & destOwnership,
118  XML_Char const * source, bool sourceCopy);
119 
128 template <class T>
129 T const * getSetNull(T const * & dest) {
130  T const * backup = dest;
131  dest = NULL;
132  return backup;
133 }
134 
135 
144 void copyIfOwned(XML_Char const * & dest, bool & ownDest, XML_Char const * source, bool ownSource);
145 
146 
155 void freeIfOwned(XML_Char const * & dest, bool ownDest);
156 
157 
169 XML_Char * makeAbsoluteUri(XML_Char const * sourceUri, XML_Char const * baseUri);
170 
171 
184 XML_Char * makeRelativeUri(XML_Char const * sourceUri, XML_Char const * baseUri);
185 
186 
194 bool isUri(XML_Char const * text);
195 
196 
204 bool isAbsoluteUri(XML_Char const * text);
205 
206 
216 bool extractInteger(XML_Char const * text, int inclusiveMinimum, int * output);
217 
218 
229 bool isWhiteSpace(XML_Char const * text, int numChars);
230 
231 
242 void cutOffWhiteSpace(XML_Char const * input, int inputNumChars,
243  XML_Char const * & blackSpaceStart, int & blackSpaceNumChars);
244 
245 
252 void trimString(std::basic_string<XML_Char> & target);
253 
254 
255 } // namespace Toolbox
256 } // namespace Xspf
257 
258 #endif // XSPF_TOOLBOX_H
void deleteNewAndCopy(XML_Char **dest, XML_Char const *src)
void freeIfOwned(XML_Char const *&dest, bool ownDest)
XML_Char * newAndCopy(XML_Char const *source)
void copyIfOwned(XML_Char const *&dest, bool &ownDest, XML_Char const *source, bool ownSource)
XML_Char * makeRelativeUri(XML_Char const *sourceUri, XML_Char const *baseUri)
XML_Char * makeAbsoluteUri(XML_Char const *sourceUri, XML_Char const *baseUri)
void cutOffWhiteSpace(XML_Char const *input, int inputNumChars, XML_Char const *&blackSpaceStart, int &blackSpaceNumChars)
bool isUri(XML_Char const *text)
bool extractInteger(XML_Char const *text, int inclusiveMinimum, int *output)
bool isAbsoluteUri(XML_Char const *text)
void trimString(std::basic_string< XML_Char > &target)
bool isWhiteSpace(XML_Char const *text, int numChars)
T const * getSetNull(T const *&dest)
Definition: XspfToolbox.h:129