18 #ifdef USE_WINDOWS_DEBUG 19 #define WIN32_LEAN_AND_MEAN 33 void log(
int level,
const char* msg) {
34 #ifdef USE_WINDOWS_DEBUG 35 if (level <= _verbosity) { OutputDebugString(msg); OutputDebugString(
"\n"); }
37 if (level <= _verbosity) std::cout << msg << std::endl;
51 #ifdef USE_WINDOWS_DEBUG 52 void error(
const char* msg) {
53 OutputDebugString(msg); OutputDebugString(
"\n");
87 vsnprintf(buf,
sizeof(buf)-1,fmt,va);
89 buf[
sizeof(buf)-1] = 0;
100 vsnprintf(buf,
sizeof(buf)-1,fmt,va);
102 buf[
sizeof(buf)-1] = 0;
111 if (*offset >=
int(xml.length()))
return std::string();
112 size_t istart = xml.find(tag, *offset);
113 if (istart == std::string::npos)
return std::string();
114 istart += strlen(tag);
115 std::string etag =
"</";
117 size_t iend = xml.find(etag, istart);
118 if (iend == std::string::npos)
return std::string();
120 *offset = int(iend + etag.length());
121 return xml.substr(istart, iend-istart);
129 if (*offset >=
int(xml.length()))
return false;
130 size_t istart = xml.find(tag, *offset);
131 if (istart == std::string::npos)
134 *offset = int(istart + strlen(tag));
144 if (*offset >=
int(xml.length()))
return false;
145 const char* cp = xml.c_str() + *offset;
147 while (*cp && isspace(*cp)) {
152 int len = int(strlen(tag));
153 if (*cp && (strncmp(cp, tag, len) == 0)) {
165 if (*offset >=
int(xml.length()))
return std::string();
167 size_t pos = *offset;
168 const char* cp = xml.c_str() + pos;
169 while (*cp && isspace(*cp)) {
174 if (*cp !=
'<')
return std::string();
180 }
while (*cp++ !=
'>' && *cp != 0);
189 static const char AMP =
'&';
190 static const char rawEntity[] = {
'<',
'>',
'&',
'\'',
'\"', 0 };
191 static const char*
xmlEntity[] = {
"lt;",
"gt;",
"amp;",
"apos;",
"quot;", 0 };
200 std::string::size_type iAmp = encoded.find(AMP);
201 if (iAmp == std::string::npos)
204 std::string decoded(encoded, 0, iAmp);
205 std::string::size_type iSize = encoded.size();
206 decoded.reserve(iSize);
208 const char* ens = encoded.c_str();
209 while (iAmp != iSize) {
210 if (encoded[iAmp] == AMP && iAmp+1 < iSize) {
212 for (iEntity=0; xmlEntity[iEntity] != 0; ++iEntity)
214 if (strncmp(ens+iAmp+1, xmlEntity[iEntity], xmlEntLen[iEntity]) == 0)
216 decoded += rawEntity[iEntity];
217 iAmp += xmlEntLen[iEntity]+1;
220 if (xmlEntity[iEntity] == 0)
221 decoded += encoded[iAmp++];
224 decoded += encoded[iAmp++];
237 std::string::size_type iRep = raw.find_first_of(rawEntity);
238 if (iRep == std::string::npos)
241 std::string encoded(raw, 0, iRep);
242 std::string::size_type iSize = raw.size();
244 while (iRep != iSize) {
246 for (iEntity=0; rawEntity[iEntity] != 0; ++iEntity)
247 if (raw[iRep] == rawEntity[iEntity])
250 encoded += xmlEntity[iEntity];
253 if (rawEntity[iEntity] == 0)
254 encoded += raw[iRep];
static XmlRpcLogHandler * getLogHandler()
Returns a pointer to the currently installed message reporting object.
void log(int level, const char *msg)
Output a message. Custom error handlers should define this method.
const char XMLRPC_VERSION[]
Version identifier.
static XmlRpcErrorHandler * _errorHandler
static int getVerbosity()
Returns the level of verbosity of informational messages. 0 is no output, 5 is very verbose...
static const char rawEntity[]
static std::string getNextTag(std::string const &xml, int *offset)
static std::string parseTag(const char *tag, std::string const &xml, int *offset)
Returns contents between <tag> and </tag>, updates offset to char after </tag>
static void setVerbosity(int v)
Specify the level of verbosity of informational messages. 0 is no output, 5 is very verbose...
static XmlRpcErrorHandler * getErrorHandler()
Returns a pointer to the currently installed error handling object.
static void error(const char *fmt,...)
Dump error messages somewhere.
DefaultErrorHandler defaultErrorHandler
static bool findTag(const char *tag, std::string const &xml, int *offset)
Returns true if the tag is found and updates offset to the char after the tag.
virtual void error(const char *msg)=0
Report an error. Custom error handlers should define this method.
int getVerbosity()
Returns log message verbosity. This is short for XmlRpcLogHandler::getVerbosity() ...
void setVerbosity(int level)
Sets log message verbosity. This is short for XmlRpcLogHandler::setVerbosity(level) ...
An interface allowing custom handling of informational message reporting.
static XmlRpcLogHandler * _logHandler
DefaultLogHandler defaultLogHandler
static std::string xmlEncode(const std::string &raw)
Convert raw text to encoded xml.
void error(const char *)
Report an error. Custom error handlers should define this method.
static const int xmlEntLen[]
static std::string xmlDecode(const std::string &encoded)
Convert encoded xml to raw text.
static void log(int level, const char *fmt,...)
Dump messages somewhere.
static bool nextTagIs(const char *tag, std::string const &xml, int *offset)
static const char * xmlEntity[]
virtual void log(int level, const char *msg)=0
Output a message. Custom error handlers should define this method.
An interface allowing custom handling of error message reporting.