SeExpr
SeExpr2
StringUtils.h
Go to the documentation of this file.
1
/*
2
Copyright Disney Enterprises, Inc. All rights reserved.
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License
6
and the following modification to it: Section 6 Trademarks.
7
deleted and replaced with:
8
9
6. Trademarks. This License does not grant permission to use the
10
trade names, trademarks, service marks, or product names of the
11
Licensor and its affiliates, except as required for reproducing
12
the content of the NOTICE file.
13
14
You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
16
*/
17
#ifndef StringUtils_h
18
#define StringUtils_h
19
20
#include <string>
21
24
inline
std::string
unescapeString
(
const
std::string&
string
) {
25
std::string output(
string
);
26
int
index
= 0;
27
bool
special =
false
;
28
for
(
char
c :
string
) {
29
if
(special ==
true
) {
30
special =
false
;
31
switch
(c) {
32
case
'n'
: output[
index
++] =
'\n'
;
break
;
33
case
'r'
: output[
index
++] =
'\r'
;
break
;
34
case
't'
: output[
index
++] =
'\t'
;
break
;
35
case
'\\'
: output[
index
++] =
'\\'
;
break
;
36
case
'"'
: output[
index
++] =
'\"'
;
break
;
37
default
:
38
// leave the escape sequence as it was
39
output[
index
++] =
'\\'
;
40
output[
index
++] = c;
41
}
42
}
else
{
43
if
(c ==
'\\'
) {
44
special =
true
;
45
}
else
{
46
output[
index
++] = c;
47
}
48
}
49
}
50
output.resize(
index
);
51
return
output;
52
}
53
54
#endif
unescapeString
std::string unescapeString(const std::string &string)
Definition:
StringUtils.h:24
index
The result is computed int int< br >< div style="margin-left: 40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed).  
Generated by
1.8.20