diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2009-08-17 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:00 +0300 |
commit | c99f3ebdd639c2adb03d8b44001b10af18516504 (patch) | |
tree | 92aaf34e5edbd7287c3f55037190da75ab0a8000 /CPP/Common | |
parent | 829409452d85cd6dd9dfc9151f109d6e13a2bb1c (diff) |
9.06 beta
Diffstat (limited to 'CPP/Common')
-rwxr-xr-x | CPP/Common/Buffer.h | 2 | ||||
-rwxr-xr-x | CPP/Common/MyGuidDef.h | 2 | ||||
-rwxr-xr-x | CPP/Common/MyInitGuid.h | 11 | ||||
-rwxr-xr-x | CPP/Common/MyString.cpp | 2 | ||||
-rwxr-xr-x | CPP/Common/MyString.h | 43 | ||||
-rwxr-xr-x | CPP/Common/MyUnknown.h | 15 | ||||
-rwxr-xr-x | CPP/Common/Random.cpp | 21 | ||||
-rwxr-xr-x | CPP/Common/StringConvert.cpp | 7 | ||||
-rwxr-xr-x | CPP/Common/StringConvert.h | 6 |
9 files changed, 55 insertions, 54 deletions
diff --git a/CPP/Common/Buffer.h b/CPP/Common/Buffer.h index b6960fa8..118fe11f 100755 --- a/CPP/Common/Buffer.h +++ b/CPP/Common/Buffer.h @@ -19,7 +19,7 @@ public: } CBuffer(): _capacity(0), _items(0) {}; CBuffer(const CBuffer &buffer): _capacity(0), _items(0) { *this = buffer; } - CBuffer(size_t size): _items(0), _capacity(0) { SetCapacity(size); } + CBuffer(size_t size): _items(0), _capacity(0) { SetCapacity(size); } virtual ~CBuffer() { delete []_items; } operator T *() { return _items; }; operator const T *() const { return _items; }; diff --git a/CPP/Common/MyGuidDef.h b/CPP/Common/MyGuidDef.h index 7cfaba0c..337884f6 100755 --- a/CPP/Common/MyGuidDef.h +++ b/CPP/Common/MyGuidDef.h @@ -47,7 +47,7 @@ inline int operator!=(REFGUID g1, REFGUID g2) { return !(g1 == g2); } #ifdef INITGUID #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } + MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } #else #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ MY_EXTERN_C const GUID name diff --git a/CPP/Common/MyInitGuid.h b/CPP/Common/MyInitGuid.h index 4fc15565..d6a48698 100755 --- a/CPP/Common/MyInitGuid.h +++ b/CPP/Common/MyInitGuid.h @@ -1,10 +1,17 @@ // Common/MyInitGuid.h -#ifndef __COMMON_MYINITGUID_H -#define __COMMON_MYINITGUID_H +#ifndef __COMMON_MY_INITGUID_H +#define __COMMON_MY_INITGUID_H #ifdef _WIN32 +#ifdef UNDER_CE +#include <basetyps.h> +#endif #include <initguid.h> +#ifdef UNDER_CE +DEFINE_GUID(IID_IUnknown, +0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); +#endif #else #define INITGUID #include "MyGuidDef.h" diff --git a/CPP/Common/MyString.cpp b/CPP/Common/MyString.cpp index 2c02e822..3d1ce2b8 100755 --- a/CPP/Common/MyString.cpp +++ b/CPP/Common/MyString.cpp @@ -96,7 +96,7 @@ int MyStringCollate(const wchar_t *s1, const wchar_t *s2) #endif } -#ifndef _WIN32_WCE +#ifndef UNDER_CE int MyStringCollate(const char *s1, const char *s2) { return ConvertCompareResult(CompareStringA( diff --git a/CPP/Common/MyString.h b/CPP/Common/MyString.h index bae239da..e8830092 100755 --- a/CPP/Common/MyString.h +++ b/CPP/Common/MyString.h @@ -4,7 +4,6 @@ #define __COMMON_STRING_H #include <string.h> -// #include <wchar.h> #include "MyVector.h" @@ -39,13 +38,15 @@ inline const wchar_t* MyStringGetPrevCharPointer(const wchar_t *, const wchar_t #ifdef _WIN32 -inline char* MyStringGetNextCharPointer(char *p) - { return CharNextA(p); } inline const char* MyStringGetNextCharPointer(const char *p) - { return CharNextA(p); } +{ + #ifdef UNDER_CE + return p + 1; + #else + return CharNextA(p); + #endif +} -inline char* MyStringGetPrevCharPointer(char *base, char *p) - { return CharPrevA(base, p); } inline const char* MyStringGetPrevCharPointer(const char *base, const char *p) { return CharPrevA(base, p); } @@ -58,8 +59,6 @@ inline wchar_t MyCharUpper(wchar_t c) wchar_t MyCharUpper(wchar_t c); #endif -inline char MyCharLower(char c) - { return (char)(unsigned int)(UINT_PTR)CharLowerA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); } #ifdef _UNICODE inline wchar_t MyCharLower(wchar_t c) { return (wchar_t)(unsigned int)(UINT_PTR)CharLowerW((LPWSTR)(UINT_PTR)(unsigned int)c); } @@ -67,6 +66,13 @@ inline wchar_t MyCharLower(wchar_t c) wchar_t MyCharLower(wchar_t c); #endif +inline char MyCharLower(char c) +#ifdef UNDER_CE + { return (char)MyCharLower((wchar_t)c); } +#else + { return (char)(unsigned int)(UINT_PTR)CharLowerA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); } +#endif + inline char * MyStringUpper(char *s) { return CharUpperA(s); } #ifdef _UNICODE inline wchar_t * MyStringUpper(wchar_t *s) { return CharUpperW(s); } @@ -89,7 +95,7 @@ wchar_t MyCharUpper(wchar_t c); // Compare /* -#ifndef _WIN32_WCE +#ifndef UNDER_CE int MyStringCollate(const char *s1, const char *s2); int MyStringCollateNoCase(const char *s1, const char *s2); #endif @@ -148,12 +154,8 @@ class CStringBase MoveItems(index + size, index); } - static T *GetNextCharPointer(T *p) - { return MyStringGetNextCharPointer(p); } static const T *GetNextCharPointer(const T *p) { return MyStringGetNextCharPointer(p); } - static T *GetPrevCharPointer(T *base, T *p) - { return MyStringGetPrevCharPointer(base, p); } static const T *GetPrevCharPointer(const T *base, const T *p) { return MyStringGetPrevCharPointer(base, p); } protected: @@ -168,10 +170,8 @@ protected: return; /* const int kMaxStringSize = 0x20000000; - #ifndef _WIN32_WCE if (newCapacity > kMaxStringSize || newCapacity < _length) throw 1052337; - #endif */ T *newBuffer = new T[realCapacity]; if (_capacity > 0) @@ -234,6 +234,8 @@ public: operator const T*() const { return _chars;} + T Back() const { return _chars[_length - 1]; } + // The minimum size of the character buffer in characters. // This value does not include space for a null terminator. T* GetBuffer(int minBufLength) @@ -246,10 +248,8 @@ public: void ReleaseBuffer(int newLength) { /* - #ifndef _WIN32_WCE if (newLength >= _capacity) throw 282217; - #endif */ _chars[newLength] = 0; _length = newLength; @@ -316,7 +316,7 @@ public: CStringBase Mid(int startIndex) const { return Mid(startIndex, _length - startIndex); } - CStringBase Mid(int startIndex, int count ) const + CStringBase Mid(int startIndex, int count) const { if (startIndex + count > _length) count = _length - startIndex; @@ -369,7 +369,7 @@ public: int Find(T c) const { return Find(c, 0); } int Find(T c, int startIndex) const { - T *p = _chars + startIndex; + const T *p = _chars + startIndex; for (;;) { if (*p == c) @@ -399,7 +399,7 @@ public: { if (_length == 0) return -1; - T *p = _chars + _length - 1; + const T *p = _chars + _length - 1; for (;;) { if (*p == c) @@ -530,7 +530,7 @@ public: } return number; } - int Delete(int index, int count = 1 ) + int Delete(int index, int count = 1) { if (index + count > _length) count = _length - index; @@ -541,6 +541,7 @@ public: } return _length; } + void DeleteBack() { Delete(_length - 1); } }; template <class T> diff --git a/CPP/Common/MyUnknown.h b/CPP/Common/MyUnknown.h index 136145a7..e9e8666b 100755 --- a/CPP/Common/MyUnknown.h +++ b/CPP/Common/MyUnknown.h @@ -1,22 +1,11 @@ // MyUnknown.h -#ifndef __MYUNKNOWN_H -#define __MYUNKNOWN_H +#ifndef __MY_UNKNOWN_H +#define __MY_UNKNOWN_H #ifdef _WIN32 - -#ifdef _WIN32_WCE -#if (_WIN32_WCE > 300) -#include <basetyps.h> -#else -#define MIDL_INTERFACE(x) struct -#endif -#else #include <basetyps.h> -#endif - #include <unknwn.h> - #else #include "MyWindows.h" #endif diff --git a/CPP/Common/Random.cpp b/CPP/Common/Random.cpp index 9519987e..4bd3fcf9 100755 --- a/CPP/Common/Random.cpp +++ b/CPP/Common/Random.cpp @@ -2,16 +2,25 @@ #include "StdAfx.h" -#include <time.h> #include <stdlib.h> +#ifndef _WIN32 +#include <time.h> +#endif + #include "Random.h" -void CRandom::Init(unsigned int seed) - { srand(seed); } +void CRandom::Init(unsigned int seed) { srand(seed); } void CRandom::Init() - { Init((unsigned int)time(NULL)); } +{ + Init((unsigned int) + #ifdef _WIN32 + GetTickCount() + #else + time(NULL) + #endif + ); +} -int CRandom::Generate() const - { return rand(); } +int CRandom::Generate() const { return rand(); } diff --git a/CPP/Common/StringConvert.cpp b/CPP/Common/StringConvert.cpp index 9bd47deb..681895b7 100755 --- a/CPP/Common/StringConvert.cpp +++ b/CPP/Common/StringConvert.cpp @@ -17,10 +17,8 @@ UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) int numChars = MultiByteToWideChar(codePage, 0, srcString, srcString.Length(), resultString.GetBuffer(srcString.Length()), srcString.Length() + 1); - #ifndef _WIN32_WCE if (numChars == 0) throw 282228; - #endif resultString.ReleaseBuffer(numChars); } return resultString; @@ -38,10 +36,8 @@ AString UnicodeStringToMultiByte(const UString &s, UINT codePage, char defaultCh dest.GetBuffer(numRequiredBytes), numRequiredBytes + 1, &defaultChar, &defUsed); defaultCharWasUsed = (defUsed != FALSE); - #ifndef _WIN32_WCE if (numChars == 0) throw 282229; - #endif dest.ReleaseBuffer(numChars); } return dest; @@ -53,7 +49,7 @@ AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage) return UnicodeStringToMultiByte(srcString, codePage, '_', defaultCharWasUsed); } -#ifndef _WIN32_WCE +#ifndef UNDER_CE AString SystemStringToOemString(const CSysString &srcString) { AString result; @@ -99,4 +95,3 @@ AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage) } #endif - diff --git a/CPP/Common/StringConvert.h b/CPP/Common/StringConvert.h index 0c37eb07..cd737bec 100755 --- a/CPP/Common/StringConvert.h +++ b/CPP/Common/StringConvert.h @@ -1,7 +1,7 @@ // Common/StringConvert.h -#ifndef __COMMON_STRINGCONVERT_H -#define __COMMON_STRINGCONVERT_H +#ifndef __COMMON_STRING_CONVERT_H +#define __COMMON_STRING_CONVERT_H #include "MyWindows.h" #include "MyString.h" @@ -66,7 +66,7 @@ inline AString GetOemString(const UString &unicodeString) { return UnicodeStringToMultiByte(unicodeString, codePage); } #endif -#ifndef _WIN32_WCE +#ifndef UNDER_CE AString SystemStringToOemString(const CSysString &srcString); #endif |