Itasca C++ Interface
Loading...
Searching...
No Matches
istringlist.h
1#pragma once
2
3#include <QtCore/qcontainerfwd.h>
4
5#include "istring.h"
6#include "idef.h"
7
8//class QStringList;
9//template <typename T> class QList;
10class IStringList : public IList<IString> {
11public:
12 using IList<IString>::IList;
13 IStringList(const IList<IString> &in) : IList<IString>(in) { }
14 IStringList(std::vector<string> &&in) { reserve(in.size()); for (auto &&v : in) emplace_back(v); in.clear(); }
15 IStringList(const std::vector<string> &in) { reserve(in.size()); for (auto &v : in) emplace_back(v); }
16 IStringList(const StringList &in) { reserve(in.size()); for (auto &v : in) emplace_back(v); }
17 explicit IStringList(const IString &s) : IList<IString>({s}) { }
18 BASE_EXPORT operator StringList() const;
19
20 // Temporary Conversion
21 BASE_EXPORT IStringList(const QStringList &sl);
23 BASE_EXPORT operator QList<IString>() const;
24 BASE_EXPORT operator QStringList() const;
25
26 void operator+=(const string &s) { push_back(s); }
27 void operator+=(const QString &s) { push_back(s); }
28 void operator+=(const char *str) { push_back(string(str)); }
29 BASE_EXPORT void operator+=(const StringList &s);
30 BASE_EXPORT void operator+=(const QStringList &s);
31 BASE_EXPORT void operator+=(const IStringList &s);
32 BASE_EXPORT void operator+=(const std::vector<string> &s);
33 BASE_EXPORT IStringList operator+(const IStringList &in) { IStringList out(*this); out += in; return out; }
34
35 IStringList &operator<<(const string &s) { push_back(s); return *this; }
36 BASE_EXPORT IStringList &operator<<(const std::vector<string> &s);
37 BASE_EXPORT IStringList &operator<<(const QStringList &s);
38
39 BASE_EXPORT void insert(int index,const IString &s);
40 void append(const IString &s) { push_back(s); }
41 BASE_EXPORT void append(const IStringList &);
42 BASE_EXPORT int removeDuplicates();
43 BASE_EXPORT void sort();
44 BASE_EXPORT IString takeFirst();
45
46 int length() const { return size(); }
47 int size() const { return to<int>(std::vector<IString>::size()); }
48 int count() const { return size(); }
49 IString value(int index,const IString &def={}) const { if (index<0 or index>=to<int>(size())) return def; return at(index); }
50 IString join(const IString &sep) const { return ::join(*this,sep); }
51 BASE_EXPORT bool contains(const IString &sep,IString::Case c=IString::Case::Sensitive) const;
52 BASE_EXPORT int indexOf(const IString &val) const;
53};
54
55inline StringList toStringList(const IStringList &sl) { return sl; }
56inline IStringList toIStringList(const StringList &sl) { return IStringList(sl); }
Definition idef.h:53
Definition istring.h:14
Definition istringlist.h:10
Definition idef.h:50
Definition basestring.h:89
#define BASE_EXPORT
Definition basedef.h:24
POPWARNING QDataStream & operator<<(QDataStream &ds, const Orientation2 &o)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition basetoqt.cpp:107