HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_VarEncode.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * See: https://tools.ietf.org/html/rfc3492
7  *
8  */
9 
10 #ifndef __UT_VarEncode__
11 #define __UT_VarEncode__
12 
13 #include "UT_API.h"
14 #include <SYS/SYS_Types.h>
15 
16 class UT_StringHolder;
17 
19 {
20 public:
21  /// @{ Returns an encoded variable name, if @c var contains any characters
22  /// illegal in a C-style variable name. Note, the encoding is prefixed.
23  /// If @c var contains only valid C-variable characters, returns it unencoded.
24  static UT_StringHolder encodeVar(const UT_StringHolder &var);
25  static UT_StringHolder decodeVar(const UT_StringHolder &var);
26  /// @}
27 
28  /// @{ Returns an encoded attribute name, if @c var contains any characters
29  /// illegal in a geometry attribute name. Note, the encoding is prefixed.
30  /// If @c var contains only valid C-variable characters, returns it unencoded.
31  static UT_StringHolder encodeAttrib(const UT_StringHolder &attr);
32  static UT_StringHolder decodeAttrib(const UT_StringHolder &attr);
33  /// @}
34 
35  /// @{ Returns an encoded parameter name, if @c var contains any characters
36  /// illegal in a node parameter name. Note, the encoding is prefixed.
37  /// If @c var contains only valid C-variable characters, returns it unencoded.
38  static UT_StringHolder encodeParm(const UT_StringHolder &parm);
39  static UT_StringHolder decodeParm(const UT_StringHolder &parm);
40  /// @}
41 
42  /// @{ Does a simple test on the string to look for the encoding prefix.
43  /// Returns true if found, indicating that the string is already encoded.
44  /// This lets us avoid double-encoding the string.
45  static bool isEncoded(const UT_StringHolder &str);
46  /// @}
47 
48 private:
49  static UT_StringHolder encode(const UT_StringHolder &value,
50  const char *safechars);
51  static UT_StringHolder decode(const UT_StringHolder &value,
52  const char *safechars);
53 };
54 
55 #endif
#define UT_API
Definition: UT_API.h:14
Definition: core.h:1131