From 1229cee3091839af4dd181e28b55e4823079007e Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 5 May 2013 08:38:57 +0000 Subject: - reworked invitation to chat - fixed chat contact's statuses - added "Spawn conversation" button in contact dialog - StringList now based on stl git-svn-id: http://svn.miranda-ng.org/main/trunk@4586 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/string_list.h | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'protocols/Skype/src/string_list.h') diff --git a/protocols/Skype/src/string_list.h b/protocols/Skype/src/string_list.h index 241080928e..df1ce7b0fa 100644 --- a/protocols/Skype/src/string_list.h +++ b/protocols/Skype/src/string_list.h @@ -1,13 +1,16 @@ #pragma once -#include +#include +#include -struct StringList : public LIST +class StringList { - static int compare(const wchar_t* p1, const wchar_t* p2) { return ::wcsicmp(p1, p2); } +private: + std::vector strings; - StringList() : LIST(2, compare) {} - StringList(const wchar_t* string, const wchar_t *delimeters = L" ") : LIST(2, compare) +public: + StringList() {} + StringList(const wchar_t* string, const wchar_t *delimeters = L" ") { wchar_t *data = ::mir_wstrdup(string); if (data) @@ -15,42 +18,44 @@ struct StringList : public LIST wchar_t *p = ::wcstok(data, delimeters); if (p) { - this->insert(::mir_wstrdup(p)); + this->strings.push_back(::mir_wstrdup(p)); while (p = wcstok(NULL, delimeters)) { - this->insert(::mir_wstrdup(p)); + this->strings.push_back(::mir_wstrdup(p)); } } ::mir_free(data); } } - ~StringList() { destroy(); } + virtual ~StringList() {} - void destroy( void ) - { - for (int i=0; i < count; i++) - mir_free(items[i]); + __inline const wchar_t *operator[](size_t idx) const + { + return (idx >= 0 && idx < this->size()) ? this->strings[idx].c_str() : NULL; + } - List_Destroy((SortedList*)this); + __inline void insert(const wchar_t* p) + { + this->strings.push_back(::mir_wstrdup(p)); } - int insertn(const wchar_t* p) { return insert(::mir_wstrdup(p)); } + __inline bool contains(const wchar_t* p) const + { + return std::find(this->strings.begin(), this->strings.end(), p) != this->strings.end(); + } - int remove(int idx) + __inline size_t size() const { - mir_free(items[idx]); - return List_Remove((SortedList*)this, idx); + return this->strings.size(); } - int remove(const wchar_t* p) + __inline bool empty() const { - int idx; - return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1 ? remove(idx) : -1; + return this->strings.empty(); } - bool contains(wchar_t* p) const + __inline void clear() { - int idx; - return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1; + this->strings.clear(); } }; \ No newline at end of file -- cgit v1.2.3