CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
TestXml.cpp
Go to the documentation of this file.
1// TestXml.cpp : Test XML encoding and decoding.
2// The characters <>&'" are illegal in xml and must be encoded.
3
4
5#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
6
7#include <iostream>
8// If you are using MSVC++6, you should update <string> to fix
9// BUG: getline Template Function Reads Extra Character
10#include <string>
11#include <assert.h>
12#include <stdlib.h>
13
14#include "XmlRpcUtil.h"
15
16using namespace XmlRpc;
17
18
19int main(int argc, char* argv[])
20{
21 // Basic tests
22 std::string empty;
23 assert(empty == XmlRpcUtil::xmlEncode(empty));
24 assert(empty == XmlRpcUtil::xmlDecode(empty));
25 assert(empty == XmlRpcUtil::xmlEncode(""));
26 assert(empty == XmlRpcUtil::xmlDecode(""));
27
28 std::string raw("<>&'\"");
30
31 std::cout << "Basic tests passed.\n";
32
33 // Interactive tests
34 std::string s;
35 for (;;) {
36 std::cout << "\nEnter line of raw text to encode:\n";
37 std::getline(std::cin, s);
38 if (s.empty()) break;
39
40 std::cout << XmlRpcUtil::xmlEncode(s) << std::endl;
41 }
42
43 for (;;) {
44 std::cout << "\nEnter line of xml-encoded text to decode:\n";
45 std::getline(std::cin, s);
46 if (s.empty()) break;
47
48 std::cout << XmlRpcUtil::xmlDecode(s) << std::endl;
49 }
50
51 return 0;
52}
53
XmlRpcServer s
Definition: HelloServer.cpp:11
static std::string xmlEncode(const std::string &raw)
Convert raw text to encoded xml.
Definition: XmlRpcUtil.cpp:224
static std::string xmlDecode(const std::string &encoded)
Convert encoded xml to raw text.
Definition: XmlRpcUtil.cpp:187
Definition: XmlRpc.h:35
int main()
Definition: test_IFile.cxx:11