Mercurial > ecos
comparison host/tools/Utils/common/Collections.h @ 76:435cced73e2f ecos-v1_3_1-release
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 14:10:45 +0000 |
| parents | |
| children | 6736c52df507 |
comparison
equal
deleted
inserted
replaced
| 75:41bf073c0c32 | 76:435cced73e2f |
|---|---|
| 1 //####COPYRIGHTBEGIN#### | |
| 2 // | |
| 3 // ---------------------------------------------------------------------------- | |
| 4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 5 // | |
| 6 // This program is part of the eCos host tools. | |
| 7 // | |
| 8 // This program is free software; you can redistribute it and/or modify it | |
| 9 // under the terms of the GNU General Public License as published by the Free | |
| 10 // Software Foundation; either version 2 of the License, or (at your option) | |
| 11 // any later version. | |
| 12 // | |
| 13 // This program is distributed in the hope that it will be useful, but WITHOUT | |
| 14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
| 16 // more details. | |
| 17 // | |
| 18 // You should have received a copy of the GNU General Public License along with | |
| 19 // this program; if not, write to the Free Software Foundation, Inc., | |
| 20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 21 // | |
| 22 // ---------------------------------------------------------------------------- | |
| 23 // | |
| 24 //####COPYRIGHTEND#### | |
| 25 #ifndef _ECOS_COLLECTIONS_H | |
| 26 #define _ECOS_COLLECTIONS_H | |
| 27 #ifdef _MSC_VER | |
| 28 //#ifdef _AFXDLL | |
| 29 //#include "stdafx.h" | |
| 30 //#endif | |
| 31 #pragma warning (push) | |
| 32 #pragma warning(disable:4018) // signed/unsigned mismatch | |
| 33 #pragma warning(disable:4097) // typedef-name 'string' used as synonym for class-name | |
| 34 #pragma warning(disable:4100) // unreferenced formal parameter | |
| 35 #pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned | |
| 36 #pragma warning(disable:4189) // local variable is initialized but not referenced | |
| 37 #pragma warning(disable:4244) // conversion from 'unsigned int' to 'char', possible loss of data | |
| 38 #pragma warning(disable:4250) // CdlConfigurationBody' : inherits 'CdlToplevelBody::is_active' via dominance | |
| 39 #pragma warning(disable:4284) // return type for (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation) | |
| 40 #pragma warning(disable:4290) // C++ Exception Specification ignored | |
| 41 #pragma warning(disable:4503) // decorated name length exceeded, name was truncated | |
| 42 #pragma warning(disable:4511) // copy constructor could not be generated | |
| 43 #pragma warning(disable:4512) // assignment operator could not be generated | |
| 44 #pragma warning(disable:4663) // C++ language change: to explicitly specialize class template... | |
| 45 #endif | |
| 46 | |
| 47 #include <string> | |
| 48 #include <vector> | |
| 49 | |
| 50 #include "eCosStd.h" | |
| 51 | |
| 52 class String; | |
| 53 typedef std::vector<String> StringArray; | |
| 54 | |
| 55 typedef std::basic_string<TCHAR> string; | |
| 56 | |
| 57 class String : public string { | |
| 58 public: | |
| 59 String() : string(),m_pszBuf(0){} | |
| 60 String(const String& rhs) : string(rhs),m_pszBuf(0){} | |
| 61 String(const String& rhs, size_type pos, size_type n) : string(rhs,pos,n),m_pszBuf(0){} | |
| 62 String(const TCHAR *s, size_type n) : string(s?s:_T(""),n),m_pszBuf(0){} | |
| 63 String(const TCHAR *s) : string(s?s:_T("")),m_pszBuf(0){} | |
| 64 String(size_type n, TCHAR c) : string(n,c),m_pszBuf(0){} | |
| 65 String(const_iterator first, const_iterator last) : string(first,last),m_pszBuf(0){} | |
| 66 virtual ~String() { delete [] m_pszBuf; } | |
| 67 bool operator==(const String& str) const {return 0==compare(str); } | |
| 68 bool operator==(const LPCTSTR psz) const {return 0==compare(psz); } | |
| 69 | |
| 70 operator LPCTSTR () const { return c_str(); } | |
| 71 unsigned int GetLength() const { return size(); } | |
| 72 LPTSTR GetBuffer (unsigned int nLength=0); | |
| 73 void Format(LPCTSTR pszFormat,...); | |
| 74 int Chop(StringArray &ar,TCHAR cSep=_TCHAR(' '),bool bObserveStrings=true) const; | |
| 75 void SetLength(unsigned int nLen) { resize(nLen); } | |
| 76 void ReleaseBuffer(); | |
| 77 char * GetCString () const; | |
| 78 static String CStrToUnicodeStr(const char *psz); | |
| 79 void vFormat(LPCTSTR pszFormat, va_list marker); | |
| 80 protected: | |
| 81 TCHAR *m_pszBuf; | |
| 82 int m_nBufferLength; | |
| 83 }; | |
| 84 | |
| 85 class Buffer { | |
| 86 unsigned int m_nSize; | |
| 87 void *pData; | |
| 88 public: | |
| 89 Buffer(unsigned int nSize) : m_nSize(nSize), pData(malloc(nSize)) {} | |
| 90 ~Buffer() { free(pData); } | |
| 91 void *Data() { return pData; } | |
| 92 void Resize(int nSize) { pData=realloc(pData,nSize); m_nSize=nSize; } | |
| 93 unsigned int Size() const { return m_nSize; } | |
| 94 }; | |
| 95 | |
| 96 typedef std::vector<void *> PtrArray; | |
| 97 | |
| 98 #ifdef _MSC_VER | |
| 99 #pragma warning (pop) | |
| 100 #endif | |
| 101 | |
| 102 #endif |
