32 #ifndef _CLI_TK_STL_H_ 33 #define _CLI_TK_STL_H_ 57 const unsigned int UI_MaxLength,
58 const char*
const STR_1,
59 const char*
const STR_2
62 tk::String str_Result(UI_MaxLength);
63 str_Result.Append(STR_1);
64 str_Result.Append(STR_2);
71 const unsigned int UI_MaxLength,
72 const char*
const STR_1,
73 const char*
const STR_2,
74 const char*
const STR_3
77 tk::String str_Result(Concat(UI_MaxLength, STR_1, STR_2));
78 str_Result.Append(STR_3);
85 const unsigned int UI_MaxLength,
86 const char*
const STR_1,
87 const char*
const STR_2,
88 const char*
const STR_3,
89 const char*
const STR_4
92 tk::String str_Result(Concat(UI_MaxLength, STR_1, STR_2, STR_3));
93 str_Result.Append(STR_4);
100 const unsigned int UI_MaxLength,
101 const char*
const STR_1,
102 const char*
const STR_2,
103 const char*
const STR_3,
104 const char*
const STR_4,
105 const char*
const STR_5
108 tk::String str_Result(Concat(UI_MaxLength, STR_1, STR_2, STR_3, STR_4));
109 str_Result.Append(STR_5);
120 const unsigned int UI_MaxLen
131 const unsigned int UI_MaxLen,
132 const char*
const STR_String
134 :
Object(), m_stlString(STR_String)
143 :
Object(), m_stlString((const char* const) TK_String)
157 return (
unsigned int) m_stlString.size();
164 return (GetLength() <= 0);
168 operator const char*
const(void)
const 170 return m_stlString.c_str();
176 const unsigned int UI_Pos
180 if (UI_Pos < m_stlString.size())
182 c_Char = m_stlString[UI_Pos];
190 const unsigned int UI_FirstCharacter,
191 const int I_SubStringLength
195 tk::String str_SubString(0);
198 unsigned int ui_CopyLen = I_SubStringLength;
199 if (GetLength() - UI_FirstCharacter < ui_CopyLen)
200 ui_CopyLen = GetLength() - UI_FirstCharacter;
203 if ((UI_FirstCharacter < GetLength()) && (ui_CopyLen > 0))
205 str_SubString.Append(m_stlString.substr(UI_FirstCharacter, ui_CopyLen).c_str());
208 return str_SubString;
215 tk::String str_Upper(0);
217 const unsigned int ui_StrLen = GetLength() + 1;
218 if (
char*
const pc_Upper =
new char[ui_StrLen])
220 memset(pc_Upper,
'\0', ui_StrLen);
221 if (
const char*
const pc_String = (
const char*) *
this) {
222 for (
unsigned int ui=0; ui<ui_StrLen; ui++)
224 pc_Upper[ui] = toupper(pc_String[ui]);
227 str_Upper.Append(pc_Upper);
238 tk::String str_Lower(0);
240 const unsigned int ui_StrLen = GetLength() + 1;
241 if (
char*
const pc_Lower =
new char[ui_StrLen])
243 memset(pc_Lower,
'\0', ui_StrLen);
244 if (
const char*
const pc_String = (
const char*) *
this)
246 for (
unsigned int ui=0; ui<ui_StrLen; ui++)
248 pc_Lower[ui] = tolower(pc_String[ui]);
251 str_Lower.Append(pc_Lower);
270 const char*
const STR_String
273 m_stlString = STR_String;
280 const char*
const STR_String
283 m_stlString += STR_String;
290 const char C_Character
293 m_stlString += C_Character;
301 const tk::String& STR_String
304 m_stlString = STR_String.m_stlString;
310 std::string m_stlString;
315 template <
class T>
class Queue :
public cli::Object
319 explicit Queue(
void);
324 const unsigned int UI_MaxCount
335 :
Object(), m_stlQueue(TK_Queue.m_stlQueue)
353 return m_stlQueue.empty();
360 return (
unsigned int) m_stlQueue.size();
379 explicit Iterator(
void) : std::deque<T>::iterator() {}
388 : std::deque<T>::iterator(it) {}
395 return const_cast<std::deque<T>&
>(m_stlQueue).begin();
404 return (it != m_stlQueue.end());
413 if (it != m_stlQueue.begin())
459 const T t_Element = *it;
460 it = m_stlQueue.erase(it);
471 m_stlQueue.push_front(T_Element);
481 m_stlQueue.push_back(T_Element);
490 return m_stlQueue.front();
498 return const_cast<T&
>(
508 return m_stlQueue.back();
516 return const_cast<T&
>(
526 const T t_Element = m_stlQueue.front();
527 m_stlQueue.pop_front();
536 const T t_Element = m_stlQueue.back();
537 m_stlQueue.pop_back();
545 const int (*cmp)(
const T&,
const T&)
549 bool b_Result =
true;
564 if (cmp(t_Sort, t_Ref) > 0)
575 if (q_1.Sort(cmp) && q_2.
Sort(cmp))
579 for (
Iterator it_1 = q_1.GetIterator();
583 if (!
AddTail(q_1.GetAt(it_1)))
611 std::deque<T> m_stlQueue;
615 template <
class K,
class T>
class Map :
public cli::Object
624 const unsigned int UI_MaxCount
634 :
Object(), m_stlMap(TK_Map.m_stlMap)
645 Map& operator=(
const Map&);
652 return m_stlMap.empty();
659 return (
unsigned int) m_stlMap.size();
680 if (m_stlMap.count(K_Key) > 0)
682 m_stlMap.erase(K_Key);
684 m_stlMap.insert(std::make_pair(K_Key, T_Value));
694 m_stlMap.erase(K_Key);
704 return (m_stlMap.count(K_Key) > 0);
713 typename std::map<K,T>::const_iterator it = m_stlMap.find(K_Key);
714 if (it != m_stlMap.end())
730 explicit Iterator(
void) : std::map<K,T>::iterator() {}
739 : std::map<K,T>::iterator(it) {}
746 std::map<K,T>::iterator::operator=(any);
761 it =
const_cast<std::map<K,T>&
>(m_stlMap).begin();
771 return (it != m_stlMap.end());
818 const T t_Element =
GetAt(it);
825 std::map<K,T> m_stlMap;
832 #endif // _CLI_TK_STL_H_
const bool Reset(void)
Resets the queue.
const bool AddTail(const T &T_Element)
Add a new element at the tail of the queue.
Main namespace of the CLI library.
virtual ~Map(void)
Destructor.
static const tk::String Concat(const unsigned int UI_MaxLength, const char *const STR_1, const char *const STR_2, const char *const STR_3)
Concatenation.
virtual ~Queue(void)
Destructor.
const T *const GetAt(const K &K_Key) const
Element accessor.
static const tk::String Concat(const unsigned int UI_MaxLength, const char *const STR_1, const char *const STR_2, const char *const STR_3, const char *const STR_4, const char *const STR_5)
Concatenation.
Queue(const unsigned int UI_MaxCount)
Main constructor.
const K & GetKey(const Iterator &it) const
Key retrieval.
const bool MoveNext(Iterator &it) const
Iterates forward the iterator.
const bool Unset(const K &K_Key)
Unset an item.
String(const String &TK_String)
Copy constructor.
const char GetChar(const unsigned int UI_Pos) const
Single character accessor.
#define CLI_NS_END(__ns)
End a namespace definition.
const String ToUpper(void) const
Upper string transformation.
static const tk::String Concat(const unsigned int UI_MaxLength, const char *const STR_1, const char *const STR_2, const char *const STR_3, const char *const STR_4)
Concatenation.
const bool Sort(const int(*cmp)(const T &, const T &))
Sort the list according to the given comparison function.
T & GetAt(const Iterator &it)
Modifiable item retrieval.
T & GetHead(void)
First item accessor of the modifiable queue.
const bool Reset(void)
String resetting.
Queue(const Queue< T > &TK_Queue)
Copy constructor.
const void * UnusedParameter(const T &T_UnusedParam)
Dummy function that aims to avoid warnings for unused parameters.
const bool IsEmpty(void) const
Determines whether the queue is empty.
const bool Append(const char *const STR_String)
String appending.
Map(const Map< K, T > &TK_Map)
Copy constructor.
const bool IsEmpty(void) const
Checks whether the string is empty or not.
const bool SetAt(const K &K_Key, const T &T_Value)
Set a new item.
const bool Append(const char C_Character)
String appending.
const T Remove(Iterator &it)
Item removal.
const T & GetAt(const Iterator &it) const
Read-only item retrieval.
const bool AddHead(const T &T_Element)
Add a new element at the head of the queue.
Iterator GetIterator(void) const
Iterator retrieval.
tk::String & operator=(const tk::String &STR_String)
Assignment operator.
const bool MoveNext(Iterator &it) const
Iterates the iterator.
const T RemoveHead(void)
Add a new element at the head of the queue.
Iterator(const Iterator &it)
Copy constructor.
const bool IsSet(const K &K_Key) const
Checks whether an element is set for this key.
const T & GetHead(void) const
First item accessor of the read-only queue.
const bool MovePrevious(Iterator &it) const
Iterates backward the iterator.
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
const unsigned int GetCount(void) const
Item count.
static const tk::String Concat(const unsigned int UI_MaxLength, const char *const STR_1, const char *const STR_2)
Concatenation.
const bool Set(const char *const STR_String)
String setting.
const tk::String SubString(const unsigned int UI_FirstCharacter, const int I_SubStringLength) const
Sub-string computation.
Iterator(const U &it)
Copy constructor from an STL iterator.
const T Remove(Iterator &it)
Item removal.
const unsigned int GetCount(void) const
Item count.
const bool Reset(void)
Resets the map.
const T & GetAt(const Iterator &it) const
Read-only item retrieval.
const String ToLower(void) const
Lower string transformation.
virtual ~String(void)
Destructor.
Map(const unsigned int UI_MaxCount)
Main constructor.
const bool IsEmpty(void) const
Determines whether the map is empty.
const T RemoveTail(void)
Add a new element at the tail of the queue.
Iterator GetIterator(void) const
Iterator retrieval.
const bool IsValid(const Iterator &it) const
Checks the element at the given position is valid.
T & GetAt(const Iterator &it)
Modifiable item retrieval.
const T & GetTail(void) const
Last item accessor of the read-only queue.
const unsigned int GetLength(void) const
String length accessor.
String(const unsigned int UI_MaxLen, const char *const STR_String)
Initial value constructor.
T & GetTail(void)
Last item accessor of the modifiable queue.
String(const unsigned int UI_MaxLen)
Constructor.
const bool IsValid(const Iterator &it) const
Checks the element at the given position is valid.