/src/skia/third_party/externals/dng_sdk/source/dng_string.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*****************************************************************************/ |
2 | | // Copyright 2006-2007 Adobe Systems Incorporated |
3 | | // All Rights Reserved. |
4 | | // |
5 | | // NOTICE: Adobe permits you to use, modify, and distribute this file in |
6 | | // accordance with the terms of the Adobe license agreement accompanying it. |
7 | | /*****************************************************************************/ |
8 | | |
9 | | /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_string.h#2 $ */ |
10 | | /* $DateTime: 2012/07/31 22:04:34 $ */ |
11 | | /* $Change: 840853 $ */ |
12 | | /* $Author: tknoll $ */ |
13 | | |
14 | | /** \file |
15 | | * Text string representation. |
16 | | */ |
17 | | |
18 | | /*****************************************************************************/ |
19 | | |
20 | | #ifndef __dng_string__ |
21 | | #define __dng_string__ |
22 | | |
23 | | /*****************************************************************************/ |
24 | | |
25 | | #include "dng_types.h" |
26 | | #include "dng_memory.h" |
27 | | |
28 | | /*****************************************************************************/ |
29 | | |
30 | | class dng_string |
31 | | { |
32 | | |
33 | | private: |
34 | | |
35 | | // Always stored internally as a UTF-8 encoded string. |
36 | | |
37 | | dng_memory_data fData; |
38 | | |
39 | | public: |
40 | | |
41 | | dng_string (); |
42 | | |
43 | | dng_string (const dng_string &s); |
44 | | |
45 | | dng_string & operator= (const dng_string &s); |
46 | | |
47 | | ~dng_string (); |
48 | | |
49 | | const char * Get () const; |
50 | | |
51 | | bool IsASCII () const; |
52 | | |
53 | | void Set (const char *s); |
54 | | |
55 | | void Set_ASCII (const char *s); |
56 | | |
57 | | void Set_UTF8 (const char *s); |
58 | | |
59 | | uint32 Get_SystemEncoding (dng_memory_data &buffer) const; |
60 | | |
61 | | void Set_SystemEncoding (const char *s); |
62 | | |
63 | | bool ValidSystemEncoding () const; |
64 | | |
65 | | void Set_JIS_X208_1990 (const char *s); |
66 | | |
67 | | static uint32 DecodeUTF8 (const char *&s, |
68 | | uint32 maxBytes = 6, |
69 | | bool *isValid = NULL); |
70 | | |
71 | | static bool IsUTF8 (const char *s); |
72 | | |
73 | | void Set_UTF8_or_System (const char *s); |
74 | | |
75 | | uint32 Get_UTF16 (dng_memory_data &buffer) const; |
76 | | |
77 | | void Set_UTF16 (const uint16 *s); |
78 | | |
79 | | void Clear (); |
80 | | |
81 | | void Truncate (uint32 maxBytes); |
82 | | |
83 | | bool TrimTrailingBlanks (); |
84 | | |
85 | | bool TrimLeadingBlanks (); |
86 | | |
87 | | bool IsEmpty () const; |
88 | | |
89 | | bool NotEmpty () const |
90 | 110 | { |
91 | 110 | return !IsEmpty (); |
92 | 110 | } |
93 | | |
94 | | uint32 Length () const; |
95 | | |
96 | | bool operator== (const dng_string &s) const; |
97 | | |
98 | | bool operator!= (const dng_string &s) const |
99 | 0 | { |
100 | 0 | return !(*this == s); |
101 | 0 | } |
102 | | |
103 | | // A utility for doing case insensitive comparisons on strings... |
104 | | |
105 | | static bool Matches (const char *t, |
106 | | const char *s, |
107 | | bool case_sensitive = false); |
108 | | |
109 | | // ...wrapped up for use with dng_string. |
110 | | |
111 | | bool Matches (const char *s, |
112 | | bool case_sensitive = false) const; |
113 | | |
114 | | bool StartsWith (const char *s, |
115 | | bool case_sensitive = false) const; |
116 | | |
117 | | bool EndsWith (const char *s, |
118 | | bool case_sensitive = false) const; |
119 | | |
120 | | bool Contains (const char *s, |
121 | | bool case_sensitive = false, |
122 | | int32 *match_offset = NULL) const; |
123 | | |
124 | | bool Replace (const char *old_string, |
125 | | const char *new_string, |
126 | | bool case_sensitive = true); |
127 | | |
128 | | bool TrimLeading (const char *s, |
129 | | bool case_sensitive = false); |
130 | | |
131 | | void Append (const char *s); |
132 | | |
133 | | void SetUppercase (); |
134 | | |
135 | | void SetLowercase (); |
136 | | |
137 | | void SetLineEndings (char ending); |
138 | | |
139 | | void SetLineEndingsToNewLines () |
140 | 0 | { |
141 | 0 | SetLineEndings ('\n'); |
142 | 0 | } |
143 | | |
144 | | void SetLineEndingsToReturns () |
145 | 0 | { |
146 | 0 | SetLineEndings ('\r'); |
147 | 0 | } |
148 | | |
149 | | void StripLowASCII (); |
150 | | |
151 | | void ForceASCII (); |
152 | | |
153 | | int32 Compare (const dng_string &s) const; |
154 | | |
155 | | // A utility to convert fields of numbers into comma separated numbers. |
156 | | |
157 | | void NormalizeAsCommaSeparatedNumbers (); |
158 | | |
159 | | }; |
160 | | |
161 | | /*****************************************************************************/ |
162 | | |
163 | | #endif |
164 | | |
165 | | /*****************************************************************************/ |