52 m_strings.insert(m_strings.begin() +
index, str);
65 m_strings[
index] = str;
82 m_strings.erase(m_strings.begin() +
index);
91 const string& compareText,
size_t foundIndex,
bool caseSensitive)
const 99 it != m_strings.end(); ++it, foundIndex++)
100 if (!
os::_strcmp(compareText.c_str(), it->c_str()))
return true;
105 it != m_strings.end(); ++it, foundIndex++)
106 if (!
os::_strcmpi(compareText.c_str(), it->c_str()))
return true;
120 size_t curPos = 0, totalLen = 0;
124 for (it = m_strings.begin(); it != m_strings.end(); it++)
125 totalLen += it->size() + 2;
127 outText.resize(totalLen);
131 for (it = m_strings.begin(); it != m_strings.end(); it++)
133 os::memcpy(&outText[curPos], totalLen, it->c_str(), it->size());
134 curPos += it->size();
135 outText[curPos++] =
'\r';
136 outText[curPos++] =
'\n';
166 wholeStr.resize(nBytes);
170 if (nBytes != fil.ReadBuffer(&wholeStr[0], nBytes))
189 for (it = m_strings.begin(); it != m_strings.end(); ++it)
191 fil.WriteBuffer(it->c_str(), it->size());
192 fil.WriteBuffer(
"\r\n", 2);
212 for (i = 0; i < N; i++) out << m_strings[i];
231 for (i = 0; i < N; i++) in >> m_strings[i];
251 outText = m_strings[
index];
264 return m_strings[
index];
276 return m_strings[
index];
286 string strToLookFor(keyName +
string(
"="));
287 size_t idx = string::npos;
292 idx = it->find(strToLookFor);
293 if (idx == 0)
return it->substr(strToLookFor.size());
307 string s(get_string(keyName));
308 return (
float)atof(
s.c_str());
318 string s(get_string(keyName));
319 return atoi(
s.c_str());
329 string s(get_string(keyName));
330 return atof(
s.c_str());
340 string s(get_string(keyName));
341 return atoi(
s.c_str()) != 0;
351 string strToLookFor(keyName +
string(
"="));
352 size_t idx = string::npos;
357 idx = it->find(strToLookFor);
361 (*it) = strToLookFor +
value;
367 m_strings.push_back(strToLookFor +
value);
void insert(size_t index, const std::string &str)
Inserts a new item at a given position (0=insert at the beggining,1=put into the second position...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
CStringList()
Default constructor (empty string list)
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void set(size_t index, const std::string &str)
Overwrites an existing position with a new value (0=first elements)
bool find(const std::string &compareText, size_t foundIndex, bool caseSensitive=true) const
Looks for a given string in the list, and returns its index, or returns "false" otherwise.
#define THROW_EXCEPTION(msg)
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
bool get_bool(const std::string &keyName)
Returns the value of the given key ("key=value").
float get_float(const std::string &keyName)
Returns the value of the given key ("key=value").
std::string getText() const
Returns the whole string list as a single string with ' ' characters for newlines.
const Scalar * const_iterator
std::string get_string(const std::string &keyName)
Returns the value of the given key ("key=value").
std::string operator()(size_t index) const
Returns one string from the line list.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A class for storing a list of text lines.
void remove(size_t index)
Delete the element at a given position (0=first element)
This CStream derived class allow using a file as a write-only, binary stream.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void clear()
Clear the whole list.
void setText(const std::string &inText)
Fills the string list by parsing a single string with '', ' ', or ' ' characters indicatng newlines...
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
size_t size() const
Returns the number of text lines in the list.
void tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) noexcept
Tokenizes a string according to a set of delimiting characters.
double get_double(const std::string &keyName)
Returns the value of the given key ("key=value").
int get_int(const std::string &keyName)
Returns the value of the given key ("key=value").
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
GLsizei const GLfloat * value
void get(size_t index, std::string &outText) const
Returns one string from the line list.
void saveToFile(const std::string &fileName) const
Save the string list to a file.
unsigned __int32 uint32_t
int _strcmp(const char *str1, const char *str2) noexcept
An OS-independent version of strcmp.
void loadFromFile(const std::string &fileName)
Load the string list from a file.
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
void add(const std::string &str)
Appends a new string at the end of the string list.
int _strcmpi(const char *str1, const char *str2) noexcept
An OS-independent version of strcmpi.