• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _XMLRPCUTIL_H_
2 #define _XMLRPCUTIL_H_
3 //
4 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
5 //
6 #if defined(_MSC_VER)
7 # pragma warning(disable:4786)    // identifier was truncated in debug info
8 #endif
9 
10 #ifndef MAKEDEPEND
11 # include <string>
12 #endif
13 
14 #if defined(_MSC_VER)
15 # define snprintf	    _snprintf
16 # define vsnprintf    _vsnprintf
17 # define strcasecmp	  _stricmp
18 # define strncasecmp	_strnicmp
19 #elif defined(__BORLANDC__)
20 # define strcasecmp stricmp
21 # define strncasecmp strnicmp
22 #endif
23 
24 namespace XmlRpc {
25 
26   //! Utilities for XML parsing, encoding, and decoding and message handlers.
27   class XmlRpcUtil {
28   public:
29     // hokey xml parsing
30     //! Returns contents between <tag> and </tag>, updates offset to char after </tag>
31     static std::string parseTag(const char* tag, std::string const& xml, int* offset);
32 
33     //! Returns true if the tag is found and updates offset to the char after the tag
34     static bool findTag(const char* tag, std::string const& xml, int* offset);
35 
36     //! Returns the next tag and updates offset to the char after the tag, or empty string
37     //! if the next non-whitespace character is not '<'
38     static std::string getNextTag(std::string const& xml, int* offset);
39 
40     //! Returns true if the tag is found at the specified offset (modulo any whitespace)
41     //! and updates offset to the char after the tag
42     static bool nextTagIs(const char* tag, std::string const& xml, int* offset);
43 
44 
45     //! Convert raw text to encoded xml.
46     static std::string xmlEncode(const std::string& raw);
47 
48     //! Convert encoded xml to raw text
49     static std::string xmlDecode(const std::string& encoded);
50 
51 
52     //! Dump messages somewhere
53     static void log(int level, const char* fmt, ...);
54 
55     //! Dump error messages somewhere
56     static void error(const char* fmt, ...);
57 
58   };
59 } // namespace XmlRpc
60 
61 #endif // _XMLRPCUTIL_H_
62