liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | /*==============================================================================
|
| 2 |
|
| 3 | ds_ASString.h
|
| 4 |
|
| 5 | GENERAL DESCRIPTION
|
| 6 | A string class with utility functions for parsing AS.
|
| 7 |
|
| 8 | EXTERNALIZED FUNCTIONS
|
| 9 |
|
| 10 | INITIALIZATION AND SEQUENCING REQUIREMENTS
|
| 11 |
|
| 12 | Copyright (c) 2014 by Qualcomm Technologies Incorporated. All Rights Reserved.
|
| 13 | ==============================================================================*/
|
| 14 |
|
| 15 | /*==============================================================================
|
| 16 | EDIT HISTORY FOR MODULE
|
| 17 |
|
| 18 | This section contains comments describing changes made to the module.
|
| 19 | Notice that changes are listed in reverse chronological order.
|
| 20 |
|
| 21 | when who what, where, why
|
| 22 | -------- --- ----------------------------------------------------------
|
| 23 | 04/21/14 ml Created file/Initial version.
|
| 24 | ==============================================================================*/
|
| 25 | #ifndef DS_AS_STRING_H
|
| 26 | #define DS_AS_STRING_H
|
| 27 |
|
| 28 | //#include "comdef.h"
|
| 29 | #include "mbtk_type.h"
|
| 30 |
|
| 31 | /*==============================================================================
|
| 32 | CLASS ASString
|
| 33 |
|
| 34 | DESCRIPTION
|
| 35 | A string class with utility functions for parsing AS.
|
| 36 | ==============================================================================*/
|
| 37 | class ASString
|
| 38 | {
|
| 39 | public:
|
| 40 | /*===========================================================================
|
| 41 | FUNCTION ASString CONSTRUCTOR
|
| 42 |
|
| 43 | DESCRIPTION
|
| 44 | Creates a new ASString. Default constructor will create an empty string.
|
| 45 | The other constructors will make a copy of the given string.
|
| 46 |
|
| 47 | DEPENDENCIES
|
| 48 | None
|
| 49 |
|
| 50 | SIDE EFFECTS
|
| 51 | None
|
| 52 | ===========================================================================*/
|
| 53 | ASString();
|
| 54 | ASString(const char* src);
|
| 55 | ASString(const char* src, uint32 len);
|
| 56 |
|
| 57 | // copy constructor
|
| 58 | ASString(ASString& src);
|
| 59 | ASString(const ASString& src);
|
| 60 |
|
| 61 | ~ASString();
|
| 62 |
|
| 63 |
|
| 64 | ASString& operator=(const ASString& rhs);
|
| 65 | ASString& operator=(const char* rhs);
|
| 66 | char operator[](const int index) const;
|
| 67 | char& operator[](const int index);
|
| 68 |
|
| 69 |
|
| 70 | /*============================================================================
|
| 71 | FUNCTION ASString::c_str
|
| 72 |
|
| 73 | DESCRIPTION
|
| 74 | Returns the raw c-string
|
| 75 |
|
| 76 | PARAMETERS
|
| 77 | None
|
| 78 |
|
| 79 | DEPENDENCIES
|
| 80 | None
|
| 81 |
|
| 82 | SIDE EFFECTS
|
| 83 | None
|
| 84 | ============================================================================*/
|
| 85 | const char* c_str() const;
|
| 86 |
|
| 87 | /*============================================================================
|
| 88 | FUNCTION ASString::size
|
| 89 | FUNCTION ASString::length
|
| 90 |
|
| 91 | DESCRIPTION
|
| 92 | Returns the length of the string
|
| 93 |
|
| 94 | PARAMETERS
|
| 95 | None
|
| 96 |
|
| 97 | DEPENDENCIES
|
| 98 | None
|
| 99 |
|
| 100 | SIDE EFFECTS
|
| 101 | None
|
| 102 | ============================================================================*/
|
| 103 | uint32 size() const;
|
| 104 | uint32 length() const;
|
| 105 |
|
| 106 | /*============================================================================
|
| 107 | FUNCTION ASString::empty
|
| 108 |
|
| 109 | DESCRIPTION
|
| 110 | Returns true if the string is empty or NULL
|
| 111 |
|
| 112 | PARAMETERS
|
| 113 | None
|
| 114 |
|
| 115 | DEPENDENCIES
|
| 116 | None
|
| 117 |
|
| 118 | SIDE EFFECTS
|
| 119 | None
|
| 120 | ============================================================================*/
|
| 121 | bool empty() const;
|
| 122 |
|
| 123 | /*============================================================================
|
| 124 | FUNCTION ASString::remove_trailing_spaces
|
| 125 |
|
| 126 | DESCRIPTION
|
| 127 | Removes all whiltespace, including tabs and newlines, at the end of the string.
|
| 128 |
|
| 129 | PARAMETERS
|
| 130 | None
|
| 131 |
|
| 132 | DEPENDENCIES
|
| 133 | None
|
| 134 |
|
| 135 | SIDE EFFECTS
|
| 136 | None
|
| 137 | ============================================================================*/
|
| 138 | void remove_trailing_spaces();
|
| 139 |
|
| 140 | /*============================================================================
|
| 141 | FUNCTION ASString::resolve_xml_escapes
|
| 142 |
|
| 143 | DESCRIPTION
|
| 144 | Replaces XML escape strings with the corresponding character.
|
| 145 |
|
| 146 | PARAMETERS
|
| 147 | None
|
| 148 |
|
| 149 | DEPENDENCIES
|
| 150 | None
|
| 151 |
|
| 152 | SIDE EFFECTS
|
| 153 | None
|
| 154 | ============================================================================*/
|
| 155 | bool resolve_xml_escapes();
|
| 156 |
|
| 157 | /*============================================================================
|
| 158 | FUNCTION ASString::to_lower
|
| 159 |
|
| 160 | DESCRIPTION
|
| 161 | Converts all characters in the string to lower case.
|
| 162 |
|
| 163 | PARAMETERS
|
| 164 | None
|
| 165 |
|
| 166 | DEPENDENCIES
|
| 167 | None
|
| 168 |
|
| 169 | SIDE EFFECTS
|
| 170 | None
|
| 171 | ============================================================================*/
|
| 172 | void to_lower();
|
| 173 |
|
| 174 | /*============================================================================
|
| 175 | FUNCTION ASString::limit_cmp
|
| 176 |
|
| 177 | DESCRIPTION
|
| 178 | Partial string compare up to len. Returns true if same, else false.
|
| 179 |
|
| 180 | PARAMETERS
|
| 181 | [In] cstr - The string to compare
|
| 182 | [In] len - The number of characters to compare.
|
| 183 |
|
| 184 | DEPENDENCIES
|
| 185 | None
|
| 186 |
|
| 187 | SIDE EFFECTS
|
| 188 | None
|
| 189 | ============================================================================*/
|
| 190 | bool limit_cmp(const char* cstr, const uint32 len) const;
|
| 191 |
|
| 192 | /*============================================================================
|
| 193 | FUNCTION ASString::append
|
| 194 |
|
| 195 | DESCRIPTION
|
| 196 | Appends the given string to the string it holds.
|
| 197 |
|
| 198 | PARAMETERS
|
| 199 | [In] append_str - The string to append
|
| 200 | [In] len - The number of characters to append
|
| 201 |
|
| 202 | DEPENDENCIES
|
| 203 | None
|
| 204 |
|
| 205 | SIDE EFFECTS
|
| 206 | None
|
| 207 | ============================================================================*/
|
| 208 | void append(const char* append_str);
|
| 209 | void append(const char* append_str, const uint32 len);
|
| 210 | void append(const ASString& append_str);
|
| 211 |
|
| 212 | protected:
|
| 213 | /*============================================================================
|
| 214 | FUNCTION ASString::copy_string
|
| 215 |
|
| 216 | DESCRIPTION
|
| 217 | Partial string compare up to len. Returns true if same, else false.
|
| 218 |
|
| 219 | PARAMETERS
|
| 220 | [In] src - The string to copy
|
| 221 | [In] len - The number of characters to copy
|
| 222 |
|
| 223 | DEPENDENCIES
|
| 224 | None
|
| 225 |
|
| 226 | SIDE EFFECTS
|
| 227 | None
|
| 228 | ============================================================================*/
|
| 229 | void copy_string(const char* src, uint32 len);
|
| 230 |
|
| 231 | char* str; // C-string object. Memory dynamically allocated as necessary
|
| 232 | };
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 | /*============================================================================
|
| 237 | FUNCTION operator==
|
| 238 | FUNCTION operator!=
|
| 239 | FUNCTION operator<
|
| 240 | FUNCTION operator>
|
| 241 |
|
| 242 | DESCRIPTION
|
| 243 | Compares the two strings and returns true/false based on the operator. The
|
| 244 | comparison will be case insensitive.
|
| 245 |
|
| 246 | PARAMETERS
|
| 247 | [In] lhs - The string to compare
|
| 248 | [In] rhs - The other string to compare
|
| 249 |
|
| 250 | DEPENDENCIES
|
| 251 | None
|
| 252 |
|
| 253 | SIDE EFFECTS
|
| 254 | None
|
| 255 | ============================================================================*/
|
| 256 | bool operator== (const ASString& lhs, const ASString& rhs);
|
| 257 | bool operator!= (const ASString& lhs, const ASString& rhs);
|
| 258 |
|
| 259 | bool operator== (const ASString& lhs, const char* rhs);
|
| 260 | bool operator!= (const ASString& lhs, const char* rhs);
|
| 261 |
|
| 262 | bool operator< (const ASString& lhs, const ASString& rhs);
|
| 263 | bool operator> (const ASString& lhs, const ASString& rhs);
|
| 264 |
|
| 265 | #endif /* DS_AS_STRING_H */
|