ScummVM API documentation
cstring.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef M4_CORE_CSTRING_H
23 #define M4_CORE_CSTRING_H
24 
25 #include "common/str-array.h"
26 #include "m4/m4_types.h"
27 
28 namespace M4 {
29 
31 public:
33 
34  int indexOf(const Common::String &str) const {
35  for (uint i = 0; i < size(); ++i) {
36  if ((*this)[i] == str)
37  return i;
38  }
39  return -1;
40  }
41 
42  bool contains(const Common::String &str) const {
43  return indexOf(str) != -1;
44  }
45  void remove(const Common::String &str) {
46  int idx = indexOf(str);
47  if (idx != -1)
48  remove_at(idx);
49  }
50 };
51 
52 #define STR_PARSE_BUFFER_SIZE 255
53 
54 bool charIsIn(char ch, char *str);
55 int16 char_IsIn(char ch, char *str); //new
56 int dtoi(char *string);
57 bool stringIsInt(char *str);
58 bool stringIsFloat(char *str);
59 
60 int16 stringIsIn(char *str, char *strings[]);
61 
62 int32 cstrlen(const char *s);
63 void cstrcpy(char *dest, const char *src);
64 void cstrncpy(char *dest, const char *src, const int16 max_len);
65 char *cstrupr(char *src);
66 char *cstr_lower(char *src);
67 int xtoi(char *string);
68 int strpos(char *key, char *target);
69 void strdel(char *inp, int indx, int count);
70 void strseg(char *work, char *work2, int indx, int count);
71 void strins(char *work, char *newStr, int indx);
72 void str_purge_trailing_spaces(char *myline);
73 void str_purge_all_spaces(char *text);
74 char *str_strip_final_lf(char *mystring);
75 void str_add_final_lf(char *mystring);
76 void str_parse_init(char *instring, char delimiter);
77 char *str_parse(char *out);
78 
79 bool cstr_isdigit(char c);
80 
81 #define strrun(a,b,c) memset(a,b,c)
82 
83 } // namespace M4
84 
85 #endif
Definition: str.h:59
Array< String > StringArray
Definition: str-array.h:43
Definition: database.h:28
size_type size() const
Definition: array.h:315
String remove_at(size_type idx)
Definition: array.h:260
Definition: cstring.h:30