sources/mystring.h

Wed, 20 Jul 2016 18:29:13 +0300

author
Teemu Piippo <teemu@compsta2.com>
date
Wed, 20 Jul 2016 18:29:13 +0300
changeset 154
9cdd6b71f0d1
parent 147
12c93c4a137c
child 150
37db42ad451a
child 157
42bb29924218
permissions
-rw-r--r--

Eliminated unnecessary difference to the protocol5 branch

1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
109
e4966d7e615d Happy new year 2016
Teemu Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
2 Copyright 2014 - 2016 Teemu Piippo
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 All rights reserved.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 Redistribution and use in source and binary forms, with or without
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 modification, are permitted provided that the following conditions
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 are met:
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 1. Redistributions of source code must retain the above copyright
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 notice, this list of conditions and the following disclaimer.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 2. Redistributions in binary form must reproduce the above copyright
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 notice, this list of conditions and the following disclaimer in the
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 documentation and/or other materials provided with the distribution.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 3. Neither the name of the copyright holder nor the names of its
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 contributors may be used to endorse or promote products derived from
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 this software without specific prior written permission.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 */
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 #pragma once
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 #include <deque>
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 #include <string>
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 #include <stdarg.h>
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 #include "basics.h"
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 #include "list.h"
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
37
88
08ccaf26cffd Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents: 87
diff changeset
38 BEGIN_ZFC_NAMESPACE
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 class String
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 {
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 public:
88
08ccaf26cffd Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents: 87
diff changeset
44 typedef std::string::iterator Iterator;
08ccaf26cffd Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents: 87
diff changeset
45 typedef std::string::const_iterator ConstIterator;
69
eb4c25284a19 Removed a lot of boilerplate code
Teemu Piippo <crimsondusk64@gmail.com>
parents: 66
diff changeset
46
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
47 String();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
48 String(char a);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
49 String(const char* data);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
50 String(const std::string& data);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
51 String(const Vector<char>& data);
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
53 void append(const char* text);
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
54 void append(char character);
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
55 void append(const String& text);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
56 ConstIterator begin() const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
57 Iterator begin();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
58 int compare(const String &other) const;
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
59 int count(char character) const;
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
60 const char* chars() const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
61 void clear();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
62 ConstIterator end() const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
63 Iterator end();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
64 bool endsWith(const String &other) const;
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
65 int find(const char* subString, int startingPosition = 0) const;
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
66 int find(char character, int startingPosition = 0) const;
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
67 int indexDifference(int a, int b);
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
68 void insert(int position, char character);
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
69 void insert(int position, const char* string);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
70 bool isEmpty() const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
71 bool isNumeric() const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
72 void modifyIndex(int &a) const;
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
73 int findLast(const char* subString, int startingPosition = -1) const;
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
74 int length() const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
75 bool maskAgainst(const String &pattern) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
76 String md5() const;
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
77 String mid(int rangeBegin, int rangeEnd) const;
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
78 void normalize(int(*filter)(int) = &isspace);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
79 String normalized(int(*filter)(int) = &isspace) const;
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
80 void prepend(String text);
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
81 void remove(int position, int length);
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
82 void removeAt(int position);
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
83 void removeFromEnd(int length);
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
84 void removeFromStart(int length);
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
85 void replace(const char* text, const char* replacement);
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
86 void replace(int position, int amount, const String &text);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
87 String right(int length) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
88 void shrinkToFit();
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
89 class StringList split(const String &delimeter) const;
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
90 class StringList split(char delimeter) const;
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
91 void __cdecl sprintf(const char* fmtstr, ...);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
92 bool startsWith(const String &other) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
93 const std::string& stdString() const;
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
94 void strip(char unwanted);
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
95 void strip(const List<char> &unwanted);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
96 double toDouble(bool* ok = nullptr) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
97 float toFloat(bool* ok = nullptr) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
98 long toInt(bool* ok = nullptr, int base = 10) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
99 String toLowerCase() const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
100 String toUpperCase() const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
101 void vsprintf(const char* fmtstr, va_list args);
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
103 static String fromNumber(short int a);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
104 static String fromNumber(int a);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
105 static String fromNumber(long int a);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
106 static String fromNumber(unsigned short int a);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
107 static String fromNumber(unsigned int a);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
108 static String fromNumber(unsigned long int a);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
109 static String fromNumber(double a);
69
eb4c25284a19 Removed a lot of boilerplate code
Teemu Piippo <crimsondusk64@gmail.com>
parents: 66
diff changeset
110
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
111 String operator+(const String& data) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
112 String operator+(const char* data) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
113 String operator+(int num) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
114 String& operator+=(const String& data);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
115 String& operator+=(const char* data);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
116 String& operator+=(int num);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
117 String& operator+=(char data);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
118 char& operator[](int i);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
119 char operator[](int i) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
120 bool operator==(const String& other) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
121 bool operator==(const char* other) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
122 bool operator!=(const String& other) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
123 bool operator!=(const char* other) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
124 bool operator>(const String& other) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
125 bool operator<(const String& other) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
126 bool operator>=(const String& other) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
127 bool operator<=(const String& other) const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
128 operator const char*() const;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
129 operator const std::string&() const;
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 private:
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 std::string m_string;
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 };
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
135
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 class StringList : public List<String>
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 {
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 public:
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
139 StringList();
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
140 StringList(int numvalues);
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
141 StringList(const List<String>& other);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
142 String join(const String& delim);
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 };
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
146 inline bool operator==(const char* a, const String& b);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
147 inline String operator+(const char* a, const String& b);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
148
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
149 // --------------------------------------------------------------------------------------------------------------------
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
150
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
151 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
152 * \brief Constructs an empty string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
153 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
154 inline String::String() {}
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
155
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
156 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
157 * \brief Constructs a string from a single character.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
158 * \param character Character to create a string out of.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
159 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
160 inline String::String(char character)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
161 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
162 char buffer[2] = { character, '\0' };
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
163 m_string = buffer;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
164 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
165
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
166 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
167 * \brief Constructs a string from a char-array.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
168 * \param string char-array to convert.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
169 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
170 inline String::String(const char* string) :
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
171 m_string(string) {}
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
172
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
173 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
174 * \brief Constructs a string out of a \c std::string .
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
175 * \param string \c std::string to base the construction on.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
176 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
177 inline String::String(const std::string& string) :
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
178 m_string(string) {}
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
179
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
180 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
181 * \brief Constructs a string out of a vector of characters. The vector does not have to be null-terminated.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
182 * \param charVector Vector of characters to construct the string out of.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
183 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
184 inline String::String(const Vector<char>& charVector) :
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
185 m_string(charVector.data(), charVector.size()) {}
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
186
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
187 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
188 * \returns a constant iterator to the beginning of the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
189 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
190 inline String::ConstIterator String::begin() const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
191 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
192 return m_string.cbegin();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
193 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
194
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
195 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
196 * \returns the string's contents as a char-array.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
197 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
198 inline const char* String::chars() const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
199 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
200 return m_string.c_str();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
201 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
202
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
203 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
204 * \returns the string's constant end-iterator.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
205 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
206 inline String::ConstIterator String::end() const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
207 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
208 return m_string.end();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
209 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
210
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
211 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
212 * \returns whether or not the string is empty.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
213 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
214 inline bool String::isEmpty() const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
215 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
216 return m_string[0] == '\0';
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
217 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
218
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
219 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
220 * \returns the length of the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
221 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
222 inline int String::length() const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
223 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
224 return m_string.length();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
225 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
226
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
227 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
228 * \returns the underlying \c std::string .
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
229 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
230 inline const std::string& String::stdString() const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
231 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
232 return m_string;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
233 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
234
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
235 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
236 * \brief Adds text from a char-array to the end of the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
237 * \param text Text to append.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
238 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
239 inline void String::append(const char* text)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
240 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
241 m_string.append(text);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
242 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
243
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
244 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
245 * \brief Adds text to the end of the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
246 * \param text Text to append.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
247 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
248 inline void String::append(char character)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
249 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
250 m_string.push_back(character);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
251 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
252
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
253 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
254 * \brief Adds text from another string to the end of this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
255 * \param text Text to append.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
256 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
257 inline void String::append(const String& text)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
258 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
259 m_string.append(text.chars());
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
260 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
261
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
262 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
263 * \returns a mutable iterator to the beginning of the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
264 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
265 inline String::Iterator String::begin()
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
266 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
267 return m_string.begin();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
268 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
269
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
270 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
271 * \brief Clears the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
272 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
273 inline void String::clear()
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
274 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
275 m_string.clear();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
276 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
277
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
278 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
279 * \returns the string's mutable end-iterator.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
280 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
281 inline String::Iterator String::end()
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
282 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
283 return m_string.end();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
284 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
285
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
286 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
287 * \brief Compares two string indices, supporting negatives as offsets from the end of string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
288 * \param a First index to compare
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
289 * \param b Second index to compare
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
290 * \returns the difference of two indices.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
291 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
292 inline int String::indexDifference(int a, int b)
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
293 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
294 modifyIndex(a);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
295 modifyIndex(b);
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
296 return b - a;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
297 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
298
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
299 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
300 * \brief Inserts a character into the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
301 * \param position Position in the string where to insert the character into.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
302 * \param character Character to insert into the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
303 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
304 inline void String::insert(int position, char character)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
305 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
306 m_string.insert(m_string.begin() + position, character);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
307 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
308
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
309 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
310 * \brief Inserts a substring into the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
311 * \param position Position in the string where to insert the substring.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
312 * \param string Substring to insert.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
313 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
314 inline void String::insert(int position, const char* string)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
315 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
316 m_string.insert(position, string);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
317 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
318
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
319 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
320 * \brief Modifies the given index so that if it is negative, it is translated into a positive index starting from the
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
321 * end of the string. For example, an index of -1 will be modified to point to the last character in the string,
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
322 * -2 to the second last, etc.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
323 * \param index Index to translate.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
324 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
325 inline void String::modifyIndex(int& index) const
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
326 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
327 if (index < 0)
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
328 index = length() - index;
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
329 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
330
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
331 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
332 * \brief Prepends the given text to the beginning of the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
333 * \param text Text to prepend.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
334 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
335 inline void String::prepend(String text)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
336 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
337 m_string = (text + m_string).stdString();
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
338 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
339
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
340 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
341 * \brief Removes a range of text from the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
342 * \param position Position where to start removing text.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
343 * \param length Amount of characters to remove.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
344 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
345 inline void String::remove(int position, int length)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
346 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
347 m_string.replace(position, length, "");
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
348 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
349
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
350 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
351 * \brief Removes a single character from the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
352 * \param position Position of the character to remove string from.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
353 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
354 inline void String::removeAt(int position)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
355 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
356 m_string.erase(m_string.begin() + position);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
357 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
358
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
359 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
360 * \brief Removes a number of characters from the end of the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
361 * \param length Amount of characters to remove.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
362 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
363 inline void String::removeFromEnd(int length)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
364 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
365 remove(this->length() - length, length);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
366 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
367
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
368 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
369 * \brief Removes a number of characters from the beginning of the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
370 * \param length Amount of characters to remove.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
371 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
372 inline void String::removeFromStart(int length)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
373 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
374 remove(0, length);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
375 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
376
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
377 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
378 * \brief Replaces a range of text in the string with another.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
379 * \param position Position where to start replacing text.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
380 * \param amount Amount of characters to replace.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
381 * \param text Replacement string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
382 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
383 inline void String::replace(int position, int amount, const String& text)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
384 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
385 m_string.replace(position, amount, text.chars());
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
386 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
387
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
388 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
389 * \brief Shrinks the string so that it does not allocate more characters than necessary.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
390 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
391 inline void String::shrinkToFit()
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
392 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
393 m_string.shrink_to_fit();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
394 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
395
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
396 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
397 * \brief Converts a number into a string, and returns a new string with the number appended to the end of the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
398 * \param number Number to convert and append.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
399 * \returns the resulting string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
400 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
401 inline String String::operator+(int number) const
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
402 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
403 return *this + String::fromNumber(number);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
404 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
405
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
406 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
407 * \brief Appends text into the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
408 * \param text Text to append.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
409 * \returns a reference to this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
410 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
411 inline String& String::operator+=(const String& text)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
412 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
413 append(text);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
414 return *this;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
415 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
416
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
417 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
418 * \brief Appends text into the string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
419 * \param text Text to append.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
420 * \returns a reference to this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
421 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
422 inline String& String::operator+=(const char* text)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
423 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
424 append(text);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
425 return *this;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
426 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
427
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
428 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
429 * \brief Converts a number into a string, and appends it into this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
430 * \param number The number to append.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
431 * \returns a refence to this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
432 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
433 inline String& String::operator+=(int number)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
434 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
435 return operator+=(String::fromNumber(number));
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
436 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
437
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
438 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
439 * \brief Appends a character into this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
440 * \param character The character to append.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
441 * \return a reference to this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
442 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
443 inline String& String::operator+=(char character)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
444 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
445 append(character);
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
446 return *this;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
447 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
448
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
449 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
450 * \param index Index referring to a character of this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
451 * \returns an editable reference to the character pointed by the given index.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
452 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
453 inline char& String::operator[](int index)
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
454 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
455 return m_string[index];
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
456 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
457
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
458 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
459 * \param index Index referring to a character of this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
460 * \returns an const reference to the character pointed by the given index.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
461 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
462 inline char String::operator[](int index) const
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
463 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
464 return m_string[index];
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
465 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
466
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
467 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
468 * \param other String to compare with.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
469 * \returns whether or not this string is the same as the other string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
470 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
471 inline bool String::operator==(const String& other) const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
472 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
473 return stdString() == other.stdString();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
474 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
475
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
476 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
477 * \param other String to compare with.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
478 * \returns whether or not this string is the same as the other string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
479 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
480 inline bool String::operator==(const char* other) const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
481 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
482 return m_string == other;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
483 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
484
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
485 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
486 * \param other String to compare with.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
487 * \returns whether or not this string is different than the other string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
488 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
489 inline bool String::operator!=(const String& other) const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
490 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
491 return stdString() != other.stdString();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
492 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
493
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
494 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
495 * \param other String to compare with.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
496 * \returns whether or not this string is different than the other string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
497 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
498 inline bool String::operator!=(const char* other) const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
499 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
500 return m_string != other;
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
501 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
502
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
503 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
504 * \param other String to compare with.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
505 * \return whether or not this string is lexicographically greater than the other string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
506 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
507 inline bool String::operator>(const String& other) const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
508 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
509 return stdString() > other.stdString();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
510 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
511
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
512 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
513 * \param other String to compare with.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
514 * \return whether or not this string is lexicographically lesser than the other string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
515 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
516 inline bool String::operator<(const String& other) const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
517 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
518 return stdString() < other.stdString();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
519 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
520
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
521 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
522 * \param other String to compare with.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
523 * \return whether or not this string is lexicographically at least as great as the other string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
524 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
525 inline bool String::operator>=(const String& other) const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
526 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
527 return stdString() >= other.stdString();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
528 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
529
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
530 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
531 * \param other String to compare with.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
532 * \return whether or not this string is lexicographically at most as great as the other string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
533 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
534 inline bool String::operator<=(const String& other) const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
535 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
536 return stdString() <= other.stdString();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
537 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
538
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
539 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
540 * \returns a char-array representation of this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
541 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
542 inline String::operator const char*() const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
543 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
544 return chars();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
545 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
546
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
547 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
548 * \returns the underlying \c std::string of this string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
549 */
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
550 inline String::operator const std::string&() const
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
551 {
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
552 return stdString();
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
553 }
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
554
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
555 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
556 * \brief Constructs an empty string list.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
557 */
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
558 inline StringList::StringList() {}
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
559
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
560 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
561 * \brief Constructs a string list containing \c numvalues empty strings.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
562 * \param numvalues Amount of empty strings to fill.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
563 */
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
564 inline StringList::StringList(int numvalues) :
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
565 List<String>(numvalues) {}
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
566
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
567 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
568 * \brief Constructs a string list from another list of strings.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
569 * \param other The list of strings to use for construction.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
570 */
147
12c93c4a137c Documented mystring.cpp. String::trim removed as it does the same as String::removeFromEnd.
Teemu Piippo <teemu@compsta2.com>
parents: 146
diff changeset
571 inline StringList::StringList(const List<String>& other) :
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
572 List<String>(other) {}
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
573
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
574 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
575 * \brief An \c operator== implementation that allows a char-array to be at the left side of a string comparison
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
576 * with a \c String.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
577 * \param one A char-array representation of a string to compare.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
578 * \param other A string to compare.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
579 * \returns whether or not the two parameters are equal.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
580 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
581 inline bool operator==(const char* one, const String& other)
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
582 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
583 return other == one;
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
584 }
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
585
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
586 /*!
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
587 * \brief An \c operator+ implementation that allows a char-array to be at the left side of a string catenation
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
588 * with a \c String.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
589 * \param one A char-array representation of a string to catenate.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
590 * \param other A string to catenate.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
591 * \returns the catenated string.
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
592 */
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
593 inline String operator+(const char* one, const String& other)
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
594 {
146
81357dcd3da4 Added doxygen documentation to mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 145
diff changeset
595 return String(one) + other;
1
4dd5bde4e777 - a whole lot of supplementary source code!!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
596 }
88
08ccaf26cffd Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents: 87
diff changeset
597
145
d0aedc9be448 Renamed String methods, and reformatted mystring.h
Teemu Piippo <teemu@compsta2.com>
parents: 129
diff changeset
598
88
08ccaf26cffd Now works with MSVC 2010/pdcurses-win32a
Teemu Piippo <tsapii@utu.fi>
parents: 87
diff changeset
599 END_ZFC_NAMESPACE

mercurial