Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / ACEXML / common / XML_Util.cpp
blobe2f0fe7931717ca927e8065396d94647ab50a0c7
1 #include "ACEXML/common/XML_Util.h"
3 static const ACEXML_Char ESCAPED_AMP[] = ACE_TEXT("&");
4 static const ACEXML_Char ESCAPED_LESS[] = ACE_TEXT("<");
5 static const ACEXML_Char ESCAPED_GREATER[] = ACE_TEXT(">");
6 static const ACEXML_Char ESCAPED_APOS[] = ACE_TEXT("'");
7 static const ACEXML_Char ESCAPED_QUOTE[] = ACE_TEXT(""");
9 #define CSTRLEN(x) ((sizeof(x) / sizeof(ACEXML_Char)) - 1)
11 ACEXML_String ACEXML_escape_string(const ACEXML_String& str)
13 ACEXML_String ret(str.length ());
14 ACEXML_escape_string(str, ret);
15 return ret;
18 void ACEXML_escape_string(const ACEXML_String& in, ACEXML_String& out)
20 size_t len = in.length ();
21 out.clear();
22 for (size_t stridx = 0; stridx < len; ++stridx)
24 switch (in[stridx]) {
25 case '&':
26 out.append(ESCAPED_AMP, CSTRLEN(ESCAPED_AMP));
27 break;
28 case '<':
29 out.append(ESCAPED_LESS, CSTRLEN(ESCAPED_LESS));
30 break;
31 case '>':
32 out.append(ESCAPED_GREATER, CSTRLEN(ESCAPED_GREATER));
33 break;
34 case '\'':
35 out.append(ESCAPED_APOS, CSTRLEN(ESCAPED_APOS));
36 break;
37 case '\"':
38 out.append(ESCAPED_QUOTE, CSTRLEN(ESCAPED_QUOTE));
39 break;
40 default:
41 out += in[stridx];