#pragma once #include #include "String.WString.hpp" #include "Iterator.tlh" //----------------------------------------------------------------------------- // WStringArray //----------------------------------------------------------------------------- class WStringArray : public std::vector { using inherited = std::vector ; public: // using Iterator = Iterator >; public: // Nothing different with Array but add some search functions // find string starting at left, -1 if not found int Find (const eSTR::WString & str) const { for (auto Iter = Iterator::From (*this); Iter; Iter++) { const auto & s = Iter (); if (s == str) return Iter.Index (); } return -1; } // find string starting at left, -1 if not found int NCFind (const eSTR::WString & str) const { for (auto Iter = Iterator::From (*this); Iter; Iter++) { const auto & s = Iter (); if (!s.CompareNoCase (str)) return Iter.Index (); } return -1; } bool IsExist (const eSTR::WString & str) const { return (Find (str) >= 0); } bool IsEmpty () const { return empty (); } void Add (const eSTR::WString & str) { push_back (str); } void Add (eSTR::WString && str) { push_back (str); } int GetSize () const { return (int) size (); } void Reset () { clear (); } int GetStringLength (void) const { int Length = 0; for (auto Iter = Iterator::From (*this); Iter; Iter++) { const auto & s = Iter (); Length += s.GetLength (); } return Length; } virtual eSTR::WString ToString (void) const { return ToString (eSTR::WStringView ()); } virtual eSTR::WString ToString (CV_WString & sep) const { // ·µ»Ø×Ö·ûÊý int seplen = sep.Length (); int length = 0; for (auto Iter = Iterator::From (*this); Iter; Iter++) { const auto & s = Iter (); length += s.GetLength () + 2; length += seplen + 2; } eSTR::WString rc; rc.GetBuffer (length); // ×Ö·ûÊý for (auto Iter = Iterator::From (*this); Iter; Iter++) { const auto & s = Iter (); rc += s; rc += sep; } return rc; } WStringArray & operator << (const eSTR::WString & string) { Add (string); return (*this); } WStringArray & operator << (CV_WString & lpsz) { Add (lpsz); return (*this); } };