diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-04-27 14:02:03 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-04-27 14:02:03 +0000 |
commit | 7c8a36e9dd320eb7e14da8fdb7875ff087b5d603 (patch) | |
tree | 197ab1fce765e898218fa6845411dc0df86acaaa /protocols/Skype/src/string_list.h | |
parent | 81068651df147a3369a740008f326b5168cb19a6 (diff) |
- some fixes in chats
- code reorganizing
git-svn-id: http://svn.miranda-ng.org/main/trunk@4554 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src/string_list.h')
-rw-r--r-- | protocols/Skype/src/string_list.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/protocols/Skype/src/string_list.h b/protocols/Skype/src/string_list.h new file mode 100644 index 0000000000..241080928e --- /dev/null +++ b/protocols/Skype/src/string_list.h @@ -0,0 +1,56 @@ +#pragma once
+
+#include <m_system_cpp.h>
+
+struct StringList : public LIST<wchar_t>
+{
+ static int compare(const wchar_t* p1, const wchar_t* p2) { return ::wcsicmp(p1, p2); }
+
+ StringList() : LIST<wchar_t>(2, compare) {}
+ StringList(const wchar_t* string, const wchar_t *delimeters = L" ") : LIST<wchar_t>(2, compare)
+ {
+ wchar_t *data = ::mir_wstrdup(string);
+ if (data)
+ {
+ wchar_t *p = ::wcstok(data, delimeters);
+ if (p)
+ {
+ this->insert(::mir_wstrdup(p));
+ while (p = wcstok(NULL, delimeters))
+ {
+ this->insert(::mir_wstrdup(p));
+ }
+ }
+ ::mir_free(data);
+ }
+ }
+ ~StringList() { destroy(); }
+
+ void destroy( void )
+ {
+ for (int i=0; i < count; i++)
+ mir_free(items[i]);
+
+ List_Destroy((SortedList*)this);
+ }
+
+ int insertn(const wchar_t* p) { return insert(::mir_wstrdup(p)); }
+
+ int remove(int idx)
+ {
+ mir_free(items[idx]);
+ return List_Remove((SortedList*)this, idx);
+ }
+
+ int remove(const wchar_t* p)
+ {
+ int idx;
+ return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1 ? remove(idx) : -1;
+ }
+
+ bool contains(wchar_t* p) const
+ {
+ int idx;
+ return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1;
+ }
+};
\ No newline at end of file |