Clean up code formatting with clang-format; add a custom clang-format style that tries to approximate the existing OST code style
This commit is contained in:
parent
184b260d9f
commit
ccf8a62fa4
|
@ -0,0 +1,115 @@
|
|||
---
|
||||
Language: Cpp
|
||||
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: true
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterClass: true
|
||||
AfterControlStatement: true
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Left
|
||||
RawStringFormats:
|
||||
- Delimiter: pb
|
||||
Language: TextProto
|
||||
BasedOnStyle: google
|
||||
ReflowComments: false
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Auto
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
...
|
||||
|
|
@ -1,2 +1 @@
|
|||
#define BUILD_NUM _T("0")
|
||||
|
||||
|
|
|
@ -200,7 +200,10 @@ int32 cArchive::GetStorageSize(const TSTRING& str)
|
|||
|
||||
int64 cArchive::Copy(cArchive* pFrom, int64 amt)
|
||||
{
|
||||
enum { BUF_SIZE = 2048 };
|
||||
enum
|
||||
{
|
||||
BUF_SIZE = 2048
|
||||
};
|
||||
int8 buf[BUF_SIZE];
|
||||
int64 amtLeft = amt;
|
||||
|
||||
|
@ -288,8 +291,7 @@ void cMemMappedArchive::SetNewMap(void* pMap, int64 offset, int64 length) const
|
|||
// mapped.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
cMemoryArchive::cMemoryArchive(int maxSize)
|
||||
: mMaxAllocatedLen(maxSize)
|
||||
cMemoryArchive::cMemoryArchive(int maxSize) : mMaxAllocatedLen(maxSize)
|
||||
{
|
||||
ASSERT(maxSize > 0);
|
||||
mpMemory = 0;
|
||||
|
@ -321,11 +323,13 @@ void cMemoryArchive::Seek(int64 offset, SeekFrom from) // throw(eArchive)
|
|||
offset = mLogicalSize + (int)offset;
|
||||
break;
|
||||
default:
|
||||
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||
ThrowAndAssert(eArchiveSeek(TSS_GetString(cCore, core::STR_MEMARCHIVE_FILENAME),
|
||||
TSS_GetString(cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||
}
|
||||
|
||||
if (offset > mLogicalSize)
|
||||
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||
ThrowAndAssert(eArchiveSeek(TSS_GetString(cCore, core::STR_MEMARCHIVE_FILENAME),
|
||||
TSS_GetString(cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||
|
||||
mReadHead = static_cast<int>(offset);
|
||||
}
|
||||
|
@ -464,17 +468,11 @@ public:
|
|||
//-----------------------------------------------------------------------------
|
||||
// cFixedMemArchive
|
||||
//-----------------------------------------------------------------------------
|
||||
cFixedMemArchive::cFixedMemArchive()
|
||||
: mpMemory (0),
|
||||
mSize (0),
|
||||
mReadHead (0)
|
||||
cFixedMemArchive::cFixedMemArchive() : mpMemory(0), mSize(0), mReadHead(0)
|
||||
{
|
||||
}
|
||||
|
||||
cFixedMemArchive::cFixedMemArchive( int8* pMem, int32 size )
|
||||
: mpMemory (0),
|
||||
mSize (0),
|
||||
mReadHead (0)
|
||||
cFixedMemArchive::cFixedMemArchive(int8* pMem, int32 size) : mpMemory(0), mSize(0), mReadHead(0)
|
||||
{
|
||||
Attach(pMem, size);
|
||||
}
|
||||
|
@ -503,11 +501,13 @@ void cFixedMemArchive::Seek(int64 offset, SeekFrom from) // throw(eArchive)
|
|||
offset = mSize + (int)offset;
|
||||
break;
|
||||
default:
|
||||
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||
ThrowAndAssert(eArchiveSeek(TSS_GetString(cCore, core::STR_MEMARCHIVE_FILENAME),
|
||||
TSS_GetString(cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||
}
|
||||
|
||||
if (offset > mSize)
|
||||
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||
ThrowAndAssert(eArchiveSeek(TSS_GetString(cCore, core::STR_MEMARCHIVE_FILENAME),
|
||||
TSS_GetString(cCore, core::STR_MEMARCHIVE_ERRSTR)));
|
||||
|
||||
mReadHead = static_cast<int32>(offset);
|
||||
}
|
||||
|
@ -566,11 +566,9 @@ int cFixedMemArchive::Write(const void* pDest, int count) // throw(eArchive)
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Ctor -- Initialize member variables to 0 or NULL equivalents.
|
||||
cFileArchive::cFileArchive() :
|
||||
mFileSize(0),
|
||||
mReadHead(0),
|
||||
isWritable(false)
|
||||
{}
|
||||
cFileArchive::cFileArchive() : mFileSize(0), mReadHead(0), isWritable(false)
|
||||
{
|
||||
}
|
||||
|
||||
cFileArchive::~cFileArchive()
|
||||
{
|
||||
|
@ -734,13 +732,13 @@ int cFileArchive::Read(void* pDest, int count)
|
|||
|
||||
if (pDest != NULL)
|
||||
{
|
||||
int nbRead =
|
||||
static_cast<int>( mCurrentFile.Read( pDest, count ) );
|
||||
int nbRead = static_cast<int>(mCurrentFile.Read(pDest, count));
|
||||
|
||||
// 'count' may not be equal to 'nbRead' if the file is open in
|
||||
// text mode.
|
||||
count = nbRead;
|
||||
if(count < 0) count = 0;
|
||||
if (count < 0)
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -765,7 +763,6 @@ int cFileArchive::Read(void* pDest, int count)
|
|||
{
|
||||
throw(eArchiveRead(mCurrentFilename, fileError.GetDescription()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
@ -793,7 +790,7 @@ int cFileArchive::Write(const void* pDest, int count) // throw(eArchive)
|
|||
// increase the size, if needed
|
||||
if (mReadHead > mFileSize)
|
||||
{
|
||||
#if 0 // IS_SUNPRO
|
||||
#if 0 // IS_SUNPRO \
|
||||
// These two lines seem to be all there is between code that crashes and code that works for sunpro
|
||||
cDebug d("cFileArchive::Write()");
|
||||
d.TraceDebug(_T("file(%s) adjusted mFileSize = %d mReadHead = %d\n"), mCurrentFilename.c_str(), (int)mFileSize, (int)mReadHead);
|
||||
|
@ -832,7 +829,6 @@ void cFileArchive::Truncate() // throw(eArchive)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// OpenReadWrite -- Opens the file to be read or written to
|
||||
//
|
||||
|
@ -842,7 +838,8 @@ void cLockedTemporaryFileArchive::OpenReadWrite( const TCHAR* filename, uint32 o
|
|||
{
|
||||
TSTRING strTempFile;
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
|
||||
ASSERT(!mCurrentFile.IsOpen()); // shouldn't be able to create a new file when we're already open
|
||||
if (mCurrentFile.IsOpen())
|
||||
|
@ -891,7 +888,8 @@ void cLockedTemporaryFileArchive::OpenReadWrite( const TCHAR* filename, uint32 o
|
|||
#endif
|
||||
|
||||
} //try
|
||||
catch (eFile& fileError) {
|
||||
catch (eFile& fileError)
|
||||
{
|
||||
TSTRING errStr = TSS_GetString(cCore, core::STR_BAD_TEMPDIRECTORY);
|
||||
eArchiveOpen e(strTempFile, errStr);
|
||||
throw e;
|
||||
|
@ -907,4 +905,3 @@ void cLockedTemporaryFileArchive::Close()
|
|||
// Note: this deletes the file as well
|
||||
cFileArchive::Close();
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,9 @@ TSS_EXCEPTION( eArchiveStringTooLong, eArchive );
|
|||
class cArchive
|
||||
{
|
||||
public:
|
||||
virtual ~cArchive() {}
|
||||
virtual ~cArchive()
|
||||
{
|
||||
}
|
||||
|
||||
// convenience methods
|
||||
//
|
||||
|
@ -137,7 +139,8 @@ protected:
|
|||
class cBidirArchive : public cArchive
|
||||
{
|
||||
public:
|
||||
enum SeekFrom {
|
||||
enum SeekFrom
|
||||
{
|
||||
BEGINNING = 0,
|
||||
CURRENT = 1,
|
||||
END = -1
|
||||
|
@ -155,7 +158,8 @@ public:
|
|||
class cMemMappedArchive : public cBidirArchive
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
MAP_TO_EOF = -1
|
||||
};
|
||||
|
||||
|
@ -202,7 +206,10 @@ public:
|
|||
|
||||
void Truncate(); // set the length to the current pos
|
||||
|
||||
int8* GetMemory() const { return mpMemory; }
|
||||
int8* GetMemory() const
|
||||
{
|
||||
return mpMemory;
|
||||
}
|
||||
|
||||
protected:
|
||||
int8* mpMemory;
|
||||
|
@ -238,6 +245,7 @@ public:
|
|||
virtual int64 CurrentPos() const;
|
||||
virtual int64 Length() const;
|
||||
virtual bool EndOfFile();
|
||||
|
||||
protected:
|
||||
//-----------------------------------
|
||||
// cArchive interface
|
||||
|
@ -320,9 +328,12 @@ public:
|
|||
private:
|
||||
// open for read only makes no sense if we're always creating the file,
|
||||
// so disallow read only file opens
|
||||
virtual void OpenRead( const TCHAR*, uint32 openFlags = 0 ) { ASSERT( false ); THROW_INTERNAL("archive.h"); }
|
||||
virtual void OpenRead(const TCHAR*, uint32 openFlags = 0)
|
||||
{
|
||||
ASSERT(false);
|
||||
THROW_INTERNAL("archive.h");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -149,5 +149,3 @@ bool cCharUtil::PopNextChar( TSTRING::const_iterator& cur,
|
|||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,8 +44,6 @@
|
|||
class cCharUtil
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
// finds the next whole character in string identified by ['cur'-'end')
|
||||
// identifies beginning of char in 'first', then end of character in 'last'
|
||||
// returns 'are there more characters in string?'
|
||||
|
@ -63,4 +61,3 @@ public:
|
|||
};
|
||||
|
||||
#endif //__CHARUTIL_H
|
||||
|
||||
|
|
|
@ -38,9 +38,7 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ctor, dotr
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
cCmdLineParser::cCmdLineParser() :
|
||||
mArgTable(HASH_VERY_SMALL),
|
||||
mLastArgInfo(-1, PARAM_NONE)
|
||||
cCmdLineParser::cCmdLineParser() : mArgTable(HASH_VERY_SMALL), mLastArgInfo(-1, PARAM_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -51,7 +49,8 @@ cCmdLineParser::~cCmdLineParser()
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// AddArg
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void cCmdLineParser::AddArg(int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed)
|
||||
void cCmdLineParser::AddArg(
|
||||
int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed)
|
||||
{
|
||||
if (arg.empty() && alias.empty())
|
||||
{
|
||||
|
@ -110,9 +109,7 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
|||
if (!mArgTable.Lookup(TSTRING(&argv[i][1]), argInfo))
|
||||
{
|
||||
// unknown switch!
|
||||
throw eCmdLineInvalidArg(
|
||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
||||
+ pCurArg );
|
||||
throw eCmdLineInvalidArg(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + pCurArg);
|
||||
}
|
||||
//
|
||||
// make sure this hasn't been specified yet...
|
||||
|
@ -124,9 +121,7 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
|||
if (it == mMultipleAllowed.end())
|
||||
{
|
||||
// It wasn't in our list of allowed params, so error.
|
||||
throw eCmdLineMultiArg(
|
||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
||||
+ argv[i] );
|
||||
throw eCmdLineMultiArg(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + argv[i]);
|
||||
}
|
||||
}
|
||||
//
|
||||
|
@ -149,9 +144,7 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
|||
if (argv[j][0] == _T('-'))
|
||||
{
|
||||
// >0 parameter passed !
|
||||
throw eCmdLineBadParam(
|
||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
||||
+ pCurArg );
|
||||
throw eCmdLineBadParam(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + pCurArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,9 +156,7 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
|||
if ((i >= argc) || (argv[i][0] == _T('-')))
|
||||
{
|
||||
// zero parameters passed to something that needed one param
|
||||
throw eCmdLineBadParam(
|
||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
||||
+ pCurArg );
|
||||
throw eCmdLineBadParam(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + pCurArg);
|
||||
}
|
||||
|
||||
curArg.mParams.push_back(TSTRING(argv[i]));
|
||||
|
@ -207,7 +198,6 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
|||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
|
||||
}
|
||||
if (!bResult)
|
||||
{
|
||||
|
@ -224,16 +214,12 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
|||
{
|
||||
if (!pCurArg)
|
||||
{
|
||||
throw eCmdLineBadSwitchPos(
|
||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
||||
+ argv[i] );
|
||||
throw eCmdLineBadSwitchPos(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// there was an extra parameter passed somewhere!
|
||||
throw eCmdLineBadArgParam(
|
||||
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
|
||||
+ pCurArg );
|
||||
throw eCmdLineBadArgParam(TSS_GetString(cCore, core::STR_ERR2_BAD_ARG_PARAMS) + pCurArg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,10 +227,7 @@ void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
|
|||
curArg.mParams.push_back(TSTRING(argv[i]));
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// it is possible not to process the final command line parameters in the "else" case above
|
||||
|
@ -283,14 +266,10 @@ void cCmdLineParser::TestMutEx()
|
|||
if (!iter2.Done())
|
||||
{
|
||||
// we have a mutual exclusion violation!
|
||||
throw eCmdLineMutEx(
|
||||
iter1.ActualParam()
|
||||
+ _T(", ")
|
||||
+ iter2.ActualParam() );
|
||||
throw eCmdLineMutEx(iter1.ActualParam() + _T(", ") + iter2.ActualParam());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -467,6 +446,4 @@ bool cCmdLineIter::SeekToArg(int argId) const
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,8 @@
|
|||
TSS_EXCEPTION(eCmdLine, eError)
|
||||
TSS_EXCEPTION(eCmdLineInvalidArg, eCmdLine) // an arg on the command line is not recognized
|
||||
TSS_EXCEPTION(eCmdLineBadArgParam, eCmdLine) // wrong number of parameters to an argument
|
||||
TSS_EXCEPTION( eCmdLineBadParam, eCmdLine ) // wrong number of paramters to the executable (not associated with any arguments)
|
||||
TSS_EXCEPTION(eCmdLineBadParam,
|
||||
eCmdLine) // wrong number of paramters to the executable (not associated with any arguments)
|
||||
TSS_EXCEPTION(eCmdLineBadSwitchPos, eCmdLine) // a '-' arg appeared after the final parameter list
|
||||
TSS_EXCEPTION(eCmdLineMutEx, eCmdLine) // a mutual exclusion error has occured
|
||||
TSS_EXCEPTION(eCmdLineDependency, eCmdLine) // a dependency error has occurred.
|
||||
|
@ -102,7 +103,8 @@ public:
|
|||
PARAM_INVALID // top of enum
|
||||
};
|
||||
|
||||
void AddArg(int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed = false);
|
||||
void
|
||||
AddArg(int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed = false);
|
||||
// this method should be called for each argument that can appear on the
|
||||
// command line.
|
||||
// argId -- a number that uniquely identifies the argument; no two arguments
|
||||
|
@ -158,7 +160,9 @@ private:
|
|||
int mId;
|
||||
ParamCount mNumParams;
|
||||
|
||||
cArgInfo(int i = -1, ParamCount p = PARAM_INVALID) : mId(i), mNumParams(p) {}
|
||||
cArgInfo(int i = -1, ParamCount p = PARAM_INVALID) : mId(i), mNumParams(p)
|
||||
{
|
||||
}
|
||||
};
|
||||
// for storing parsed argv information
|
||||
struct cArgData
|
||||
|
@ -167,11 +171,14 @@ private:
|
|||
std::vector<TSTRING> mParams;
|
||||
TSTRING mActualParam; // a string representation of what was actually on the command line
|
||||
|
||||
cArgData(int id = -1, const TSTRING& actualParam = TSTRING(_T(""))) : mId(id), mActualParam(actualParam) {}
|
||||
cArgData(int id = -1, const TSTRING& actualParam = TSTRING(_T(""))) : mId(id), mActualParam(actualParam)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
cHashTable<TSTRING, cArgInfo> mArgTable;
|
||||
cArgInfo mLastArgInfo; // info on the argument that comes at the end of the command line (with no associated '-x' or '--x')
|
||||
cArgInfo
|
||||
mLastArgInfo; // info on the argument that comes at the end of the command line (with no associated '-x' or '--x')
|
||||
std::list<cArgData> mArgData;
|
||||
std::list<std::pair<int, int> > mMutExList; // all of the mutual exclusions
|
||||
std::list<std::pair<std::pair<int, int>, bool> > mDependencyList; // all of the dependencies
|
||||
|
@ -218,8 +225,7 @@ private:
|
|||
//#############################################################################
|
||||
// inline implementation
|
||||
//#############################################################################
|
||||
inline cCmdLineIter::cCmdLineIter(const cCmdLineParser& parser) :
|
||||
mList(parser.mArgData)
|
||||
inline cCmdLineIter::cCmdLineIter(const cCmdLineParser& parser) : mList(parser.mArgData)
|
||||
{
|
||||
SeekBegin();
|
||||
}
|
||||
|
@ -264,4 +270,3 @@ inline const TSTRING& cCmdLineIter::ParamAt(int index) const
|
|||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -205,7 +205,8 @@ namespace /*Unique*/
|
|||
d.TraceDebug("ENOMEM: Insufficient storage space is available.\n");
|
||||
break;
|
||||
case EINVAL:
|
||||
d.TraceDebug( "EINVAL: The conversion specified by fromcode and tocode is not supported by the implementation.\n" );
|
||||
d.TraceDebug("EINVAL: The conversion specified by fromcode and tocode is not supported by the "
|
||||
"implementation.\n");
|
||||
break;
|
||||
default:
|
||||
d.TraceDebug("UNKNOWN: Unknown error.\n");
|
||||
|
@ -221,48 +222,34 @@ namespace /*Unique*/
|
|||
// [EINVAL] Input conversion stopped due to an incomplete character
|
||||
// [EBADF] The cd argument is not a valid open conversion descriptor.
|
||||
// errno
|
||||
d.TraceDebug(
|
||||
_T( "iconv failed with: %s\n" ),
|
||||
iFSServices::GetInstance()->GetErrString().c_str() );
|
||||
d.TraceDebug(_T( "iconv failed with: %s\n" ), iFSServices::GetInstance()->GetErrString().c_str());
|
||||
|
||||
/// RAD: Always throw on error (Let user Catch if they want to go on)
|
||||
switch (errno)
|
||||
{
|
||||
case EILSEQ:
|
||||
case EINVAL:
|
||||
throw
|
||||
eConverterFatal (
|
||||
TSS_GetString( cCore, core::STR_ERR_BADCHAR ) );
|
||||
throw eConverterFatal(TSS_GetString(cCore, core::STR_ERR_BADCHAR));
|
||||
break;
|
||||
|
||||
case E2BIG:
|
||||
throw
|
||||
eConverterFatal(
|
||||
TSS_GetString(cCore, core::STR_ERR_OVERFLOW ) );
|
||||
throw eConverterFatal(TSS_GetString(cCore, core::STR_ERR_OVERFLOW));
|
||||
break;
|
||||
|
||||
case EBADF:
|
||||
throw
|
||||
eConverterUnknownCodepage(
|
||||
TSS_GetString( cCore, core::STR_UNKNOWN ) );
|
||||
throw eConverterUnknownCodepage(TSS_GetString(cCore, core::STR_UNKNOWN));
|
||||
break;
|
||||
default:
|
||||
throw
|
||||
eConverterFatal(
|
||||
TSS_GetString( cCore, core::STR_UNKNOWN ) );
|
||||
throw eConverterFatal(TSS_GetString(cCore, core::STR_UNKNOWN));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
template< class BufferT, class SourceT >
|
||||
class ByteConvert
|
||||
template<class BufferT, class SourceT> class ByteConvert
|
||||
{
|
||||
public:
|
||||
|
||||
bool
|
||||
Convert( BufferT** ppBuf, size_t* pnBufferLeft,
|
||||
const SourceT** ppSrc, size_t* pnSourceLeft )
|
||||
bool Convert(BufferT** ppBuf, size_t* pnBufferLeft, const SourceT** ppSrc, size_t* pnSourceLeft)
|
||||
{
|
||||
cDebug d("ByteConvert::Convert< BufferT, SourceT >()");
|
||||
|
||||
|
@ -285,21 +272,21 @@ namespace /*Unique*/
|
|||
class UTF8_Util
|
||||
{
|
||||
public:
|
||||
enum { INVALID_VALUE = 0xFF };
|
||||
enum
|
||||
{
|
||||
INVALID_VALUE = 0xFF
|
||||
};
|
||||
};
|
||||
|
||||
// convert to INVALID_VALUE and remember the byte value
|
||||
template< class BufferT, class SourceT >
|
||||
class ToUTF8Convert
|
||||
template<class BufferT, class SourceT> class ToUTF8Convert
|
||||
{
|
||||
public:
|
||||
ToUTF8Convert(std::list<byte>& lb) : m_lb(lb)
|
||||
{
|
||||
}
|
||||
|
||||
ToUTF8Convert( std::list<byte>& lb )
|
||||
: m_lb( lb ) {}
|
||||
|
||||
bool
|
||||
Convert( mbchar_t** ppBuf, size_t* pnBufferLeft,
|
||||
const dbchar_t** ppSrc, size_t* pnSourceLeft )
|
||||
bool Convert(mbchar_t** ppBuf, size_t* pnBufferLeft, const dbchar_t** ppSrc, size_t* pnSourceLeft)
|
||||
{
|
||||
cDebug d("ToUTF8Convert::Convert< mbchar_t, dbchar_t >()");
|
||||
|
||||
|
@ -320,9 +307,7 @@ namespace /*Unique*/
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Convert( mbchar_t** ppBuf, size_t* pnBufferLeft,
|
||||
const mbchar_t** ppSrc, size_t* pnSourceLeft )
|
||||
bool Convert(mbchar_t** ppBuf, size_t* pnBufferLeft, const mbchar_t** ppSrc, size_t* pnSourceLeft)
|
||||
{
|
||||
cDebug d("ToUTF8Convert::Convert< char, char >()");
|
||||
|
||||
|
@ -344,23 +329,19 @@ namespace /*Unique*/
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
// TODO:Get rid of this guy and just use a vector<BufferT*,BufferT> and
|
||||
// insert them when finished with second step
|
||||
std::list<byte>& m_lb;
|
||||
};
|
||||
|
||||
template< class BufferT, class SourceT >
|
||||
class FromUTF8Convert
|
||||
template<class BufferT, class SourceT> class FromUTF8Convert
|
||||
{
|
||||
public:
|
||||
FromUTF8Convert(std::list<byte>& lb) : m_lb(lb)
|
||||
{
|
||||
}
|
||||
|
||||
FromUTF8Convert( std::list<byte>& lb )
|
||||
: m_lb( lb ) {}
|
||||
|
||||
bool
|
||||
Convert( dbchar_t** ppBuf, size_t* pnBufferLeft,
|
||||
const mbchar_t** ppSrc, size_t* pnSourceLeft )
|
||||
bool Convert(dbchar_t** ppBuf, size_t* pnBufferLeft, const mbchar_t** ppSrc, size_t* pnSourceLeft)
|
||||
{
|
||||
cDebug d("FromUTF8Convert::Convert< dbchar_t, mbchar_t >()");
|
||||
|
||||
|
@ -395,9 +376,7 @@ namespace /*Unique*/
|
|||
// Converts a UTF-8 value to corresponding UCS2 char (in the private
|
||||
// use range) whose value is 0xE000 < x < 0xE0FF in UCS2.
|
||||
// Must be of the form 11101110 100000xx 10xxxxxx
|
||||
bool
|
||||
Convert( mbchar_t** ppBuf, size_t* pnBufferLeft,
|
||||
const mbchar_t** ppSrc, size_t* pnSourceLeft )
|
||||
bool Convert(mbchar_t** ppBuf, size_t* pnBufferLeft, const mbchar_t** ppSrc, size_t* pnSourceLeft)
|
||||
{
|
||||
cDebug d("FromUTF8Convert::Convert< mbchar_t, mbchar_t >()");
|
||||
/*
|
||||
|
@ -486,16 +465,12 @@ namespace /*Unique*/
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
// TODO:Get rid of this guy and just use a vector<BufferT*,BufferT> and
|
||||
// insert them when finished with second step
|
||||
std::list<byte>& m_lb;
|
||||
};
|
||||
|
||||
bool
|
||||
tss_ReverseConvert( iconv_t revConv,
|
||||
const char* pConvertedFrom, size_t nFrom,
|
||||
char* pConvertedTo, size_t nTo )
|
||||
bool tss_ReverseConvert(iconv_t revConv, const char* pConvertedFrom, size_t nFrom, char* pConvertedTo, size_t nTo)
|
||||
{
|
||||
cDebug d("tss_ReverseConvert< B, S, C >()");
|
||||
d.TraceDebug("Converted from: %s\n", util_output_bytes((void*)pConvertedFrom, nFrom).c_str());
|
||||
|
@ -538,26 +513,27 @@ namespace /*Unique*/
|
|||
return true;
|
||||
}
|
||||
|
||||
template< class CharT >
|
||||
bool tss_IsFlaggedCharacter( CharT ch )
|
||||
template<class CharT> bool tss_IsFlaggedCharacter(CharT ch)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<>
|
||||
bool tss_IsFlaggedCharacter< dbchar_t >( dbchar_t wch )
|
||||
template<> bool tss_IsFlaggedCharacter<dbchar_t>(dbchar_t wch)
|
||||
{
|
||||
return cConvertUtil::ValueInReservedRange(wch);
|
||||
}
|
||||
|
||||
template<class BufferT, class SourceT>
|
||||
int
|
||||
tss_ConvertOneCharacter( iconv_t convForward,
|
||||
int tss_ConvertOneCharacter(iconv_t convForward,
|
||||
iconv_t convReverse,
|
||||
const char** ppSource, size_t* pnSourceLeft,
|
||||
char** ppBuffer, size_t* pnBufferLeft
|
||||
const char** ppSource,
|
||||
size_t* pnSourceLeft,
|
||||
char** ppBuffer,
|
||||
size_t* pnBufferLeft
|
||||
# if (!SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST)
|
||||
, BufferT /*dummy*/, SourceT /*dummy*/
|
||||
,
|
||||
BufferT /*dummy*/,
|
||||
SourceT /*dummy*/
|
||||
# endif
|
||||
)
|
||||
{
|
||||
|
@ -576,9 +552,7 @@ namespace /*Unique*/
|
|||
|
||||
//-- Try to find the number of items needed to get a complete character
|
||||
size_t nSrcTry;
|
||||
for( nSrcTry = sizeof( SourceT );
|
||||
nSrcTry <= *pnBufferLeft && nSrcTry <= MB_LEN_MAX;
|
||||
nSrcTry += sizeof( SourceT ) )
|
||||
for (nSrcTry = sizeof(SourceT); nSrcTry <= *pnBufferLeft && nSrcTry <= MB_LEN_MAX; nSrcTry += sizeof(SourceT))
|
||||
{
|
||||
size_t nSrcLeft = nSrcTry;
|
||||
size_t nBufLeft = *pnBufferLeft; // Try to find a character in 'n' items
|
||||
|
@ -608,12 +582,7 @@ namespace /*Unique*/
|
|||
}
|
||||
else
|
||||
{
|
||||
if( tss_ReverseConvert(
|
||||
convReverse,
|
||||
*ppSource,
|
||||
pSrc - *ppSource,
|
||||
*ppBuffer,
|
||||
pBuf - *ppBuffer ) )
|
||||
if (tss_ReverseConvert(convReverse, *ppSource, pSrc - *ppSource, *ppBuffer, pBuf - *ppBuffer))
|
||||
{
|
||||
// Modify source items to return
|
||||
|
||||
|
@ -648,11 +617,12 @@ namespace /*Unique*/
|
|||
// NOTE: pBuffer should really have (nBufferItems+1) buffer items, because some
|
||||
// platforms use the last character to NULL terminate.
|
||||
template<class BufferT, class SourceT, class ConvT>
|
||||
int
|
||||
tss_Converter( iconv_t convForward,
|
||||
int tss_Converter(iconv_t convForward,
|
||||
iconv_t convReverse,
|
||||
BufferT* pBuffer, size_t nBufferItems,
|
||||
const SourceT* pSource, size_t nSourceItems,
|
||||
BufferT* pBuffer,
|
||||
size_t nBufferItems,
|
||||
const SourceT* pSource,
|
||||
size_t nSourceItems,
|
||||
ConvT& ConvertByte)
|
||||
{
|
||||
cDebug d("tss_Converter< BufferT, SourceT >()");
|
||||
|
@ -685,7 +655,8 @@ namespace /*Unique*/
|
|||
size_t nbIconvSrc = (size_t)nSourceLeft;
|
||||
size_t nbIconvDest = (size_t)nBufferLeft;
|
||||
|
||||
size_t nConv = iconv( convForward, (ICONV_SOURCE_TYPE**)&pIconvSrc, &nbIconvSrc, (char**)&pIconvDest, &nbIconvDest );
|
||||
size_t nConv =
|
||||
iconv(convForward, (ICONV_SOURCE_TYPE**)&pIconvSrc, &nbIconvSrc, (char**)&pIconvDest, &nbIconvDest);
|
||||
|
||||
if (nConv == -1)
|
||||
{
|
||||
|
@ -704,7 +675,9 @@ namespace /*Unique*/
|
|||
(char**)&pBuf,
|
||||
&nBufferLeft
|
||||
# if (!SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST)
|
||||
, BufferT(), SourceT()
|
||||
,
|
||||
BufferT(),
|
||||
SourceT()
|
||||
# endif
|
||||
);
|
||||
}
|
||||
|
@ -738,11 +711,12 @@ namespace /*Unique*/
|
|||
}
|
||||
}
|
||||
|
||||
d.TraceDebug( "buffer out: %s\n", util_output_bytes( (void*)pBuffer, nBufferItems * sizeof(BufferT) - nBufferLeft ).c_str() );
|
||||
d.TraceDebug("buffer out: %s\n",
|
||||
util_output_bytes((void*)pBuffer, nBufferItems * sizeof(BufferT) - nBufferLeft).c_str());
|
||||
return nBufferItems - (nBufferLeft / sizeof(BufferT));
|
||||
}
|
||||
|
||||
}//Unique
|
||||
} // namespace
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// cIconvConverter
|
||||
|
@ -795,10 +769,7 @@ void cIconvConverter::Init()
|
|||
icFromDb = cIconvUtil::OpenHandle(cIconvUtil::GetCodePageID(), cIconvUtil::GetIconvDbIdentifier());
|
||||
}
|
||||
|
||||
int
|
||||
cIconvConverter::Convert(
|
||||
ntmbs_t pbz, size_t nBytes,
|
||||
const_ntdbs_t pwz, size_t nChars )
|
||||
int cIconvConverter::Convert(ntmbs_t pbz, size_t nBytes, const_ntdbs_t pwz, size_t nChars)
|
||||
{
|
||||
cDebug d("cIconvConverter::Convert( ntdbs_t -> ntmbs_t )");
|
||||
|
||||
|
@ -823,10 +794,7 @@ cIconvConverter::Convert(
|
|||
return nConverted;
|
||||
}
|
||||
|
||||
int
|
||||
cIconvConverter::Convert(
|
||||
ntdbs_t pwz, size_t nch,
|
||||
const_ntmbs_t pbz, size_t nBytes )
|
||||
int cIconvConverter::Convert(ntdbs_t pwz, size_t nch, const_ntmbs_t pbz, size_t nBytes)
|
||||
{
|
||||
cDebug d("cIconvConverter::Convert( ntmbs to ntdbs )");
|
||||
|
||||
|
@ -851,13 +819,6 @@ cIconvConverter::Convert(
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
@ -996,10 +957,7 @@ void cDoubleIconvConverter::Init()
|
|||
icUTF8ToMb = cIconvUtil::OpenHandle(cIconvUtil::GetCodePageID(), cIconvUtil::GetMiddleIdentifier());
|
||||
}
|
||||
|
||||
int
|
||||
cDoubleIconvConverter::Convert(
|
||||
ntmbs_t pbz, size_t nBytes,
|
||||
const_ntdbs_t pwz, size_t nChars )
|
||||
int cDoubleIconvConverter::Convert(ntmbs_t pbz, size_t nBytes, const_ntdbs_t pwz, size_t nChars)
|
||||
{
|
||||
cDebug d("cDoubleIconvConverter::Convert( ntdbs_t -> ntmbs_t )");
|
||||
|
||||
|
@ -1057,10 +1015,7 @@ cDoubleIconvConverter::Convert(
|
|||
return nConverted;
|
||||
}
|
||||
|
||||
int
|
||||
cDoubleIconvConverter::Convert(
|
||||
ntdbs_t pwz, size_t nch,
|
||||
const_ntmbs_t pbz, size_t nBytes )
|
||||
int cDoubleIconvConverter::Convert(ntdbs_t pwz, size_t nch, const_ntmbs_t pbz, size_t nBytes)
|
||||
{
|
||||
cDebug d("cDoubleIconvConverter::Convert( ntmbs to ntdbs )");
|
||||
|
||||
|
@ -1172,9 +1127,7 @@ void cIconvUtil::ResetConverter( iconv_t ic )
|
|||
char* p = 0;
|
||||
size_t s = 0;
|
||||
|
||||
size_t i = iconv( ic,
|
||||
(ICONV_SOURCE_TYPE**) &p,
|
||||
&s, &p, &s );
|
||||
size_t i = iconv(ic, (ICONV_SOURCE_TYPE**)&p, &s, &p, &s);
|
||||
if (i == (size_t)-1)
|
||||
{
|
||||
ASSERT(false);
|
||||
|
@ -1215,7 +1168,6 @@ bool cIconvUtil::TestConverter( const char* pTo, const char* pFrom )
|
|||
#endif //TSS_USE_ICONV_CCONV16
|
||||
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// cWcharIs32BitUcs2Converterer
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -1224,8 +1176,7 @@ namespace /*Unique*/
|
|||
{
|
||||
//-- Ensures 1-to-1 mb to wide character mapping by doing a reverse conversion
|
||||
// and comparing the results
|
||||
int
|
||||
tss_mbtowc( wchar_t* pwch, const mbchar_t* pch, size_t nBytes )
|
||||
int tss_mbtowc(wchar_t* pwch, const mbchar_t* pch, size_t nBytes)
|
||||
{
|
||||
// convert forward
|
||||
int nNarrow = ::mbtowc(pwch, pch, nBytes);
|
||||
|
@ -1239,8 +1190,7 @@ namespace /*Unique*/
|
|||
return -1;
|
||||
|
||||
// compare...
|
||||
if( ( nNarrow > (int)nBytes ) ||
|
||||
( 0 != memcmp( ach, pch, nNarrow ) ) )
|
||||
if ((nNarrow > (int)nBytes) || (0 != memcmp(ach, pch, nNarrow)))
|
||||
return -1;
|
||||
|
||||
// success!
|
||||
|
@ -1249,8 +1199,7 @@ namespace /*Unique*/
|
|||
|
||||
//-- Ensures 1-to-1 mb to wide character mapping by doing a reverse conversion
|
||||
// and comparing the results
|
||||
int
|
||||
tss_wctomb( mbchar_t* pch, wchar_t wch )
|
||||
int tss_wctomb(mbchar_t* pch, wchar_t wch)
|
||||
{
|
||||
// convert forward
|
||||
int nWide = ::wctomb(pch, wch);
|
||||
|
@ -1271,8 +1220,7 @@ namespace /*Unique*/
|
|||
return nWide;
|
||||
}
|
||||
|
||||
int
|
||||
tss_wcstombs( ntmbs_t pbz, const_ntwcs_t pwz, size_t nCount )
|
||||
int tss_wcstombs(ntmbs_t pbz, const_ntwcs_t pwz, size_t nCount)
|
||||
{
|
||||
cDebug d("tss_wcstombs");
|
||||
|
||||
|
@ -1292,8 +1240,7 @@ namespace /*Unique*/
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
tss_mbstowcs( ntwcs_t pwz, const_ntmbs_t pbz, size_t nBytes )
|
||||
int tss_mbstowcs(ntwcs_t pwz, const_ntmbs_t pbz, size_t nBytes)
|
||||
{
|
||||
cDebug d("tss_mbstowcs");
|
||||
|
||||
|
@ -1305,9 +1252,7 @@ namespace /*Unique*/
|
|||
N = tss_mbtowc(pwz, pbz, end - pbz);
|
||||
if (N == (size_t)-1)
|
||||
{
|
||||
d.TraceDebug(
|
||||
"manually converting %X...\n",
|
||||
cConvertUtil::ConvertNonChar( *pbz ) );
|
||||
d.TraceDebug("manually converting %X...\n", cConvertUtil::ConvertNonChar(*pbz));
|
||||
|
||||
*pwz = (wchar_t)cConvertUtil::ConvertNonChar(*pbz);
|
||||
N = 1;
|
||||
|
@ -1316,14 +1261,11 @@ namespace /*Unique*/
|
|||
|
||||
return (int)nConv;
|
||||
}
|
||||
}//Unique
|
||||
} // namespace
|
||||
|
||||
#if WCHAR_IS_32_BITS
|
||||
|
||||
int
|
||||
cWcharIs32BitUcs2Converterer::Convert(
|
||||
ntmbs_t pbz, size_t nBytes,
|
||||
const_ntdbs_t pwz, size_t nCount )
|
||||
int cWcharIs32BitUcs2Converterer::Convert(ntmbs_t pbz, size_t nBytes, const_ntdbs_t pwz, size_t nCount)
|
||||
{
|
||||
if (pbz == 0 || (pwz == 0 && nCount))
|
||||
throw eConverterFatal(TSS_GetString(cCore, core::STR_ERR_ISNULL));
|
||||
|
@ -1354,10 +1296,7 @@ cWcharIs32BitUcs2Converterer::Convert(
|
|||
return nConv;
|
||||
}
|
||||
|
||||
int
|
||||
cWcharIs32BitUcs2Converterer::Convert(
|
||||
ntdbs_t pwz, size_t nCount,
|
||||
const_ntmbs_t pbz, size_t nBytes )
|
||||
int cWcharIs32BitUcs2Converterer::Convert(ntdbs_t pwz, size_t nCount, const_ntmbs_t pbz, size_t nBytes)
|
||||
{
|
||||
cDebug d("cWcharIs32BitUcs2Converterer::Convert( ntmbs to ntdbs )");
|
||||
|
||||
|
@ -1402,10 +1341,7 @@ cWcharIs32BitUcs2Converterer::Convert(
|
|||
|
||||
#if WCHAR_IS_16_BITS
|
||||
|
||||
int
|
||||
cWcharIs16BitUcs2Converterer::Convert(
|
||||
ntmbs_t pbz, size_t nbMB,
|
||||
const_ntdbs_t pwz, size_t nch )
|
||||
int cWcharIs16BitUcs2Converterer::Convert(ntmbs_t pbz, size_t nbMB, const_ntdbs_t pwz, size_t nch)
|
||||
{
|
||||
// Validate Input
|
||||
if (pbz == 0 || (pwz == 0 && nch))
|
||||
|
@ -1427,10 +1363,7 @@ cWcharIs16BitUcs2Converterer::Convert(
|
|||
return nConverted;
|
||||
}
|
||||
|
||||
int
|
||||
cWcharIs16BitUcs2Converterer::Convert(
|
||||
ntdbs_t pwz, size_t nch,
|
||||
const_ntmbs_t pbz, size_t nBytes )
|
||||
int cWcharIs16BitUcs2Converterer::Convert(ntdbs_t pwz, size_t nch, const_ntmbs_t pbz, size_t nBytes)
|
||||
{
|
||||
// Validate Input
|
||||
if (pbz == 0 || (pwz == 0 && nch))
|
||||
|
@ -1450,11 +1383,7 @@ cWcharIs16BitUcs2Converterer::Convert(
|
|||
#endif // WCHAR_IS_16_BITS
|
||||
|
||||
|
||||
|
||||
int
|
||||
cGoodEnoughConverterer::Convert(
|
||||
ntmbs_t pbz, size_t nBytes,
|
||||
const_ntdbs_t pwz, size_t nCount )
|
||||
int cGoodEnoughConverterer::Convert(ntmbs_t pbz, size_t nBytes, const_ntdbs_t pwz, size_t nCount)
|
||||
{
|
||||
if (pbz == 0 || (pwz == 0 && nCount))
|
||||
throw eConverterFatal(TSS_GetString(cCore, core::STR_ERR_ISNULL));
|
||||
|
@ -1485,10 +1414,7 @@ cGoodEnoughConverterer::Convert(
|
|||
return ((size_t)at - (size_t)pbz);
|
||||
}
|
||||
|
||||
int
|
||||
cGoodEnoughConverterer::Convert(
|
||||
ntdbs_t pwz, size_t nCount,
|
||||
const_ntmbs_t pbz, size_t nBytes )
|
||||
int cGoodEnoughConverterer::Convert(ntdbs_t pwz, size_t nCount, const_ntmbs_t pbz, size_t nBytes)
|
||||
{
|
||||
// Validate Input
|
||||
if (pwz == 0 || (pbz == 0 && nBytes))
|
||||
|
@ -1531,9 +1457,7 @@ dbchar_t cConvertUtil::ConvertNonChar( mbchar_t ch )
|
|||
|
||||
dbchar_t wch = (dbchar_t)(tss::util::char_to_size(ch) + TSS_UCS2_RESERVED_START);
|
||||
|
||||
d.TraceDebug( "Converted 0x%08X to 0x%08X\n",
|
||||
tss::util::char_to_size( ch ),
|
||||
tss::util::char_to_size( wch ) );
|
||||
d.TraceDebug("Converted 0x%08X to 0x%08X\n", tss::util::char_to_size(ch), tss::util::char_to_size(wch));
|
||||
|
||||
return (wch);
|
||||
}
|
||||
|
@ -1550,9 +1474,7 @@ mbchar_t cConvertUtil::ConvertNonChar( dbchar_t wch )
|
|||
|
||||
mbchar_t ch = (mbchar_t)(wch - TSS_UCS2_RESERVED_START);
|
||||
|
||||
d.TraceDebug( "Converted 0x%08X to 0x%08X\n",
|
||||
tss::util::char_to_size( wch ),
|
||||
tss::util::char_to_size( ch ) );
|
||||
d.TraceDebug("Converted 0x%08X to 0x%08X\n", tss::util::char_to_size(wch), tss::util::char_to_size(ch));
|
||||
|
||||
return (ch);
|
||||
}
|
||||
|
@ -1560,13 +1482,11 @@ mbchar_t cConvertUtil::ConvertNonChar( dbchar_t wch )
|
|||
bool cConvertUtil::ValueInReservedRange(dbchar_t wch)
|
||||
{
|
||||
size_t s = tss::util::char_to_size(wch);
|
||||
return( ( s >= TSS_UCS2_RESERVED_START ) &&
|
||||
( s <= TSS_UCS2_RESERVED_END ) );
|
||||
return ((s >= TSS_UCS2_RESERVED_START) && (s <= TSS_UCS2_RESERVED_END));
|
||||
}
|
||||
|
||||
bool cConvertUtil::ValueInReservedRange(mbchar_t ch)
|
||||
{
|
||||
size_t s = tss::util::char_to_size(ch);
|
||||
return( ( s >= TSS_HIGH_ASCII_START ) &&
|
||||
( s <= TSS_HIGH_ASCII_END ) );
|
||||
return ((s >= TSS_HIGH_ASCII_START) && (s <= TSS_HIGH_ASCII_END));
|
||||
}
|
||||
|
|
|
@ -91,44 +91,37 @@ TSS_EXCEPTION( eConverterUnknownCodepage, eConverter );
|
|||
class iCodeConverter
|
||||
{
|
||||
public:
|
||||
|
||||
static iCodeConverter* GetInstance(); // Singleton
|
||||
static void Finit();
|
||||
|
||||
|
||||
|
||||
/// Subclass Responsibilities
|
||||
virtual
|
||||
int
|
||||
Convert(
|
||||
ntmbs_t, // NTMBS buffer
|
||||
virtual int Convert(ntmbs_t, // NTMBS buffer
|
||||
size_t, // Capacity in mbchar_t's (bytes)
|
||||
const_ntdbs_t, // null terminated two-byte wide character (UCS2 rep)
|
||||
size_t nCount) = 0; // Amount to convert in dbchar_t's
|
||||
// returns number of buffer items converted, -1 on error
|
||||
|
||||
|
||||
virtual
|
||||
int
|
||||
Convert(
|
||||
ntdbs_t, // NTDBS (Null-terminated two byte sequence) buf
|
||||
virtual int Convert(ntdbs_t, // NTDBS (Null-terminated two byte sequence) buf
|
||||
size_t, // Capacity in dbchar_t's
|
||||
const_ntmbs_t, // Null-terminated multi-byte sequence
|
||||
size_t) = 0; // Capacity in mbchar_t's (bytes)
|
||||
// returns number of buffer items converted, -1 on error
|
||||
|
||||
protected:
|
||||
|
||||
iCodeConverter() {}
|
||||
virtual ~iCodeConverter() {}
|
||||
iCodeConverter()
|
||||
{
|
||||
}
|
||||
virtual ~iCodeConverter()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static iCodeConverter* CreateConverter();
|
||||
static iCodeConverter* CreateGoodEnoughConverter();
|
||||
|
||||
static iCodeConverter* m_pInst;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -149,7 +142,6 @@ class iCodeConverter
|
|||
class cIconvUtil
|
||||
{
|
||||
public:
|
||||
|
||||
static const char* GetCodePageID(); // gets code page id for current locale, throws if error
|
||||
static bool GetCodePageID(const char** ppCP);
|
||||
static const char* GetIconvDbIdentifier();
|
||||
|
@ -164,7 +156,6 @@ class cIconvUtil
|
|||
class cIconvConverter : public iCodeConverter
|
||||
{
|
||||
public:
|
||||
|
||||
static bool Test(); // is there a conversion for the current codepage?
|
||||
|
||||
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||
|
@ -183,7 +174,6 @@ class cIconvConverter : public iCodeConverter
|
|||
class cDoubleIconvConverter : public iCodeConverter
|
||||
{
|
||||
public:
|
||||
|
||||
static bool Test(); // is there a conversion for the current codepage?
|
||||
|
||||
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||
|
@ -193,7 +183,6 @@ class cDoubleIconvConverter : public iCodeConverter
|
|||
virtual ~cDoubleIconvConverter();
|
||||
|
||||
private:
|
||||
|
||||
void Init();
|
||||
|
||||
iconv_t icMbToUTF8;
|
||||
|
@ -223,7 +212,9 @@ public:
|
|||
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||
virtual int Convert(ntdbs_t, size_t, const_ntmbs_t, size_t);
|
||||
|
||||
virtual ~cWcharIs32BitUcs2Converterer() {}
|
||||
virtual ~cWcharIs32BitUcs2Converterer()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // WCHAR_IS_32_BITS
|
||||
|
@ -243,7 +234,9 @@ public:
|
|||
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||
virtual int Convert(ntdbs_t, size_t, const_ntmbs_t, size_t);
|
||||
|
||||
virtual ~cWcharIs16BitUcs2Converterer() {}
|
||||
virtual ~cWcharIs16BitUcs2Converterer()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // WCHAR_IS_16_BITS
|
||||
|
@ -256,7 +249,9 @@ public:
|
|||
virtual int Convert(ntmbs_t, size_t, const_ntdbs_t, size_t);
|
||||
virtual int Convert(ntdbs_t, size_t, const_ntmbs_t, size_t);
|
||||
|
||||
virtual ~cGoodEnoughConverterer() {}
|
||||
virtual ~cGoodEnoughConverterer()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -269,6 +264,7 @@ class cConvertUtil
|
|||
TSS_HIGH_ASCII_START = 0x0080u,
|
||||
TSS_HIGH_ASCII_END = 0x00FFu
|
||||
};
|
||||
|
||||
public:
|
||||
static dbchar_t ConvertNonChar(mbchar_t ch);
|
||||
static mbchar_t ConvertNonChar(dbchar_t ch);
|
||||
|
@ -279,4 +275,3 @@ public:
|
|||
|
||||
|
||||
#endif //__CODECONVERT_H
|
||||
|
||||
|
|
|
@ -64,4 +64,3 @@ cCore::~cCore()
|
|||
{
|
||||
iCodeConverter::Finit();
|
||||
}
|
||||
|
||||
|
|
|
@ -52,11 +52,9 @@ TSS_BeginPackage( cCore )
|
|||
TSS_DECLARE_STRINGTABLE;
|
||||
|
||||
public:
|
||||
|
||||
cCore();
|
||||
~cCore();
|
||||
|
||||
TSS_EndPackage(cCore)
|
||||
|
||||
#endif //__CORE_H
|
||||
|
||||
|
|
|
@ -110,7 +110,8 @@ TSS_REGISTER_ERROR( eFSServicesGeneric(),_T("File system error.") )
|
|||
|
||||
/// Serializer
|
||||
|
||||
TSS_REGISTER_ERROR( eSerializerUnknownType(), _T("Unknown type encountered in file.\nFile format may not be valid for this platform.") )
|
||||
TSS_REGISTER_ERROR(eSerializerUnknownType(),
|
||||
_T("Unknown type encountered in file.\nFile format may not be valid for this platform."))
|
||||
TSS_REGISTER_ERROR(eSerializerInputStreamFmt(), _T("Invalid input stream format."))
|
||||
TSS_REGISTER_ERROR(eSerializerOutputStreamFmt(), _T("Invalid output stream format."))
|
||||
TSS_REGISTER_ERROR(eSerializerInputStremTypeArray(), _T("A bad index was encountered in file."))
|
||||
|
@ -163,4 +164,3 @@ TSS_REGISTER_ERROR( eUnknownEscapeEncoding(), _T("Unknown encoding in display
|
|||
|
||||
|
||||
TSS_END_ERROR_REGISTRATION()
|
||||
|
||||
|
|
|
@ -45,4 +45,3 @@ TSS_DECLARE_ERROR_REGISTRATION( core )
|
|||
|
||||
|
||||
#endif //__COREERRORS_H
|
||||
|
||||
|
|
|
@ -44,14 +44,11 @@ TSS_BeginStringtable( cCore )
|
|||
TSS_StringEntry(core::STR_ERR2_ARCH_CRYPTO_ERR, _T("File could not be decrypted.")),
|
||||
TSS_StringEntry(core::STR_ERR2_BAD_ARG_PARAMS, _T("Argument: ")),
|
||||
TSS_StringEntry(core::STR_ERROR_ERROR, _T("### Error")),
|
||||
TSS_StringEntry( core::STR_ERROR_WARNING, _T("### Warning") ),
|
||||
TSS_StringEntry( core::STR_ERROR_COLON, _T(":") ),
|
||||
TSS_StringEntry( core::STR_ERROR_HEADER, _T("### ") ),
|
||||
TSS_StringEntry( core::STR_ERROR_EXITING, _T("Exiting...") ),
|
||||
TSS_StringEntry(core::STR_ERROR_WARNING, _T("### Warning")), TSS_StringEntry(core::STR_ERROR_COLON, _T(":")),
|
||||
TSS_StringEntry(core::STR_ERROR_HEADER, _T("### ")), TSS_StringEntry(core::STR_ERROR_EXITING, _T("Exiting...")),
|
||||
TSS_StringEntry(core::STR_ERROR_CONTINUING, _T("Continuing...")),
|
||||
TSS_StringEntry(core::STR_ERR2_FILENAME, _T("Filename: ")),
|
||||
TSS_StringEntry( core::STR_ERROR_FILENAME, _T("Filename: ") ),
|
||||
TSS_StringEntry( core::STR_UNKNOWN, _T("Unknown") ),
|
||||
TSS_StringEntry(core::STR_ERROR_FILENAME, _T("Filename: ")), TSS_StringEntry(core::STR_UNKNOWN, _T("Unknown")),
|
||||
TSS_StringEntry(core::STR_NUMBER_TOO_BIG, _T("Number too big")),
|
||||
TSS_StringEntry(core::STR_SIGNAL, _T("Software interrupt forced exit:")),
|
||||
TSS_StringEntry(core::STR_NEWLINE, _T("\n")),
|
||||
|
@ -59,7 +56,9 @@ TSS_BeginStringtable( cCore )
|
|||
TSS_StringEntry(core::STR_MEMARCHIVE_ERRSTR, _T("")),
|
||||
TSS_StringEntry(core::STR_ENDOFTIME, _T("Tripwire is not designed to run past the year 2038.\nNow exiting...")),
|
||||
TSS_StringEntry(core::STR_UNKNOWN_TIME, _T("Unknown time")),
|
||||
TSS_StringEntry( core::STR_BAD_TEMPDIRECTORY, _T("Solution: Check existence/permissions for directory specified by TEMPDIRECTORY in config file") ),
|
||||
TSS_StringEntry(
|
||||
core::STR_BAD_TEMPDIRECTORY,
|
||||
_T("Solution: Check existence/permissions for directory specified by TEMPDIRECTORY in config file")),
|
||||
/// Particularly useful for eCharacter and eCharacterEncoding
|
||||
|
||||
TSS_StringEntry(core::STR_ERR_ISNULL, _T("Argument cannot be null.")),
|
||||
|
@ -68,6 +67,3 @@ TSS_BeginStringtable( cCore )
|
|||
TSS_StringEntry(core::STR_ERR_BADCHAR, _T("Input contained an invalid character."))
|
||||
|
||||
TSS_EndStringtable(cCore)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -48,34 +48,16 @@
|
|||
TSS_BeginStringIds(core)
|
||||
|
||||
STR_ERR2_ARCH_CRYPTO_ERR,
|
||||
STR_ERR2_BAD_ARG_PARAMS,
|
||||
STR_ERROR_ERROR,
|
||||
STR_ERROR_WARNING,
|
||||
STR_ERROR_COLON,
|
||||
STR_ERROR_HEADER,
|
||||
STR_ERROR_EXITING,
|
||||
STR_ERROR_CONTINUING,
|
||||
STR_ERR2_FILENAME,
|
||||
STR_ERROR_FILENAME,
|
||||
STR_NUMBER_TOO_BIG,
|
||||
STR_UNKNOWN,
|
||||
STR_SIGNAL,
|
||||
STR_NEWLINE,
|
||||
STR_MEMARCHIVE_FILENAME,
|
||||
STR_MEMARCHIVE_ERRSTR,
|
||||
STR_ENDOFTIME,
|
||||
STR_UNKNOWN_TIME,
|
||||
STR_BAD_TEMPDIRECTORY,
|
||||
STR_ERR2_BAD_ARG_PARAMS, STR_ERROR_ERROR, STR_ERROR_WARNING, STR_ERROR_COLON, STR_ERROR_HEADER, STR_ERROR_EXITING,
|
||||
STR_ERROR_CONTINUING, STR_ERR2_FILENAME, STR_ERROR_FILENAME, STR_NUMBER_TOO_BIG, STR_UNKNOWN, STR_SIGNAL,
|
||||
STR_NEWLINE, STR_MEMARCHIVE_FILENAME, STR_MEMARCHIVE_ERRSTR, STR_ENDOFTIME, STR_UNKNOWN_TIME, STR_BAD_TEMPDIRECTORY,
|
||||
|
||||
/// Particularly useful for eCharacterSet and eCharacterEncoding
|
||||
|
||||
STR_ERR_ISNULL,
|
||||
STR_ERR_OVERFLOW,
|
||||
STR_ERR_UNDERFLOW,
|
||||
STR_ERR_ISNULL, STR_ERR_OVERFLOW, STR_ERR_UNDERFLOW,
|
||||
STR_ERR_BADCHAR
|
||||
|
||||
TSS_EndStringIds(core)
|
||||
|
||||
|
||||
#endif //__CORESTRINGS_H
|
||||
|
||||
|
|
|
@ -86,7 +86,6 @@ void cDebug::Trace(int levelNum, const char* format, ...)
|
|||
va_start(args, format);
|
||||
DoTrace(format, args);
|
||||
va_end(args);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -231,7 +230,8 @@ bool cDebug::AddOutTarget(OutTarget target)
|
|||
mOutMask |= OUT_STDOUT;
|
||||
if (target == OUT_TRACE)
|
||||
mOutMask |= OUT_TRACE;
|
||||
if (target == OUT_FILE) {
|
||||
if (target == OUT_FILE)
|
||||
{
|
||||
mOutMask |= OUT_FILE;
|
||||
return false;
|
||||
}
|
||||
|
@ -286,10 +286,12 @@ bool cDebug::SetOutputFile(const char* filename)
|
|||
//make sure info. will not be clobbered.
|
||||
|
||||
//Should be open now- if not, abort.
|
||||
if (!logfile) {
|
||||
if (!logfile)
|
||||
{
|
||||
mOutMask ^= OUT_FILE;
|
||||
return false;
|
||||
} else
|
||||
}
|
||||
else
|
||||
mOutMask |= OUT_FILE;
|
||||
return true;
|
||||
}
|
||||
|
@ -318,4 +320,3 @@ void cDebug::DebugOut( const char* lpOutputString, ... )
|
|||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// ASSERT macro support function
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
#include <assert.h>
|
||||
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
/* Do it in this order, because autoconf checks for <stdarg.h>
|
||||
* first i.e. if HAVE_VARARGS_H is defined, it is only because
|
||||
|
@ -125,7 +123,6 @@ public:
|
|||
// Outputs based on levelnum. If levelnum <= global debug, print.
|
||||
|
||||
public:
|
||||
|
||||
static bool AddOutTarget(OutTarget target);
|
||||
static bool RemoveOutTarget(OutTarget target);
|
||||
// used to specify the out target....
|
||||
|
@ -144,7 +141,10 @@ public:
|
|||
// than that will have unpredictable and probably bad results
|
||||
private:
|
||||
#ifdef DEBUG
|
||||
enum { MAX_LABEL = 128 };
|
||||
enum
|
||||
{
|
||||
MAX_LABEL = 128
|
||||
};
|
||||
|
||||
static int mDebugLevel;
|
||||
static uint32 mOutMask;
|
||||
|
@ -181,29 +181,69 @@ inline int cDebug::GetDebugLevel()
|
|||
|
||||
# else // DEBUG
|
||||
|
||||
inline cDebug::cDebug (const char *) {}
|
||||
inline cDebug::~cDebug () {}
|
||||
inline cDebug::cDebug (const cDebug&) {}
|
||||
inline void cDebug::TraceAlways (const char *, ...) {}
|
||||
inline void cDebug::TraceError (const char *, ...) {}
|
||||
inline void cDebug::TraceWarning (const char *, ...) {}
|
||||
inline void cDebug::TraceDebug (const char *, ...) {}
|
||||
inline void cDebug::TraceDetail (const char *, ...) {}
|
||||
inline void cDebug::TraceNever (const char *, ...) {}
|
||||
inline void cDebug::TraceVaArgs (int, const char *, va_list &) {}
|
||||
inline void cDebug::Trace (int, const char*, ...) {}
|
||||
inline bool cDebug::AddOutTarget (OutTarget) { return false; }
|
||||
inline bool cDebug::RemoveOutTarget (OutTarget) { return false; }
|
||||
inline bool cDebug::HasOutTarget (OutTarget) { return false; }
|
||||
inline bool cDebug::SetOutputFile (const char*) { return false; }
|
||||
inline void cDebug::SetDebugLevel (int) {}
|
||||
inline int cDebug::GetDebugLevel (void) { return 0; }
|
||||
inline void cDebug::DebugOut ( const char*, ... ) {}
|
||||
inline cDebug::cDebug(const char*)
|
||||
{
|
||||
}
|
||||
inline cDebug::~cDebug()
|
||||
{
|
||||
}
|
||||
inline cDebug::cDebug(const cDebug&)
|
||||
{
|
||||
}
|
||||
inline void cDebug::TraceAlways(const char*, ...)
|
||||
{
|
||||
}
|
||||
inline void cDebug::TraceError(const char*, ...)
|
||||
{
|
||||
}
|
||||
inline void cDebug::TraceWarning(const char*, ...)
|
||||
{
|
||||
}
|
||||
inline void cDebug::TraceDebug(const char*, ...)
|
||||
{
|
||||
}
|
||||
inline void cDebug::TraceDetail(const char*, ...)
|
||||
{
|
||||
}
|
||||
inline void cDebug::TraceNever(const char*, ...)
|
||||
{
|
||||
}
|
||||
inline void cDebug::TraceVaArgs(int, const char*, va_list&)
|
||||
{
|
||||
}
|
||||
inline void cDebug::Trace(int, const char*, ...)
|
||||
{
|
||||
}
|
||||
inline bool cDebug::AddOutTarget(OutTarget)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
inline bool cDebug::RemoveOutTarget(OutTarget)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
inline bool cDebug::HasOutTarget(OutTarget)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
inline bool cDebug::SetOutputFile(const char*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
inline void cDebug::SetDebugLevel(int)
|
||||
{
|
||||
}
|
||||
inline int cDebug::GetDebugLevel(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
inline void cDebug::DebugOut(const char*, ...)
|
||||
{
|
||||
}
|
||||
|
||||
# endif // DEBUG
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// ASSERT macro
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -226,4 +266,3 @@ inline void cDebug::DebugOut ( const char*, ... ) {}
|
|||
# endif
|
||||
|
||||
#endif //__DEBUG_H
|
||||
|
||||
|
|
|
@ -66,8 +66,7 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
inline bool IsSingleTCHAR( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last )
|
||||
inline bool IsSingleTCHAR(TSTRING::const_iterator first, TSTRING::const_iterator last)
|
||||
{
|
||||
return (first + 1 == last);
|
||||
}
|
||||
|
@ -83,23 +82,19 @@ class iCharEncoder
|
|||
public:
|
||||
virtual ~iCharEncoder(){};
|
||||
|
||||
virtual bool NeedsEncoding( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const = 0;
|
||||
virtual bool NeedsEncoding(TSTRING::const_iterator first, TSTRING::const_iterator last) const = 0;
|
||||
// Determines if character identified by [first,last) needs encoding.
|
||||
// Returns true if it does.
|
||||
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const = 0;
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first, TSTRING::const_iterator last) const = 0;
|
||||
// Encodes character identified by [first,last) in such a way that it
|
||||
// can be decoded by Decode(). Returns encoded character sequence.
|
||||
|
||||
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const = 0;
|
||||
virtual TSTRING EncodePretty(TSTRING::const_iterator first, TSTRING::const_iterator last) const = 0;
|
||||
// Encodes character identified by [first,last) in a manner that is not roundtrip,
|
||||
// but looks good. Returns encoded character sequence.
|
||||
|
||||
virtual TSTRING Decode( TSTRING::const_iterator* pcur,
|
||||
const TSTRING::const_iterator end ) const = 0;
|
||||
virtual TSTRING Decode(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end) const = 0;
|
||||
// Decodes character sequence beginning with '*pcur' and ending before 'end'.
|
||||
// Returns decoded character or sequence of characters. Advances *pcur beyond
|
||||
// the last character decoded.
|
||||
|
@ -107,10 +102,12 @@ class iCharEncoder
|
|||
|
||||
virtual TCHAR Identifier() const = 0;
|
||||
|
||||
static TCHAR EscapeChar() { return char_escape; }
|
||||
static TCHAR EscapeChar()
|
||||
{
|
||||
return char_escape;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
static TCHAR char_escape;
|
||||
};
|
||||
|
||||
|
@ -118,21 +115,20 @@ class iCharEncoder
|
|||
class cNonNarrowableCharEncoder : public iCharEncoder
|
||||
{
|
||||
public:
|
||||
virtual ~cNonNarrowableCharEncoder() {}
|
||||
virtual ~cNonNarrowableCharEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool NeedsEncoding( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual bool NeedsEncoding(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual TSTRING EncodePretty(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING Decode( TSTRING::const_iterator* cur,
|
||||
const TSTRING::const_iterator end ) const;
|
||||
virtual TSTRING Decode(TSTRING::const_iterator* cur, const TSTRING::const_iterator end) const;
|
||||
|
||||
virtual TCHAR Identifier() const;
|
||||
|
||||
private:
|
||||
static TCHAR char_identifier;
|
||||
static TCHAR char_replace;
|
||||
|
@ -142,24 +138,22 @@ class cNonNarrowableCharEncoder : public iCharEncoder
|
|||
class cNonPrintableCharEncoder : public iCharEncoder
|
||||
{
|
||||
public:
|
||||
cNonPrintableCharEncoder( bool f_allowWS )
|
||||
: m_allowWS( f_allowWS ) {};
|
||||
cNonPrintableCharEncoder(bool f_allowWS) : m_allowWS(f_allowWS){};
|
||||
|
||||
virtual ~cNonPrintableCharEncoder() {}
|
||||
virtual ~cNonPrintableCharEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool NeedsEncoding( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual bool NeedsEncoding(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual TSTRING EncodePretty(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING Decode( TSTRING::const_iterator* cur,
|
||||
const TSTRING::const_iterator end ) const;
|
||||
virtual TSTRING Decode(TSTRING::const_iterator* cur, const TSTRING::const_iterator end) const;
|
||||
|
||||
virtual TCHAR Identifier() const;
|
||||
|
||||
private:
|
||||
static TCHAR char_identifier;
|
||||
static TCHAR char_replace;
|
||||
|
@ -170,21 +164,20 @@ class cNonPrintableCharEncoder : public iCharEncoder
|
|||
class cQuoteCharEncoder : public iCharEncoder
|
||||
{
|
||||
public:
|
||||
virtual ~cQuoteCharEncoder() {}
|
||||
virtual ~cQuoteCharEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool NeedsEncoding( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual bool NeedsEncoding(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual TSTRING EncodePretty(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING Decode( TSTRING::const_iterator* cur,
|
||||
const TSTRING::const_iterator end ) const;
|
||||
virtual TSTRING Decode(TSTRING::const_iterator* cur, const TSTRING::const_iterator end) const;
|
||||
|
||||
virtual TCHAR Identifier() const;
|
||||
|
||||
private:
|
||||
static TCHAR char_test;
|
||||
static TCHAR char_identifier;
|
||||
|
@ -195,21 +188,20 @@ class cQuoteCharEncoder : public iCharEncoder
|
|||
class cBackslashCharEncoder : public iCharEncoder
|
||||
{
|
||||
public:
|
||||
virtual ~cBackslashCharEncoder() {}
|
||||
virtual ~cBackslashCharEncoder()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool NeedsEncoding( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual bool NeedsEncoding(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const;
|
||||
virtual TSTRING EncodePretty(TSTRING::const_iterator first, TSTRING::const_iterator last) const;
|
||||
|
||||
virtual TSTRING Decode( TSTRING::const_iterator* cur,
|
||||
const TSTRING::const_iterator end ) const;
|
||||
virtual TSTRING Decode(TSTRING::const_iterator* cur, const TSTRING::const_iterator end) const;
|
||||
|
||||
virtual TCHAR Identifier() const;
|
||||
|
||||
private:
|
||||
static TCHAR char_test;
|
||||
static TCHAR char_identifier;
|
||||
|
@ -241,18 +233,13 @@ TCHAR cNonPrintableCharEncoder::char_replace = _T('?');
|
|||
// TESTS
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool cNonNarrowableCharEncoder::NeedsEncoding(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
bool cNonNarrowableCharEncoder::NeedsEncoding(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
return false; // all chars are narrow
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool cNonPrintableCharEncoder::NeedsEncoding(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
bool cNonPrintableCharEncoder::NeedsEncoding(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
// TODO:BAM -- handle this with mb chars
|
||||
// std::isprint<wchar_t> does a wctob() on the wchar!!?!?!
|
||||
|
@ -284,26 +271,14 @@ bool cNonPrintableCharEncoder::NeedsEncoding(
|
|||
return cCharEncoderUtil::IsPrintable(*first);
|
||||
}
|
||||
|
||||
bool cQuoteCharEncoder::NeedsEncoding(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
bool cQuoteCharEncoder::NeedsEncoding(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
return(
|
||||
IsSingleTCHAR( first, last )
|
||||
&&
|
||||
( *first == char_test )
|
||||
);
|
||||
return (IsSingleTCHAR(first, last) && (*first == char_test));
|
||||
}
|
||||
|
||||
bool cBackslashCharEncoder::NeedsEncoding(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
bool cBackslashCharEncoder::NeedsEncoding(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
return(
|
||||
IsSingleTCHAR( first, last )
|
||||
&&
|
||||
( *first == char_test )
|
||||
);
|
||||
return (IsSingleTCHAR(first, last) && (*first == char_test));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -311,9 +286,7 @@ bool cBackslashCharEncoder::NeedsEncoding(
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
TSTRING cNonNarrowableCharEncoder::EncodeRoundtrip(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
TSTRING cNonNarrowableCharEncoder::EncodeRoundtrip(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
TSTRING str;
|
||||
|
||||
|
@ -325,9 +298,7 @@ TSTRING cNonNarrowableCharEncoder::EncodeRoundtrip(
|
|||
}
|
||||
|
||||
|
||||
TSTRING cNonPrintableCharEncoder::EncodeRoundtrip(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
TSTRING cNonPrintableCharEncoder::EncodeRoundtrip(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
ASSERT(IsSingleTCHAR(first, last)); // non-prints are single char (see NOTE above)
|
||||
|
||||
|
@ -341,9 +312,7 @@ TSTRING cNonPrintableCharEncoder::EncodeRoundtrip(
|
|||
}
|
||||
|
||||
|
||||
TSTRING cQuoteCharEncoder::EncodeRoundtrip(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
TSTRING cQuoteCharEncoder::EncodeRoundtrip(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
// should just be a quote
|
||||
ASSERT(IsSingleTCHAR(first, last));
|
||||
|
@ -358,10 +327,7 @@ TSTRING cQuoteCharEncoder::EncodeRoundtrip(
|
|||
}
|
||||
|
||||
|
||||
|
||||
TSTRING cBackslashCharEncoder::EncodeRoundtrip(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
TSTRING cBackslashCharEncoder::EncodeRoundtrip(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
// should just be a backslash
|
||||
ASSERT(IsSingleTCHAR(first, last));
|
||||
|
@ -380,25 +346,19 @@ TSTRING cBackslashCharEncoder::EncodeRoundtrip(
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
TSTRING cNonNarrowableCharEncoder::EncodePretty(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
TSTRING cNonNarrowableCharEncoder::EncodePretty(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
return EncodeRoundtrip(first, last);
|
||||
}
|
||||
|
||||
|
||||
TSTRING cNonPrintableCharEncoder::EncodePretty(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
TSTRING cNonPrintableCharEncoder::EncodePretty(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
return EncodeRoundtrip(first, last);
|
||||
}
|
||||
|
||||
|
||||
TSTRING cQuoteCharEncoder::EncodePretty(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
TSTRING cQuoteCharEncoder::EncodePretty(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
// should just be a quote
|
||||
ASSERT(IsSingleTCHAR(first, last));
|
||||
|
@ -408,9 +368,7 @@ TSTRING cQuoteCharEncoder::EncodePretty(
|
|||
}
|
||||
|
||||
|
||||
TSTRING cBackslashCharEncoder::EncodePretty(
|
||||
TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last ) const
|
||||
TSTRING cBackslashCharEncoder::EncodePretty(TSTRING::const_iterator first, TSTRING::const_iterator last) const
|
||||
{
|
||||
// should just be a backslash
|
||||
ASSERT(IsSingleTCHAR(first, last));
|
||||
|
@ -424,8 +382,7 @@ TSTRING cBackslashCharEncoder::EncodePretty(
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
TSTRING cNonNarrowableCharEncoder::Decode( TSTRING::const_iterator* pcur,
|
||||
const TSTRING::const_iterator end ) const
|
||||
TSTRING cNonNarrowableCharEncoder::Decode(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end) const
|
||||
{
|
||||
// check preconditions
|
||||
if ((*pcur) >= end || *(*pcur) != Identifier())
|
||||
|
@ -435,8 +392,7 @@ TSTRING cNonNarrowableCharEncoder::Decode( TSTRING::const_iterator* pcur,
|
|||
}
|
||||
|
||||
|
||||
TSTRING cNonPrintableCharEncoder::Decode( TSTRING::const_iterator* pcur,
|
||||
const TSTRING::const_iterator end ) const
|
||||
TSTRING cNonPrintableCharEncoder::Decode(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end) const
|
||||
{
|
||||
// check preconditions
|
||||
if ((*pcur) >= end || *(*pcur) != Identifier())
|
||||
|
@ -446,8 +402,7 @@ TSTRING cNonPrintableCharEncoder::Decode( TSTRING::const_iterator* pcur,
|
|||
}
|
||||
|
||||
|
||||
TSTRING cQuoteCharEncoder::Decode( TSTRING::const_iterator* pcur,
|
||||
const TSTRING::const_iterator end ) const
|
||||
TSTRING cQuoteCharEncoder::Decode(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end) const
|
||||
{
|
||||
if ((*pcur) >= end || *(*pcur) != Identifier())
|
||||
ThrowAndAssert(eBadDecoderInput());
|
||||
|
@ -458,8 +413,7 @@ TSTRING cQuoteCharEncoder::Decode( TSTRING::const_iterator* pcur,
|
|||
}
|
||||
|
||||
|
||||
TSTRING cBackslashCharEncoder::Decode( TSTRING::const_iterator* pcur,
|
||||
const TSTRING::const_iterator end ) const
|
||||
TSTRING cBackslashCharEncoder::Decode(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end) const
|
||||
{
|
||||
if ((*pcur) >= end || *(*pcur) != Identifier())
|
||||
ThrowAndAssert(eBadDecoderInput());
|
||||
|
@ -502,11 +456,7 @@ TCHAR cBackslashCharEncoder::Identifier() const
|
|||
|
||||
bool cCharEncoderUtil::IsWhiteSpace(TCHAR ch)
|
||||
{
|
||||
return ( ch == '\r' ||
|
||||
ch == '\n' ||
|
||||
ch == '\t' ||
|
||||
ch == '\v' ||
|
||||
ch == ' ' );
|
||||
return (ch == '\r' || ch == '\n' || ch == '\t' || ch == '\v' || ch == ' ');
|
||||
}
|
||||
|
||||
bool cCharEncoderUtil::IsPrintable(TCHAR ch)
|
||||
|
@ -549,8 +499,7 @@ TSTRING cCharEncoderUtil::HexValueToCharString( const TSTRING& str )
|
|||
return strOut;
|
||||
}
|
||||
|
||||
TCHAR cCharEncoderUtil::hex_to_char( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last )
|
||||
TCHAR cCharEncoderUtil::hex_to_char(TSTRING::const_iterator first, TSTRING::const_iterator last)
|
||||
{
|
||||
static const TCHAR max_char = std::numeric_limits<TCHAR>::max();
|
||||
static const TCHAR min_char = std::numeric_limits<TCHAR>::min();
|
||||
|
@ -586,22 +535,17 @@ TSTRING cCharEncoderUtil::char_to_hex( TCHAR ch )
|
|||
|
||||
ss << tss::util::char_to_size(ch);
|
||||
|
||||
if( ss.bad() || ss.fail() ||
|
||||
ss.str().length() != TCHAR_AS_HEX__IN_TCHARS )
|
||||
if (ss.bad() || ss.fail() || ss.str().length() != TCHAR_AS_HEX__IN_TCHARS)
|
||||
ThrowAndAssert(eBadHexConversion(TSTRING(1, ch)));
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
TSTRING cCharEncoderUtil::DecodeHexToChar( TSTRING::const_iterator* pcur,
|
||||
const TSTRING::const_iterator end )
|
||||
TSTRING cCharEncoderUtil::DecodeHexToChar(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end)
|
||||
{
|
||||
// get hex numbers -- 2 chars
|
||||
TSTRING str;
|
||||
size_t n = 0;
|
||||
for( (*pcur)++;
|
||||
n < TCHAR_AS_HEX__IN_TCHARS &&
|
||||
(*pcur) != end;
|
||||
n++, (*pcur)++ )
|
||||
for ((*pcur)++; n < TCHAR_AS_HEX__IN_TCHARS && (*pcur) != end; n++, (*pcur)++)
|
||||
{
|
||||
str += *(*pcur);
|
||||
}
|
||||
|
@ -618,8 +562,7 @@ TSTRING cCharEncoderUtil::DecodeHexToChar( TSTRING::const_iterator* pcur,
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
cEncoder::cEncoder( int e, int f )
|
||||
: m_fFlags( f )
|
||||
cEncoder::cEncoder(int e, int f) : m_fFlags(f)
|
||||
{
|
||||
// add encodings
|
||||
if (e & NON_NARROWABLE)
|
||||
|
@ -632,14 +575,10 @@ cEncoder::cEncoder( int e, int f )
|
|||
m_encodings.push_back(new cQuoteCharEncoder);
|
||||
|
||||
// assert that we weren't passed anything freaky
|
||||
ASSERT( 0 == ( e & ~( NON_NARROWABLE |
|
||||
NON_PRINTABLE |
|
||||
BACKSLASH |
|
||||
DBL_QUOTE ) ) );
|
||||
ASSERT(0 == (e & ~(NON_NARROWABLE | NON_PRINTABLE | BACKSLASH | DBL_QUOTE)));
|
||||
|
||||
// add flags
|
||||
ASSERT( ! ( ( m_fFlags & ROUNDTRIP ) &&
|
||||
( m_fFlags & NON_ROUNDTRIP ) ) );
|
||||
ASSERT(!((m_fFlags & ROUNDTRIP) && (m_fFlags & NON_ROUNDTRIP)));
|
||||
|
||||
#ifdef TSS_DO_SCHEMA_VALIDATION
|
||||
|
||||
|
@ -647,7 +586,6 @@ cEncoder::cEncoder( int e, int f )
|
|||
ValidateSchema();
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -689,9 +627,7 @@ void cEncoder::Encode( TSTRING& strIn ) const
|
|||
sack_type::const_iterator atE;
|
||||
|
||||
// for all encoders
|
||||
for( atE = m_encodings.begin();
|
||||
atE != m_encodings.end();
|
||||
atE++ )
|
||||
for (atE = m_encodings.begin(); atE != m_encodings.end(); atE++)
|
||||
{
|
||||
// does char need encoding?
|
||||
if ((*atE)->NeedsEncoding(first, last))
|
||||
|
@ -713,9 +649,8 @@ void cEncoder::Encode( TSTRING& strIn ) const
|
|||
strIn = strOut;
|
||||
}
|
||||
|
||||
TSTRING cEncoder::Encode( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last,
|
||||
sack_type::const_iterator encoding ) const
|
||||
TSTRING
|
||||
cEncoder::Encode(TSTRING::const_iterator first, TSTRING::const_iterator last, sack_type::const_iterator encoding) const
|
||||
{
|
||||
// encode it
|
||||
if (RoundTrip())
|
||||
|
@ -739,8 +674,7 @@ void cEncoder::Decode( TSTRING& strIn ) const
|
|||
while (cCharUtil::PopNextChar(cur, end, first, last))
|
||||
{
|
||||
// is this char the escape character?
|
||||
if( IsSingleTCHAR( first, last ) &&
|
||||
*first == iCharEncoder::EscapeChar() )
|
||||
if (IsSingleTCHAR(first, last) && *first == iCharEncoder::EscapeChar())
|
||||
{
|
||||
// get to identifier
|
||||
if (!cCharUtil::PopNextChar(cur, end, first, last))
|
||||
|
@ -755,9 +689,7 @@ void cEncoder::Decode( TSTRING& strIn ) const
|
|||
// determine to which encoding the identifier belongs
|
||||
bool fFoundEncoding = false;
|
||||
sack_type::const_iterator atE;
|
||||
for( atE = m_encodings.begin();
|
||||
atE != m_encodings.end();
|
||||
atE++ )
|
||||
for (atE = m_encodings.begin(); atE != m_encodings.end(); atE++)
|
||||
{
|
||||
// is this the right encoding?
|
||||
if (*first == (*atE)->Identifier())
|
||||
|
@ -823,8 +755,7 @@ bool cEncoder::OnlyOneCatagoryPerChar() const
|
|||
}
|
||||
}
|
||||
ch++;
|
||||
}
|
||||
while( ch != std::numeric_limits<TCHAR>::max() );
|
||||
} while (ch != std::numeric_limits<TCHAR>::max());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -857,9 +788,7 @@ bool cEncoder::AllTestsRunOnEncodedString( const TSTRING& s ) const
|
|||
while (cCharUtil::PopNextChar(cur, end, first, last))
|
||||
{
|
||||
sack_type::const_iterator atE;
|
||||
for( atE = m_encodings.begin();
|
||||
atE != m_encodings.end();
|
||||
atE++ )
|
||||
for (atE = m_encodings.begin(); atE != m_encodings.end(); atE++)
|
||||
{
|
||||
if ((*atE)->NeedsEncoding(first, last))
|
||||
{
|
||||
|
@ -877,14 +806,7 @@ bool cEncoder::AllTestsRunOnEncodedString( const TSTRING& s ) const
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
cDisplayEncoder::cDisplayEncoder( Flags f )
|
||||
: cEncoder(
|
||||
NON_NARROWABLE |
|
||||
NON_PRINTABLE |
|
||||
BACKSLASH |
|
||||
DBL_QUOTE,
|
||||
f
|
||||
)
|
||||
cDisplayEncoder::cDisplayEncoder(Flags f) : cEncoder(NON_NARROWABLE | NON_PRINTABLE | BACKSLASH | DBL_QUOTE, f)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -898,4 +820,3 @@ bool cDisplayEncoder::Decode( TSTRING& str ) const
|
|||
cEncoder::Decode(str);
|
||||
return true; // TODO:BAM -- throw error!
|
||||
}
|
||||
|
||||
|
|
|
@ -89,9 +89,8 @@ class cEncoder
|
|||
private:
|
||||
typedef std::vector<iCharEncoder*> sack_type;
|
||||
|
||||
TSTRING Encode( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last,
|
||||
sack_type::const_iterator encoding ) const;
|
||||
TSTRING
|
||||
Encode(TSTRING::const_iterator first, TSTRING::const_iterator last, sack_type::const_iterator encoding) const;
|
||||
|
||||
bool RoundTrip() const;
|
||||
bool AllowWhiteSpace() const;
|
||||
|
@ -128,11 +127,9 @@ class cDisplayEncoder : public cEncoder
|
|||
};
|
||||
|
||||
|
||||
|
||||
class cCharEncoderUtil
|
||||
{
|
||||
public:
|
||||
|
||||
static bool IsPrintable(TCHAR ch);
|
||||
static bool IsWhiteSpace(TCHAR ch);
|
||||
|
||||
|
@ -140,13 +137,11 @@ class cCharEncoderUtil
|
|||
|
||||
static TSTRING HexValueToCharString(const TSTRING& str);
|
||||
|
||||
static TCHAR hex_to_char( TSTRING::const_iterator first,
|
||||
TSTRING::const_iterator last );
|
||||
static TCHAR hex_to_char(TSTRING::const_iterator first, TSTRING::const_iterator last);
|
||||
|
||||
static TSTRING char_to_hex(TCHAR ch);
|
||||
|
||||
static TSTRING DecodeHexToChar( TSTRING::const_iterator* pcur,
|
||||
const TSTRING::const_iterator end );
|
||||
static TSTRING DecodeHexToChar(TSTRING::const_iterator* pcur, const TSTRING::const_iterator end);
|
||||
|
||||
|
||||
enum
|
||||
|
@ -241,4 +236,3 @@ typedef cDisplayEncoder_<TCHAR> cDisplayEncoder;
|
|||
#endif //__DISPLAYENCODER_H
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
@ -96,5 +96,3 @@ TSTRING cDisplayUtil::FormatMultiLineString( const TSTRING& str, int nOffset, in
|
|||
|
||||
return (sstr.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -98,4 +98,3 @@ public:
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
#endif // #ifndef __DISPLAYUTIL_H
|
||||
|
||||
|
|
|
@ -64,4 +64,3 @@ bool CheckEpoch()
|
|||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -42,4 +42,3 @@
|
|||
bool CheckEpoch();
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,5 +47,3 @@ uint32 eError::CalcHash( const char* name )
|
|||
crcFinit(crc);
|
||||
return crc.crc;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
class eError
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Construction and Assignment
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -138,19 +137,24 @@ protected:
|
|||
class except : public base \
|
||||
{ \
|
||||
public: \
|
||||
except( const TSTRING& msg, uint32 flags = 0 ) \
|
||||
: base( msg, flags ) {} \
|
||||
TSS_BEGIN_EXCEPTION_EXPLICIT except( const except& rhs ) \
|
||||
: base( rhs ) {} \
|
||||
explicit except() : base() {} \
|
||||
except(const TSTRING& msg, uint32 flags = 0) : base(msg, flags) \
|
||||
{ \
|
||||
} \
|
||||
TSS_BEGIN_EXCEPTION_EXPLICIT except(const except& rhs) : base(rhs) \
|
||||
{ \
|
||||
} \
|
||||
explicit except() : base() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
virtual uint32 GetID() const \
|
||||
{ \
|
||||
return CalcHash(#except); \
|
||||
}\
|
||||
}
|
||||
|
||||
#define TSS_END_EXCEPTION() \
|
||||
};
|
||||
} \
|
||||
;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TSS_BEGIN_EXCEPTION_NO_CTOR
|
||||
|
@ -161,12 +165,14 @@ protected:
|
|||
class except : public base \
|
||||
{ \
|
||||
public: \
|
||||
explicit except() : base() {} \
|
||||
explicit except() : base() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
virtual uint32 GetID() const \
|
||||
{ \
|
||||
return CalcHash(#except); \
|
||||
}\
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TSS_EXCEPTION
|
||||
|
@ -189,31 +195,22 @@ protected:
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// eError
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline eError::eError( const TSTRING& msg, uint32 flags )
|
||||
: mMsg ( msg ),
|
||||
mFlags ( flags )
|
||||
inline eError::eError(const TSTRING& msg, uint32 flags) : mMsg(msg), mFlags(flags)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// eError
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline eError::eError( const eError& rhs )
|
||||
: mMsg ( rhs.mMsg ),
|
||||
mFlags ( rhs.mFlags )
|
||||
inline eError::eError(const eError& rhs) : mMsg(rhs.mMsg), mFlags(rhs.mFlags)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// eError
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline eError::eError( )
|
||||
: mMsg ( _T("") ),
|
||||
mFlags ( 0 )
|
||||
inline eError::eError() : mMsg(_T("")), mFlags(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -231,7 +228,6 @@ inline void eError::operator=( const eError& rhs )
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline eError::~eError()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -275,7 +271,6 @@ inline void eError::SetFatality(bool fatal)
|
|||
inline bool eError::IsFatal() const
|
||||
{
|
||||
return (mFlags & (uint32)NON_FATAL) == 0;
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -298,6 +293,4 @@ inline bool eError::SupressThird() const
|
|||
}
|
||||
|
||||
|
||||
|
||||
#endif //__ERROR_H
|
||||
|
||||
|
|
|
@ -57,7 +57,9 @@ class cErrorBucket
|
|||
{
|
||||
public:
|
||||
cErrorBucket();
|
||||
virtual ~cErrorBucket() {}
|
||||
virtual ~cErrorBucket()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void AddError(const eError& error);
|
||||
// add an error to the bucket
|
||||
|
@ -81,8 +83,7 @@ protected:
|
|||
///////////////////
|
||||
// cErrorBucket
|
||||
///////////////////
|
||||
inline cErrorBucket::cErrorBucket() :
|
||||
mpChild(0)
|
||||
inline cErrorBucket::cErrorBucket() : mpChild(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -99,4 +100,3 @@ inline cErrorBucket* cErrorBucket::SetChild(cErrorBucket* pNewChild)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -52,9 +52,7 @@ void cErrorBucket::AddError(const eError& error)
|
|||
//#############################################################################
|
||||
void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
||||
{
|
||||
cDisplayEncoder e(
|
||||
(cDisplayEncoder::Flags) ( cDisplayEncoder::NON_ROUNDTRIP |
|
||||
cDisplayEncoder::ALLOW_WHITESPACE ) );
|
||||
cDisplayEncoder e((cDisplayEncoder::Flags)(cDisplayEncoder::NON_ROUNDTRIP | cDisplayEncoder::ALLOW_WHITESPACE));
|
||||
TSTRING errStr;
|
||||
|
||||
//
|
||||
|
@ -74,8 +72,7 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
|||
return;
|
||||
|
||||
// "First Part" header
|
||||
errStr = TSS_GetString( cCore, error.IsFatal() ? core::STR_ERROR_ERROR
|
||||
: core::STR_ERROR_WARNING );
|
||||
errStr = TSS_GetString(cCore, error.IsFatal() ? core::STR_ERROR_ERROR : core::STR_ERROR_WARNING);
|
||||
|
||||
if (errStr.empty())
|
||||
{
|
||||
|
@ -136,7 +133,8 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
|||
break;
|
||||
}
|
||||
|
||||
TSTRING::size_type lastSpace = currentStr.find_last_of(SPACE, currentStr.length() >= WIDTH - 1 ? WIDTH - 1 : TSTRING::npos);
|
||||
TSTRING::size_type lastSpace =
|
||||
currentStr.find_last_of(SPACE, currentStr.length() >= WIDTH - 1 ? WIDTH - 1 : TSTRING::npos);
|
||||
if (lastSpace == TSTRING::npos)
|
||||
{
|
||||
// can't find space to break at so this string will just have to be longer than screen width.
|
||||
|
@ -148,15 +146,11 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
|||
lastSpace = currentStr.length();
|
||||
}
|
||||
|
||||
TCERR << TSS_GetString( cCore, core::STR_ERROR_HEADER )
|
||||
<< currentStr.substr( 0, lastSpace )
|
||||
<< std::endl;
|
||||
TCERR << TSS_GetString(cCore, core::STR_ERROR_HEADER) << currentStr.substr(0, lastSpace) << std::endl;
|
||||
|
||||
currentStr.erase(0, lastSpace + 1);
|
||||
}
|
||||
while ( !currentStr.empty() );
|
||||
}
|
||||
while ( !errStr.empty() );
|
||||
} while (!currentStr.empty());
|
||||
} while (!errStr.empty());
|
||||
}
|
||||
|
||||
// "Third Part" print 'exiting' or 'continuing'
|
||||
|
@ -165,11 +159,8 @@ void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
|
|||
if ((error.GetFlags() & eError::SUPRESS_THIRD_MSG) == 0)
|
||||
{
|
||||
TCERR << TSS_GetString(cCore, core::STR_ERROR_HEADER)
|
||||
<< TSS_GetString(
|
||||
cCore,
|
||||
error.IsFatal()
|
||||
? core::STR_ERROR_EXITING
|
||||
: core::STR_ERROR_CONTINUING ) << std::endl;
|
||||
<< TSS_GetString(cCore, error.IsFatal() ? core::STR_ERROR_EXITING : core::STR_ERROR_CONTINUING)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,9 +176,7 @@ void cErrorTracer::HandleError(const eError& error)
|
|||
{
|
||||
cDebug d("cErrorTracer::HandleError");
|
||||
|
||||
d.TraceError( _T("%s : %s\n"),
|
||||
cErrorTable::GetInstance()->Get( error.GetID() ).c_str(),
|
||||
error.GetMsg().c_str() );
|
||||
d.TraceError(_T("%s : %s\n"), cErrorTable::GetInstance()->Get(error.GetID()).c_str(), error.GetMsg().c_str());
|
||||
}
|
||||
|
||||
//#############################################################################
|
||||
|
@ -210,14 +199,12 @@ void cErrorQueue::HandleError(const eError& error)
|
|||
mList.push_back(ePoly(error));
|
||||
}
|
||||
|
||||
cErrorQueueIter::cErrorQueueIter(cErrorQueue& queue) :
|
||||
mList(queue.mList)
|
||||
cErrorQueueIter::cErrorQueueIter(cErrorQueue& queue) : mList(queue.mList)
|
||||
{
|
||||
SeekBegin();
|
||||
}
|
||||
|
||||
cErrorQueueIter::cErrorQueueIter(const cErrorQueue& queue)
|
||||
: mList( ((cErrorQueue*)&queue)->mList )
|
||||
cErrorQueueIter::cErrorQueueIter(const cErrorQueue& queue) : mList(((cErrorQueue*)&queue)->mList)
|
||||
{
|
||||
SeekBegin();
|
||||
}
|
||||
|
@ -267,7 +254,6 @@ void cErrorQueue::Read(iSerializer* pSerializer, int32 version)
|
|||
|
||||
mList.push_back(ePoly(errorNumber, errorString, flags));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -283,7 +269,6 @@ void cErrorQueue::Write(iSerializer* pSerializer) const
|
|||
pSerializer->WriteString((*i).GetMsg());
|
||||
pSerializer->WriteInt32((*i).GetFlags());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -303,4 +288,3 @@ void cErrorQueue::TraceContents(int dl) const
|
|||
d.Trace(dl, _T("Error[%d]: num = %x string = %s\n"), counter, (*i).GetID(), (*i).GetMsg().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ protected:
|
|||
class cErrorQueue : public cErrorBucket, public iTypedSerializable
|
||||
{
|
||||
friend class cErrorQueueIter;
|
||||
|
||||
public:
|
||||
void Clear();
|
||||
// remove all errors from the queue
|
||||
|
@ -119,6 +120,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void HandleError(const eError& error);
|
||||
|
||||
private:
|
||||
typedef std::list<ePoly> ListType;
|
||||
ListType mList;
|
||||
|
@ -131,7 +133,9 @@ class cErrorQueueIter
|
|||
public:
|
||||
cErrorQueueIter(cErrorQueue& queue);
|
||||
cErrorQueueIter(const cErrorQueue& queue);
|
||||
~cErrorQueueIter() {}
|
||||
~cErrorQueueIter()
|
||||
{
|
||||
}
|
||||
|
||||
// iteration methods
|
||||
void SeekBegin();
|
||||
|
@ -153,9 +157,14 @@ private:
|
|||
//////////////////////////////////////////////////////
|
||||
class cErrorBucketNull : public cErrorBucket
|
||||
{
|
||||
virtual void AddError(const eError& ) {}
|
||||
virtual void AddError(const eError&)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void HandleError(const eError& ) {}
|
||||
virtual void HandleError(const eError&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
|
@ -165,10 +174,10 @@ protected:
|
|||
class cErrorBucketPassThru : public cErrorBucket
|
||||
{
|
||||
protected:
|
||||
virtual void HandleError(const eError& ) {}
|
||||
virtual void HandleError(const eError&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -46,4 +46,3 @@ TSS_EXCEPTION( eBadCmdLine, eErrorGeneral );
|
|||
TSS_EXCEPTION(eBadModeSwitch, eErrorGeneral);
|
||||
|
||||
#endif //#ifndef __ERRORGENERAL_H
|
||||
|
||||
|
|
|
@ -72,10 +72,10 @@ void cErrorTable::AssertMsgValidity(const TCHAR* msg)
|
|||
// Sunpro got stuck in an infinite loop when we called GetString from this func;
|
||||
TSTRING::size_type errorSize = 9;
|
||||
TSTRING::size_type warningSize = 10;
|
||||
TSTRING::size_type maxHeaderSize = (errorSize > warningSize ? errorSize : warningSize) + 6; // Add 6 to account for "### ' and ': '
|
||||
TSTRING::size_type maxHeaderSize =
|
||||
(errorSize > warningSize ? errorSize : warningSize) + 6; // Add 6 to account for "### ' and ': '
|
||||
# endif
|
||||
|
||||
ASSERT(maxHeaderSize + errSize < 80);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -113,12 +113,9 @@ inline void cErrorTable::Put( const eError& e, const TCHAR* msg )
|
|||
RegisterErrors##pkgName::RegisterErrors##pkgName() \
|
||||
{
|
||||
|
||||
#define TSS_REGISTER_ERROR( err, str ) \
|
||||
cErrorTable::GetInstance()->Put \
|
||||
( err, str );
|
||||
# define TSS_REGISTER_ERROR(err, str) cErrorTable::GetInstance()->Put(err, str);
|
||||
|
||||
#define TSS_END_ERROR_REGISTRATION() \
|
||||
}
|
||||
# define TSS_END_ERROR_REGISTRATION() }
|
||||
|
||||
//===================
|
||||
// h file macros
|
||||
|
@ -132,9 +129,7 @@ inline void cErrorTable::Put( const eError& e, const TCHAR* msg )
|
|||
//===================
|
||||
// package init macros
|
||||
//===================
|
||||
#define TSS_REGISTER_PKG_ERRORS( pkgName ) \
|
||||
RegisterErrors##pkgName register##pkgName;
|
||||
# define TSS_REGISTER_PKG_ERRORS(pkgName) RegisterErrors##pkgName register##pkgName;
|
||||
|
||||
|
||||
#endif //__ERRORTABLE_H
|
||||
|
||||
|
|
|
@ -47,10 +47,9 @@ namespace //unique
|
|||
snprintf(string, size, "%d", value);
|
||||
return string;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
eInternal::eInternal(TCHAR* sourceFile, int lineNum)
|
||||
: eError(_T(""))
|
||||
eInternal::eInternal(TCHAR* sourceFile, int lineNum) : eError(_T(""))
|
||||
{
|
||||
TCHAR buf[256];
|
||||
|
||||
|
@ -81,4 +80,3 @@ TSTRING cErrorUtil::MakeFileError( const TSTRING& msg, const TSTRING& fileName )
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,11 @@ public:
|
|||
|
||||
// TODO: ASSERT is always fatal in Unix, perhaps we could #ifdef the ASSERT
|
||||
// to echo to cout the line number the exception occured at?
|
||||
#define ThrowAndAssert(exception) { ASSERT(false); throw exception; }
|
||||
#define ThrowAndAssert(exception) \
|
||||
{ \
|
||||
ASSERT(false); \
|
||||
throw exception; \
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -118,11 +122,8 @@ public:
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ePoly
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline ePoly::ePoly( uint32 id, const TSTRING& msg, uint32 flags )
|
||||
: eError( msg, flags ),
|
||||
mID( id )
|
||||
inline ePoly::ePoly(uint32 id, const TSTRING& msg, uint32 flags) : eError(msg, flags), mID(id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -136,11 +137,8 @@ inline ePoly::ePoly( const eError& rhs )
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ePoly
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline ePoly::ePoly()
|
||||
: eError( _T("") ),
|
||||
mID( 0 )
|
||||
inline ePoly::ePoly() : eError(_T("")), mID(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -170,4 +168,3 @@ inline void ePoly::SetID( uint32 id )
|
|||
}
|
||||
|
||||
#endif //__ERRORUTIL_H
|
||||
|
||||
|
|
|
@ -88,8 +88,10 @@ public:
|
|||
// note that reading from the file is implicit
|
||||
OPEN_READ = 0x00000001, // not needed, but makes calls nice...
|
||||
OPEN_WRITE = 0x00000002, // we will be writing to the file
|
||||
OPEN_LOCKED_TEMP = 0x00000004, // the file should not be readable by other processes and should be removed when closed
|
||||
OPEN_TRUNCATE = 0x00000008, // opens an empty file. creates it if it doesn't exist. Doesn't make much sense without OF_WRITE
|
||||
OPEN_LOCKED_TEMP =
|
||||
0x00000004, // the file should not be readable by other processes and should be removed when closed
|
||||
OPEN_TRUNCATE =
|
||||
0x00000008, // opens an empty file. creates it if it doesn't exist. Doesn't make much sense without OF_WRITE
|
||||
OPEN_CREATE = 0x00000010, // create the file if it doesn't exist; this is implicit if OF_TRUNCATE is set
|
||||
OPEN_TEXT = 0x00000020,
|
||||
OPEN_EXCLUSIVE = 0x00000040, // Use O_CREAT | O_EXCL
|
||||
|
@ -183,4 +185,3 @@ public:
|
|||
|
||||
|
||||
#endif //__FILE_H
|
||||
|
||||
|
|
|
@ -82,9 +82,9 @@ struct cFile_i
|
|||
};
|
||||
|
||||
//Ctor
|
||||
cFile_i::cFile_i() :
|
||||
m_fd(-1), mpCurrStream(NULL), mFlags(0)
|
||||
{}
|
||||
cFile_i::cFile_i() : m_fd(-1), mpCurrStream(NULL), mFlags(0)
|
||||
{
|
||||
}
|
||||
|
||||
//Dtor
|
||||
cFile_i::~cFile_i()
|
||||
|
@ -113,8 +113,7 @@ cFile_i::~cFile_i()
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
cFile::cFile() :
|
||||
mpData(NULL), isWritable(false)
|
||||
cFile::cFile() : mpData(NULL), isWritable(false)
|
||||
{
|
||||
mpData = new cFile_i;
|
||||
}
|
||||
|
@ -174,7 +173,8 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
|||
mode = _T("rb");
|
||||
}
|
||||
|
||||
if (flags & OPEN_EXCLUSIVE) {
|
||||
if (flags & OPEN_EXCLUSIVE)
|
||||
{
|
||||
perm |= O_CREAT | O_EXCL;
|
||||
openmode = (mode_t)0600; // Make sure only root can read the file
|
||||
}
|
||||
|
@ -257,7 +257,6 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
|||
ioctl(fh, VX_SETCACHE, VX_SEQ | VX_NOREUSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -351,14 +350,19 @@ cFile::File_t cFile::Read( void* buffer, File_t nBytes ) const //throw(eFile)
|
|||
if (nBytes == 0)
|
||||
return 0;
|
||||
|
||||
if (mpData->mFlags & OPEN_DIRECT) {
|
||||
if (mpData->mFlags & OPEN_DIRECT)
|
||||
{
|
||||
iBytesRead = read(mpData->m_fd, buffer, nBytes);
|
||||
if (iBytesRead<0) {
|
||||
if (iBytesRead < 0)
|
||||
{
|
||||
throw eFileRead(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
iBytesRead = fread(buffer, sizeof(byte), nBytes, mpData->mpCurrStream);
|
||||
if( ferror( mpData->mpCurrStream ) != 0 ) {
|
||||
if (ferror(mpData->mpCurrStream) != 0)
|
||||
{
|
||||
throw eFileRead(mpData->mFileName, iFSServices::GetInstance()->GetErrString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
#include "corestrings.h"
|
||||
|
||||
// TODO: Make this use MakeFileError() for consistency
|
||||
eFileError::eFileError( const TSTRING& filename, const TSTRING& description, uint32 flags )
|
||||
: eError( _T(""), flags )
|
||||
eFileError::eFileError(const TSTRING& filename, const TSTRING& description, uint32 flags) : eError(_T(""), flags)
|
||||
{
|
||||
mFilename = filename;
|
||||
mMsg = description;
|
||||
|
@ -73,4 +72,3 @@ TSTRING eFileError::GetDescription() const
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,10 +58,13 @@ private:
|
|||
public:
|
||||
eFileError(const TSTRING& filename, const TSTRING& description, uint32 flags = 0);
|
||||
|
||||
explicit eFileError( const eFileError& rhs )
|
||||
: eError( rhs ) { mFilename = rhs.mFilename; }
|
||||
eFileError( const TSTRING& msg, uint32 flags = 0 )
|
||||
: eError( msg, flags ) {}
|
||||
explicit eFileError(const eFileError& rhs) : eError(rhs)
|
||||
{
|
||||
mFilename = rhs.mFilename;
|
||||
}
|
||||
eFileError(const TSTRING& msg, uint32 flags = 0) : eError(msg, flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TSTRING GetFilename() const;
|
||||
|
@ -72,9 +75,9 @@ TSS_END_EXCEPTION()
|
|||
|
||||
# define TSS_FILE_EXCEPTION(except, base) \
|
||||
TSS_BEGIN_EXCEPTION(except, base) \
|
||||
except( const TSTRING& filename, const TSTRING& msg, uint32 flags = 0 ) \
|
||||
: base( filename, msg, flags ) {} \
|
||||
except(const TSTRING& filename, const TSTRING& msg, uint32 flags = 0) : base(filename, msg, flags) \
|
||||
{ \
|
||||
} \
|
||||
TSS_END_EXCEPTION()
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -79,9 +79,7 @@ void cFileHeaderID::operator=( const cFileHeaderID& rhs )
|
|||
|
||||
int cFileHeaderID::operator==(const cFileHeaderID& rhs) const
|
||||
{
|
||||
return
|
||||
( mIDLen == rhs.mIDLen ) &&
|
||||
( ::memcmp( mID, rhs.mID, mIDLen * sizeof(char) ) == 0 );
|
||||
return (mIDLen == rhs.mIDLen) && (::memcmp(mID, rhs.mID, mIDLen * sizeof(char)) == 0);
|
||||
}
|
||||
|
||||
void cFileHeaderID::Read(iSerializer* pSerializer, int32 /*version*/) // throw (eSerializer, eArchive)
|
||||
|
@ -108,8 +106,7 @@ void cFileHeaderID::Write(iSerializer* pSerializer) const // throw (eSerializer,
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// class cFileHeader
|
||||
|
||||
cFileHeader::cFileHeader()
|
||||
: mVersion(0)
|
||||
cFileHeader::cFileHeader() : mVersion(0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mEncoding = LAST_ENCODING; // set to invalid value so we can assert on write
|
||||
|
@ -119,20 +116,14 @@ cFileHeader::cFileHeader()
|
|||
}
|
||||
|
||||
cFileHeader::cFileHeader(const cFileHeader& rhs)
|
||||
: iSerializable(),
|
||||
mID(rhs.mID),
|
||||
mVersion(rhs.mVersion),
|
||||
mEncoding(rhs.mEncoding)
|
||||
: iSerializable(), mID(rhs.mID), mVersion(rhs.mVersion), mEncoding(rhs.mEncoding)
|
||||
{
|
||||
if (rhs.mBaggage.Length() > 0)
|
||||
{
|
||||
mBaggage.MapArchive(0, rhs.mBaggage.Length());
|
||||
rhs.mBaggage.MapArchive(0, rhs.mBaggage.Length());
|
||||
|
||||
::memcpy(
|
||||
mBaggage.GetMap(),
|
||||
rhs.mBaggage.GetMap(),
|
||||
static_cast<size_t>( rhs.mBaggage.Length() ) );
|
||||
::memcpy(mBaggage.GetMap(), rhs.mBaggage.GetMap(), static_cast<size_t>(rhs.mBaggage.Length()));
|
||||
|
||||
mBaggage.MapArchive(0, 0);
|
||||
rhs.mBaggage.MapArchive(0, 0);
|
||||
|
@ -250,4 +241,3 @@ void cFileHeader::Write(iSerializer* pSerializer) const // throw (eSerializer, e
|
|||
pSerializer->WriteBlob(mBaggage.GetMap(), len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,10 @@ private:
|
|||
// the program is the only person who will see them.
|
||||
int16 mIDLen;
|
||||
|
||||
enum { MAXBYTES = 256 };
|
||||
enum
|
||||
{
|
||||
MAXBYTES = 256
|
||||
};
|
||||
char mID[MAXBYTES];
|
||||
};
|
||||
|
||||
|
@ -84,9 +87,7 @@ inline cFileHeaderID::cFileHeaderID(const TCHAR* id)
|
|||
*this = id;
|
||||
}
|
||||
|
||||
inline
|
||||
cFileHeaderID::cFileHeaderID( const cFileHeaderID& rhs ) :
|
||||
iSerializable(), mIDLen( rhs.mIDLen )
|
||||
inline cFileHeaderID::cFileHeaderID(const cFileHeaderID& rhs) : iSerializable(), mIDLen(rhs.mIDLen)
|
||||
{
|
||||
memcpy(mID, rhs.mID, MAXBYTES);
|
||||
}
|
||||
|
@ -163,4 +164,3 @@ inline const cMemoryArchive& cFileHeader::GetBaggage() const
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -48,4 +48,3 @@
|
|||
#define fixed_basic_ofstream std::basic_ofstream
|
||||
|
||||
#endif //__FIXED_FILEBUF_H
|
||||
|
||||
|
|
|
@ -43,5 +43,3 @@ iFSServices* iFSServices::mpInstance = 0;
|
|||
//#############################################################################
|
||||
// eFSServices
|
||||
//#############################################################################
|
||||
|
||||
|
||||
|
|
|
@ -122,8 +122,10 @@ typedef int64 cFSType;
|
|||
|
||||
// this class is used only to pass arguments to iFSServices
|
||||
// it is the union of MAX(elem) for all the file systems that we support
|
||||
struct cFSStatArgs {
|
||||
enum FileType {
|
||||
struct cFSStatArgs
|
||||
{
|
||||
enum FileType
|
||||
{
|
||||
TY_INVALID, // lazy evaluation
|
||||
TY_FILE,
|
||||
TY_DIR,
|
||||
|
@ -164,7 +166,6 @@ struct cFSStatArgs {
|
|||
};
|
||||
|
||||
|
||||
|
||||
//=========================================================================
|
||||
//
|
||||
// eFSServices -- exception class
|
||||
|
@ -185,7 +186,9 @@ TSS_FILE_EXCEPTION( eFSServicesGeneric, eFSServices );
|
|||
class iFSServices
|
||||
{
|
||||
public:
|
||||
virtual ~iFSServices() {}
|
||||
virtual ~iFSServices()
|
||||
{
|
||||
}
|
||||
///////////////////////////////////////////////////////////////
|
||||
// ENUMS
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
@ -357,4 +360,3 @@ inline void iFSServices::SetInstance( iFSServices* pInst )
|
|||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,7 +47,10 @@ public:
|
|||
size_t mSize;
|
||||
int8* mpData;
|
||||
|
||||
cHeap( size_t size ) : mSize( size ), mpData( new int8[size] ) { ASSERT(mpData != 0); }
|
||||
cHeap(size_t size) : mSize(size), mpData(new int8[size])
|
||||
{
|
||||
ASSERT(mpData != 0);
|
||||
}
|
||||
// Note: The above ASSERT should never occur! If the new failed we should have thrown a bad_alloc().
|
||||
};
|
||||
typedef std::vector<cHeap> HeapList;
|
||||
|
@ -59,7 +62,10 @@ public:
|
|||
size_t mCurOff;
|
||||
|
||||
cGrowHeap_i(size_t initialSize, size_t growBy, const TCHAR* name);
|
||||
~cGrowHeap_i() { Clear(); }
|
||||
~cGrowHeap_i()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
size_t AlignSizeRequest(size_t size, size_t alignSize);
|
||||
void* Malloc(size_t size);
|
||||
|
@ -68,10 +74,7 @@ public:
|
|||
|
||||
|
||||
cGrowHeap_i::cGrowHeap_i(size_t initialSize, size_t growBy, const TCHAR* name)
|
||||
: mInitialSize( initialSize ),
|
||||
mGrowBy ( growBy ),
|
||||
mName ( name ),
|
||||
mCurOff ( 0 )
|
||||
: mInitialSize(initialSize), mGrowBy(growBy), mName(name), mCurOff(0)
|
||||
{
|
||||
// assure that initial size and growby are aligned
|
||||
ASSERT(0 == (initialSize % BYTE_ALIGN));
|
||||
|
@ -168,10 +171,9 @@ void cGrowHeap_i::Clear()
|
|||
//-----------------------------------------------------------------------------
|
||||
// cGrowHeap
|
||||
//-----------------------------------------------------------------------------
|
||||
cGrowHeap::cGrowHeap( size_t initialSize, size_t growBy, const TCHAR* name ) :
|
||||
mpData( new cGrowHeap_i( initialSize, growBy, name ) )
|
||||
cGrowHeap::cGrowHeap(size_t initialSize, size_t growBy, const TCHAR* name)
|
||||
: mpData(new cGrowHeap_i(initialSize, growBy, name))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
cGrowHeap::~cGrowHeap()
|
||||
|
@ -191,4 +193,3 @@ void cGrowHeap::Clear()
|
|||
{
|
||||
mpData->Clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,4 +69,3 @@ private:
|
|||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -32,5 +32,3 @@
|
|||
//hashtable.cpp : implementation for hashtable which maps const TCHAR*'s to void*'s
|
||||
#include "stdcore.h"
|
||||
#include "hashtable.h"
|
||||
|
||||
|
||||
|
|
|
@ -67,8 +67,7 @@
|
|||
// equality. There is also a specialization for TSTRINGS. If neither of these
|
||||
// fit your needs, you must pass the hash table your own fn pointer or class
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template<class T>
|
||||
class cDefaultCompare
|
||||
template<class T> class cDefaultCompare
|
||||
{
|
||||
public:
|
||||
bool operator()(const T& lhs, const T& rhs)
|
||||
|
@ -79,8 +78,7 @@ public:
|
|||
/////////////////////////////////////////////////////////
|
||||
// specialization for TSTRINGS
|
||||
/////////////////////////////////////////////////////////
|
||||
template<>
|
||||
inline bool cDefaultCompare<TSTRING>::operator()(const TSTRING& lhs, const TSTRING& rhs)
|
||||
template<> inline bool cDefaultCompare<TSTRING>::operator()(const TSTRING& lhs, const TSTRING& rhs)
|
||||
{
|
||||
return (lhs.compare(rhs) == 0);
|
||||
}
|
||||
|
@ -90,8 +88,7 @@ inline bool cDefaultCompare<TSTRING>::operator()(const TSTRING& lhs, const TSTRI
|
|||
// into a byte* and a key length (for hashing purposes). The default implementation
|
||||
// just does a cast. A specialization is also provided for TSTRINGs.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template<class T>
|
||||
class cDefaultConvert
|
||||
template<class T> class cDefaultConvert
|
||||
{
|
||||
public:
|
||||
const byte* operator()(const T& obj, int* const pcbKeyLen)
|
||||
|
@ -104,8 +101,7 @@ public:
|
|||
/////////////////////////////////////////////////////////
|
||||
// specialization for TSTRINGS
|
||||
/////////////////////////////////////////////////////////
|
||||
template<>
|
||||
inline const byte* cDefaultConvert<TSTRING>::operator()(const TSTRING& obj, int* const pcbKeyLen )
|
||||
template<> inline const byte* cDefaultConvert<TSTRING>::operator()(const TSTRING& obj, int* const pcbKeyLen)
|
||||
{
|
||||
*pcbKeyLen = sizeof(TCHAR) * obj.length();
|
||||
return (byte*)obj.c_str();
|
||||
|
@ -123,7 +119,8 @@ inline const byte* cDefaultConvert<TSTRING>::operator()(const TSTRING& obj, int*
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// these were moved outside of the class because it sucks to have to name the class with template parameters
|
||||
// ie -- mTable(cHashTable<TSTRING, int>::MEDIUM
|
||||
enum cHashTable_TableSize {
|
||||
enum cHashTable_TableSize
|
||||
{
|
||||
HASH_VERY_SMALL = 17,
|
||||
HASH_SMALL = 2007,
|
||||
HASH_MEDIUM = 6007,
|
||||
|
@ -132,17 +129,25 @@ enum cHashTable_TableSize {
|
|||
};
|
||||
|
||||
// forward declaration
|
||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP = cDefaultCompare<KEY_TYPE>, class CONVERTER = cDefaultConvert<KEY_TYPE> >
|
||||
template<class KEY_TYPE,
|
||||
class VAL_TYPE,
|
||||
class COMPARE_OP = cDefaultCompare<KEY_TYPE>,
|
||||
class CONVERTER = cDefaultConvert<KEY_TYPE> >
|
||||
class cHashTableIter;
|
||||
|
||||
//General version of cHashTable template:
|
||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP = cDefaultCompare<KEY_TYPE>, class CONVERTER = cDefaultConvert<KEY_TYPE> >
|
||||
template<class KEY_TYPE,
|
||||
class VAL_TYPE,
|
||||
class COMPARE_OP = cDefaultCompare<KEY_TYPE>,
|
||||
class CONVERTER = cDefaultConvert<KEY_TYPE> >
|
||||
class cHashTable
|
||||
{
|
||||
friend class cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>;
|
||||
|
||||
public:
|
||||
//structure for hash table nodes.
|
||||
struct node {
|
||||
struct node
|
||||
{
|
||||
KEY_TYPE nKey;
|
||||
VAL_TYPE nData;
|
||||
node* next;
|
||||
|
@ -169,7 +174,10 @@ public:
|
|||
bool IsEmpty(void) const;
|
||||
uint32 Hash(const KEY_TYPE& key) const;
|
||||
//The hashing function, taken from old Tripwire
|
||||
int32 GetNumValues() const { return mValuesInTable; };
|
||||
int32 GetNumValues() const
|
||||
{
|
||||
return mValuesInTable;
|
||||
};
|
||||
// returns number of table entries filled
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -190,8 +198,7 @@ private:
|
|||
// cHashTableIter
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||
class cHashTableIter
|
||||
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER> class cHashTableIter
|
||||
{
|
||||
public:
|
||||
cHashTableIter(const cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>& hashTbl);
|
||||
|
@ -214,7 +221,6 @@ private:
|
|||
};
|
||||
|
||||
|
||||
|
||||
//#############################################################################
|
||||
// implementation
|
||||
|
||||
|
@ -222,8 +228,9 @@ private:
|
|||
// iterator
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||
inline cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::cHashTableIter( const cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>& hashTbl) :
|
||||
mHashTable(hashTbl)
|
||||
inline cHashTableIter<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::cHashTableIter(
|
||||
const cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>& hashTbl)
|
||||
: mHashTable(hashTbl)
|
||||
{
|
||||
SeekBegin();
|
||||
}
|
||||
|
@ -334,7 +341,8 @@ bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Insert(KEY_TYPE key,
|
|||
COMPARE_OP compare;
|
||||
|
||||
int hindex = Hash(key);
|
||||
if (mTable[hindex] == NULL) {
|
||||
if (mTable[hindex] == NULL)
|
||||
{
|
||||
//open index, perform insert
|
||||
mTable[hindex] = new node;
|
||||
(mTable[hindex])->nKey = key;
|
||||
|
@ -393,19 +401,20 @@ bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Insert(KEY_TYPE key,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// General Version:
|
||||
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||
bool
|
||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Lookup(KEY_TYPE key, VAL_TYPE& d_out) const
|
||||
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Lookup(KEY_TYPE key, VAL_TYPE& d_out) const
|
||||
{
|
||||
COMPARE_OP compare;
|
||||
|
||||
int hindex = Hash(key);
|
||||
if (mTable[hindex] == NULL)
|
||||
return false;
|
||||
else {
|
||||
else
|
||||
{
|
||||
node* nodeptr = mTable[hindex];
|
||||
while (nodeptr != NULL)
|
||||
{
|
||||
if( compare(nodeptr->nKey, key)) {
|
||||
if (compare(nodeptr->nKey, key))
|
||||
{
|
||||
d_out = nodeptr->nData;
|
||||
return true;
|
||||
}
|
||||
|
@ -421,21 +430,23 @@ cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Lookup(KEY_TYPE key, VAL_
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// General Version -
|
||||
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||
bool
|
||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Remove(KEY_TYPE key)
|
||||
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Remove(KEY_TYPE key)
|
||||
{
|
||||
COMPARE_OP compare;
|
||||
|
||||
int hindex = Hash(key);
|
||||
if (mTable[hindex] == NULL) {
|
||||
if (mTable[hindex] == NULL)
|
||||
{
|
||||
delete (mTable[hindex]);
|
||||
mTable[hindex] = NULL;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
node* nodeptr = mTable[hindex];
|
||||
node* prev;
|
||||
while(nodeptr != NULL) {
|
||||
while (nodeptr != NULL)
|
||||
{
|
||||
prev = nodeptr;
|
||||
if (compare(mTable[hindex]->nKey, key))
|
||||
{
|
||||
|
@ -456,15 +467,16 @@ cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Remove(KEY_TYPE key)
|
|||
// Clear -- Clears entire hash table so that all indices are NULL
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||
bool
|
||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Clear(void)
|
||||
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Clear(void)
|
||||
{
|
||||
for (int i = 0; i < mTableSize; ++i)
|
||||
{
|
||||
if (mTable[i] != NULL) {
|
||||
if (mTable[i] != NULL)
|
||||
{
|
||||
node* curr = mTable[i];
|
||||
node* del;
|
||||
while(curr != NULL) {
|
||||
while (curr != NULL)
|
||||
{
|
||||
del = curr;
|
||||
curr = curr->next;
|
||||
delete del;
|
||||
|
@ -482,8 +494,7 @@ cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::Clear(void)
|
|||
// IsEmpty --
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template<class KEY_TYPE, class VAL_TYPE, class COMPARE_OP, class CONVERTER>
|
||||
bool
|
||||
cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::IsEmpty(void) const
|
||||
bool cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::IsEmpty(void) const
|
||||
{
|
||||
bool ret = true;
|
||||
for (int i = 0; i < mTableSize; ++i)
|
||||
|
@ -538,12 +549,15 @@ void cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::TraceDiagnostics() c
|
|||
d.TraceDebug("---------------Hash Table Statisics---------------\n");
|
||||
d.TraceDebug("-- Number of slots: %d\n", mTableSize);
|
||||
d.TraceDebug("-- Number of items: %d\n", numItems);
|
||||
d.TraceDebug("-- Slots filled: %d (%lf %%)\n",slotsFilled, ((double)slotsFilled / (double)mTableSize) * 100.0);
|
||||
d.TraceDebug("-- Slots with >1 item: %d (%lf %%)\n",numMultiSlot, ((double)numMultiSlot / (double)slotsFilled) * 100.0);
|
||||
d.TraceDebug("-- Slots filled: %d (%lf %%)\n",
|
||||
slotsFilled,
|
||||
((double)slotsFilled / (double)mTableSize) * 100.0);
|
||||
d.TraceDebug("-- Slots with >1 item: %d (%lf %%)\n",
|
||||
numMultiSlot,
|
||||
((double)numMultiSlot / (double)slotsFilled) * 100.0);
|
||||
d.TraceDebug("--------------------------------------------------\n");
|
||||
}
|
||||
# endif // DEBUG
|
||||
|
||||
|
||||
#endif //__HASHTABLE_H
|
||||
|
||||
|
|
|
@ -66,11 +66,20 @@
|
|||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
#if (WCHAR_IS_16_BITS)
|
||||
namespace tss { typedef std::wstring dbstring; }
|
||||
namespace tss
|
||||
{
|
||||
typedef std::wstring dbstring;
|
||||
}
|
||||
|
||||
#elif (WCHAR_IS_32_BITS)
|
||||
namespace std { template <> struct char_traits< dbchar_t >; }
|
||||
namespace tss { typedef std::basic_string<dbchar_t> dbstring; }
|
||||
namespace std
|
||||
{
|
||||
template<> struct char_traits<dbchar_t>;
|
||||
}
|
||||
namespace tss
|
||||
{
|
||||
typedef std::basic_string<dbchar_t> dbstring;
|
||||
}
|
||||
|
||||
#else
|
||||
# error "wchar_t is not correctly factored!"
|
||||
|
@ -84,8 +93,7 @@
|
|||
|
||||
// specialize *std*::char_traits!!!
|
||||
|
||||
template<>
|
||||
struct std::char_traits< dbchar_t >
|
||||
template<> struct std::char_traits<dbchar_t>
|
||||
{
|
||||
typedef dbchar_t char_type;
|
||||
typedef wint_t int_type;
|
||||
|
@ -98,23 +106,22 @@ struct std::char_traits< dbchar_t >
|
|||
typedef int state_type; // Shame on you KAI! This is ANSI-C!
|
||||
# endif
|
||||
|
||||
static
|
||||
void assign( char_type& lhs, const char_type& rhs ) {
|
||||
static void assign(char_type& lhs, const char_type& rhs)
|
||||
{
|
||||
lhs = rhs;
|
||||
}
|
||||
|
||||
static
|
||||
bool eq( const char_type& lhs, const char_type& rhs ) {
|
||||
static bool eq(const char_type& lhs, const char_type& rhs)
|
||||
{
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
static
|
||||
bool lt( const char_type& lhs, const char_type& rhs ) {
|
||||
static bool lt(const char_type& lhs, const char_type& rhs)
|
||||
{
|
||||
return lhs < rhs;
|
||||
}
|
||||
|
||||
static
|
||||
int compare( const char_type* lhs, const char_type* rhs, size_t N )
|
||||
static int compare(const char_type* lhs, const char_type* rhs, size_t N)
|
||||
{
|
||||
for (; N; ++lhs, ++rhs, --N)
|
||||
if (*lhs != *rhs)
|
||||
|
@ -123,21 +130,20 @@ struct std::char_traits< dbchar_t >
|
|||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
size_t length( const char_type* psz )
|
||||
static size_t length(const char_type* psz)
|
||||
{
|
||||
if (psz == 0)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
const char_type* end;
|
||||
for ( end = psz; *end; end++ );
|
||||
for (end = psz; *end; end++)
|
||||
;
|
||||
return (size_t)(end - psz);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
char_type* copy( char_type* lhs, const char_type* rhs, size_t N )
|
||||
static char_type* copy(char_type* lhs, const char_type* rhs, size_t N)
|
||||
{
|
||||
for (char_type* at = lhs; N; ++at, ++rhs, --N)
|
||||
*at = *rhs;
|
||||
|
@ -145,9 +151,7 @@ struct std::char_traits< dbchar_t >
|
|||
return lhs;
|
||||
}
|
||||
|
||||
static
|
||||
const char_type*
|
||||
find( const char_type* psz, size_t N, const char_type& ch )
|
||||
static const char_type* find(const char_type* psz, size_t N, const char_type& ch)
|
||||
{
|
||||
for (; N; ++psz, --N)
|
||||
if (*psz == ch)
|
||||
|
@ -156,40 +160,35 @@ struct std::char_traits< dbchar_t >
|
|||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
char_type* move( char_type* lhs, const char_type* rhs, size_t N ) {
|
||||
static char_type* move(char_type* lhs, const char_type* rhs, size_t N)
|
||||
{
|
||||
return (char_type*)memmove(lhs, rhs, N * sizeof(char_type));
|
||||
}
|
||||
|
||||
static
|
||||
char_type* assign( char_type* lhs, size_t N, char_type ch )
|
||||
static char_type* assign(char_type* lhs, size_t N, char_type ch)
|
||||
{
|
||||
for (char_type* at = lhs; N; ++at, --N)
|
||||
*at = ch;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
static
|
||||
int_type not_eof( const int_type& ch ) {
|
||||
static int_type not_eof(const int_type& ch)
|
||||
{
|
||||
return int_type(!eq(ch, eof()) ? ch : ~ch);
|
||||
}
|
||||
|
||||
static
|
||||
char_type to_char_type( const int_type& ch )
|
||||
static char_type to_char_type(const int_type& ch)
|
||||
{
|
||||
return
|
||||
eq_int_type( ch, to_int_type( ch ) )
|
||||
? ch
|
||||
: char_type(0);
|
||||
return eq_int_type(ch, to_int_type(ch)) ? ch : char_type(0);
|
||||
}
|
||||
|
||||
static
|
||||
int_type to_int_type( const char_type& ch ) {
|
||||
static int_type to_int_type(const char_type& ch)
|
||||
{
|
||||
return (int_type)ch;
|
||||
}
|
||||
|
||||
static
|
||||
bool eq_int_type( const int_type& lhs, const int_type& rhs ) {
|
||||
static bool eq_int_type(const int_type& lhs, const int_type& rhs)
|
||||
{
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
|
@ -198,31 +197,31 @@ struct std::char_traits< dbchar_t >
|
|||
// CAUTION:RAD -- Extra members required by Modena!!
|
||||
|
||||
# ifdef MBSTATE_T_DEFINED // This is ANSI-C *not* ANSI-C++!!
|
||||
static
|
||||
state_type get_state( pos_type pos ) {
|
||||
static state_type get_state(pos_type pos)
|
||||
{
|
||||
return pos.state();
|
||||
}
|
||||
|
||||
static
|
||||
pos_type get_pos( pos_type pos, state_type state ) {
|
||||
static pos_type get_pos(pos_type pos, state_type state)
|
||||
{
|
||||
return pos_type(pos.offset(), state);
|
||||
}
|
||||
# endif //MBSTATE_T_DEFINED
|
||||
|
||||
static
|
||||
char_type newline() {
|
||||
static char_type newline()
|
||||
{
|
||||
return L'\n';
|
||||
}
|
||||
|
||||
static
|
||||
char_type eos() {
|
||||
static char_type eos()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
# endif //IS_STDLIB_MODENA
|
||||
|
||||
static
|
||||
int_type eof() {
|
||||
static int_type eof()
|
||||
{
|
||||
return (wint_t)(0xFFFF);
|
||||
}
|
||||
};
|
||||
|
@ -231,4 +230,3 @@ struct std::char_traits< dbchar_t >
|
|||
|
||||
|
||||
#endif //__NTDBS_H
|
||||
|
||||
|
|
|
@ -47,13 +47,11 @@
|
|||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
#ifndef TSS_Raise // Should add file and line info in DEBUG mode!!!!
|
||||
#define TSS_Raise( Xcpt, pkg, ids ) \
|
||||
throw Xcpt( TSS_GetString( pkg, ids ) )
|
||||
# define TSS_Raise(Xcpt, pkg, ids) throw Xcpt(TSS_GetString(pkg, ids))
|
||||
|
||||
#endif //TSS_Raise
|
||||
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// NTMBS Utils -- Definition
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -134,8 +132,7 @@ tss::mbsdec( const_ntmbs_t beg, const_ntmbs_t curr )
|
|||
* POSTCONDITIONS:
|
||||
* Returns non-const pointer after moving it.
|
||||
*/
|
||||
ntmbs_t
|
||||
tss::mbsinc( const_ntmbs_t psz )
|
||||
ntmbs_t tss::mbsinc(const_ntmbs_t psz)
|
||||
{
|
||||
cDebug dbg("tss::mbsinc -");
|
||||
|
||||
|
@ -153,10 +150,7 @@ tss::mbsinc( const_ntmbs_t psz )
|
|||
}
|
||||
|
||||
dbg.TraceDebug("Incorrectly Formed, Cannot Normalize!\n");
|
||||
TSS_Raise(
|
||||
eCharacterEncoding,
|
||||
cCore,
|
||||
core::STR_ERR_BADCHAR );
|
||||
TSS_Raise(eCharacterEncoding, cCore, core::STR_ERR_BADCHAR);
|
||||
}
|
||||
|
||||
return (((ntmbs_t)psz) + nBytes);
|
||||
|
@ -180,8 +174,7 @@ tss::mbsinc( const_ntmbs_t psz )
|
|||
* POSTCONDITIONS:
|
||||
* Returns size_t value indicating bytes in the range of [0,nCount).
|
||||
*/
|
||||
size_t
|
||||
tss::mbsbytes( const_ntmbs_t psz, size_t nCount )
|
||||
size_t tss::mbsbytes(const_ntmbs_t psz, size_t nCount)
|
||||
{
|
||||
const_ntmbs_t at = psz;
|
||||
while (nCount--)
|
||||
|
@ -192,21 +185,19 @@ tss::mbsbytes( const_ntmbs_t psz, size_t nCount )
|
|||
|
||||
/// To Null terminator
|
||||
|
||||
size_t
|
||||
tss::mbsbytes( const_ntmbs_t psz )
|
||||
size_t tss::mbsbytes(const_ntmbs_t psz)
|
||||
{
|
||||
if (psz == 0)
|
||||
throw eCharacter(TSS_GetString(cCore, core::STR_ERR_ISNULL));
|
||||
|
||||
|
||||
const_ntmbs_t at;
|
||||
for ( at = psz; *at; ++at );
|
||||
for (at = psz; *at; ++at)
|
||||
;
|
||||
return (size_t)((char*)at - (char*)psz);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* TSS::mbscount
|
||||
*
|
||||
|
@ -224,25 +215,22 @@ tss::mbsbytes( const_ntmbs_t psz )
|
|||
* POSTCONDITIONS:
|
||||
* Returns size_t value indicating characters in the range of [psz + 0, psz + nBytes).
|
||||
*/
|
||||
size_t
|
||||
tss_mbscount( const_ntmbs_t psz, size_t nBytes )
|
||||
size_t tss_mbscount(const_ntmbs_t psz, size_t nBytes)
|
||||
{
|
||||
size_t nCount = 0;
|
||||
const_ntmbs_t at = psz;
|
||||
const_ntmbs_t end = psz + nBytes;
|
||||
for ( ; at < end; nCount++, at = tss::mbsinc( at ) );
|
||||
for (; at < end; nCount++, at = tss::mbsinc(at))
|
||||
;
|
||||
return nCount;
|
||||
}
|
||||
|
||||
/// To Null terminator
|
||||
|
||||
size_t
|
||||
tss::mbscount( const_ntmbs_t psz )
|
||||
size_t tss::mbscount(const_ntmbs_t psz)
|
||||
{
|
||||
size_t nCount = 0;
|
||||
for ( ; *psz; psz = tss::mbsinc( psz ), nCount++ );
|
||||
for (; *psz; psz = tss::mbsinc(psz), nCount++)
|
||||
;
|
||||
return nCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
154
src/core/ntmbs.h
154
src/core/ntmbs.h
|
@ -78,7 +78,6 @@
|
|||
#endif //NTWCS_T_DEFINED
|
||||
|
||||
|
||||
|
||||
/// NOTE: Size Specific (2 [double] or 4 [quad] byte wide characters)
|
||||
|
||||
//--Null-terminated double(2)-byte Character Sequence
|
||||
|
@ -109,7 +108,6 @@
|
|||
#endif //NTQBS_T_DEFINED
|
||||
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// NTMBS Manipulators
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -131,10 +129,11 @@ namespace tss
|
|||
size_t mbsbytes(const_ntmbs_t);
|
||||
size_t mbscount(const_ntmbs_t);
|
||||
|
||||
inline size_t mbslen( const_ntmbs_t psz ) { // RAD: Yeesh!
|
||||
inline size_t mbslen(const_ntmbs_t psz)
|
||||
{ // RAD: Yeesh!
|
||||
return tss::mbscount(psz);
|
||||
}
|
||||
}//tss::
|
||||
} // namespace tss
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -149,9 +148,8 @@ namespace tss
|
|||
|
||||
//--DEC
|
||||
|
||||
template< class CT >
|
||||
inline
|
||||
CT* strdec( const CT*, const CT* psz ) {
|
||||
template<class CT> inline CT* strdec(const CT*, const CT* psz)
|
||||
{
|
||||
return const_cast<CT*>(psz - 1);
|
||||
}
|
||||
|
||||
|
@ -166,33 +164,25 @@ namespace tss
|
|||
|
||||
//--INC
|
||||
|
||||
template< class CT >
|
||||
inline
|
||||
CT* strinc( const CT* psz )
|
||||
template<class CT> inline CT* strinc(const CT* psz)
|
||||
{
|
||||
ASSERT(psz);
|
||||
return const_cast<CT*>((*psz ? psz + 1 : psz));
|
||||
}
|
||||
|
||||
template< class CT, class SIZET >
|
||||
inline
|
||||
CT* strinc( const CT* psz, SIZET N )
|
||||
template<class CT, class SIZET> inline CT* strinc(const CT* psz, SIZET N)
|
||||
{
|
||||
ASSERT(psz);
|
||||
return const_cast<CT*>((*psz ? psz + N : psz));
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
inline
|
||||
ntmbs_t strinc( const_ntmbs_t psz )
|
||||
template<> inline ntmbs_t strinc(const_ntmbs_t psz)
|
||||
{
|
||||
return tss::mbsinc(psz);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline
|
||||
ntmbs_t strinc( const_ntmbs_t psz, size_t N )
|
||||
template<> inline ntmbs_t strinc(const_ntmbs_t psz, size_t N)
|
||||
{
|
||||
ntmbs_t at = const_cast<ntmbs_t>(psz);
|
||||
while (N--)
|
||||
|
@ -206,52 +196,50 @@ namespace tss
|
|||
|
||||
//--BYTES
|
||||
|
||||
template< class CT >
|
||||
size_t strsize( const CT* psz )
|
||||
template<class CT> size_t strsize(const CT* psz)
|
||||
{
|
||||
const CT* at = psz;
|
||||
while ( *at ) at++;
|
||||
while (*at)
|
||||
at++;
|
||||
return (size_t)((char*)at - (char*)psz);
|
||||
}
|
||||
|
||||
template< class CT >
|
||||
size_t strsize( const CT*, size_t N )
|
||||
template<class CT> size_t strsize(const CT*, size_t N)
|
||||
{
|
||||
return N * sizeof(CT);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline size_t strsize( const_ntmbs_t psz ) {
|
||||
template<> inline size_t strsize(const_ntmbs_t psz)
|
||||
{
|
||||
return mbsbytes(psz);
|
||||
}
|
||||
template<>
|
||||
inline size_t strsize( const_ntmbs_t psz, size_t N ) {
|
||||
template<> inline size_t strsize(const_ntmbs_t psz, size_t N)
|
||||
{
|
||||
return mbsbytes(psz, N);
|
||||
}
|
||||
|
||||
|
||||
//--COUNT
|
||||
|
||||
template< class CT >
|
||||
size_t strcount( const CT* psz )
|
||||
template<class CT> size_t strcount(const CT* psz)
|
||||
{
|
||||
const CT* at = psz;
|
||||
while ( *at ) at++;
|
||||
while (*at)
|
||||
at++;
|
||||
return (size_t)(at - psz);
|
||||
}
|
||||
|
||||
template< class CT >
|
||||
size_t strcount( const CT*, size_t N )
|
||||
template<class CT> size_t strcount(const CT*, size_t N)
|
||||
{
|
||||
return N;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline size_t strcount( const_ntmbs_t psz ) {
|
||||
template<> inline size_t strcount(const_ntmbs_t psz)
|
||||
{
|
||||
return mbscount(psz);
|
||||
}
|
||||
template<>
|
||||
inline size_t strcount( const_ntmbs_t psz, size_t N ) {
|
||||
template<> inline size_t strcount(const_ntmbs_t psz, size_t N)
|
||||
{
|
||||
return mbscount(psz, N);
|
||||
}
|
||||
|
||||
|
@ -274,23 +262,21 @@ done with it */
|
|||
|
||||
//--FIND_FIRST: ITER
|
||||
|
||||
template< class InputT, class E >
|
||||
InputT
|
||||
find_first( InputT beg, InputT end, const E& item )
|
||||
template<class InputT, class E> InputT find_first(InputT beg, InputT end, const E& item)
|
||||
{
|
||||
for ( ; beg < end && *beg != item; beg = (InputT)tss::strinc( beg ) );
|
||||
for (; beg < end && *beg != item; beg = (InputT)tss::strinc(beg))
|
||||
;
|
||||
return beg;
|
||||
}
|
||||
|
||||
|
||||
//--FIND_LAST: ITER
|
||||
|
||||
template< class InputT, class E >
|
||||
InputT
|
||||
find_last( InputT beg, InputT end, const E& item )
|
||||
template<class InputT, class E> InputT find_last(InputT beg, InputT end, const E& item)
|
||||
{
|
||||
InputT at = end;
|
||||
for ( ; beg < end ; beg = (InputT)tss::strinc( beg ) );
|
||||
for (; beg < end; beg = (InputT)tss::strinc(beg))
|
||||
;
|
||||
if (*beg == item)
|
||||
at = beg;
|
||||
|
||||
|
@ -300,12 +286,9 @@ done with it */
|
|||
|
||||
//--FIND_FIRST: STRING
|
||||
|
||||
template< class StrT >
|
||||
StrT::size_type
|
||||
find_first( const StrT& sin, StrT::const_reference item )
|
||||
template<class StrT> StrT::size_type find_first(const StrT& sin, StrT::const_reference item)
|
||||
{
|
||||
StrT::const_iterator
|
||||
beg = sin.begin();
|
||||
StrT::const_iterator beg = sin.begin();
|
||||
end = sin.end();
|
||||
|
||||
StrT::size_type N;
|
||||
|
@ -319,17 +302,15 @@ done with it */
|
|||
|
||||
//--FIND_LAST: STRING
|
||||
|
||||
template< class StrT >
|
||||
StrT::size_type
|
||||
find_last( const StrT& sin, StrT::const_reference item )
|
||||
template<class StrT> StrT::size_type find_last(const StrT& sin, StrT::const_reference item)
|
||||
{
|
||||
StrT::size_type N = 0;
|
||||
StrT::size_type nResult = StrT::npos;
|
||||
StrT::const_iterator
|
||||
beg = sin.begin();
|
||||
StrT::const_iterator beg = sin.begin();
|
||||
end = sin.end();
|
||||
|
||||
for ( ; beg < end ; beg = (InputT)tss::strinc( beg ) );
|
||||
for (; beg < end; beg = (InputT)tss::strinc(beg))
|
||||
;
|
||||
if (*beg == item)
|
||||
nResult = N;
|
||||
|
||||
|
@ -339,16 +320,11 @@ done with it */
|
|||
|
||||
//--FIND_FIRST_OF: ITER
|
||||
|
||||
template< class InputT >
|
||||
InputT
|
||||
find_first_of(
|
||||
InputT beg,
|
||||
InputT end,
|
||||
InputT setbeg,
|
||||
InputT setend )
|
||||
template<class InputT> InputT find_first_of(InputT beg, InputT end, InputT setbeg, InputT setend)
|
||||
{
|
||||
InputT at;
|
||||
for ( ; beg < end; beg = (InputT)tss::strinc( beg ) );
|
||||
for (; beg < end; beg = (InputT)tss::strinc(beg))
|
||||
;
|
||||
for (at = setbeg; setbeg < setend; at = (InputT)tss::strinc(at))
|
||||
if (*beg == *at)
|
||||
return beg;
|
||||
|
@ -359,9 +335,7 @@ done with it */
|
|||
|
||||
//--FIND_FIRST_OF: STRING (SAFE!!!)
|
||||
|
||||
template< class StrT >
|
||||
StrT::size_type
|
||||
find_first_of( const StrT& sin, StrT::const_iterator set )
|
||||
template<class StrT> StrT::size_type find_first_of(const StrT& sin, StrT::const_iterator set)
|
||||
{
|
||||
// Point to beg of input
|
||||
StrT::iterator beg = sin.begin();
|
||||
|
@ -380,12 +354,7 @@ done with it */
|
|||
//--FIND_FIRST_OF: STRING (NOT SAFE!!!)
|
||||
|
||||
template<class StrT>
|
||||
StrT::size_type
|
||||
find_first_of(
|
||||
const StrT& sin,
|
||||
StrT::const_iterator set,
|
||||
StrT::size_type nPos,
|
||||
StrT::size_type nCount )
|
||||
StrT::size_type find_first_of(const StrT& sin, StrT::const_iterator set, StrT::size_type nPos, StrT::size_type nCount)
|
||||
{
|
||||
ASSERT( nPos < tss::strcount( sin.begin() );
|
||||
|
||||
|
@ -393,7 +362,8 @@ done with it */
|
|||
{
|
||||
ASSERT(nCount > tss::strcount(set));
|
||||
StrT::const_iterator endset; // Get end of set
|
||||
while ( nCount-- ) endset++;
|
||||
while (nCount--)
|
||||
endset++;
|
||||
|
||||
// Advance to nPos
|
||||
StrT::const_iterator at = tss::strinc(sin.begin(), nPos);
|
||||
|
@ -415,13 +385,11 @@ done with it */
|
|||
//--FIND_LAST_OF: ITER
|
||||
|
||||
template<class InputT1, class InputT2>
|
||||
InputT
|
||||
find_last_of(
|
||||
const InputT1 beg, const InputT1 end,
|
||||
const InputT2 setbeg, const InputT2 setend )
|
||||
InputT find_last_of(const InputT1 beg, const InputT1 end, const InputT2 setbeg, const InputT2 setend)
|
||||
{
|
||||
const InputT1 ans = end;
|
||||
for ( ; beg < end; beg = tss::strinc( beg ) );
|
||||
for (; beg < end; beg = tss::strinc(beg))
|
||||
;
|
||||
for (InputT2 at = setbeg; setbeg != setend; at = tss::strinc(at))
|
||||
if (*beg == *at)
|
||||
ans = beg;
|
||||
|
@ -432,9 +400,7 @@ done with it */
|
|||
|
||||
//--FIND_LAST_OF: STRING (SAFE!!!)
|
||||
|
||||
template< class StrT >
|
||||
StrT::size_type
|
||||
find_last_of( const StrT& sin, StrT::const_iterator set )
|
||||
template<class StrT> StrT::size_type find_last_of(const StrT& sin, StrT::const_iterator set)
|
||||
{
|
||||
StrT::size_type nResult = StrT::npos;
|
||||
StrT::size_type N = 0;
|
||||
|
@ -450,17 +416,11 @@ done with it */
|
|||
|
||||
|
||||
template<class StrT>
|
||||
StrT::size_type
|
||||
find_last_of(
|
||||
const StrT& sin,
|
||||
StrT::const_iterator set,
|
||||
StrT::size_type nStart,
|
||||
StrT::size_type nCount )
|
||||
StrT::size_type find_last_of(const StrT& sin, StrT::const_iterator set, StrT::size_type nStart, StrT::size_type nCount)
|
||||
{
|
||||
if (nCount > 0 && sin.size())
|
||||
{
|
||||
for ( StrT::const_iterator at = sin.begin()
|
||||
+ (nStart < _Len ? nStart : _Len - 1); ; --_U)
|
||||
for (StrT::const_iterator at = sin.begin() + (nStart < _Len ? nStart : _Len - 1);; --_U)
|
||||
if (_Tr::find(set, nCount, *_U) != 0)
|
||||
return (_U - _Ptr);
|
||||
else if (_U == _Ptr)
|
||||
|
@ -479,10 +439,7 @@ done with it */
|
|||
{
|
||||
// Preserves bit values when enlarging a type to a size_t
|
||||
// Good for preventing sign extension
|
||||
template< class E >
|
||||
inline
|
||||
size_t
|
||||
char_to_size( E ch )
|
||||
template<class E> inline size_t char_to_size(E ch)
|
||||
{
|
||||
// if this fails, 'ch' can't be cast to a
|
||||
// size_t and preserve bit values
|
||||
|
@ -498,15 +455,12 @@ done with it */
|
|||
}
|
||||
|
||||
|
||||
inline
|
||||
size_t
|
||||
char_to_size( char ch )
|
||||
inline size_t char_to_size(char ch)
|
||||
{
|
||||
return (size_t)(unsigned char)ch;
|
||||
}
|
||||
}
|
||||
}//tss::
|
||||
} // namespace util
|
||||
} // namespace tss
|
||||
|
||||
|
||||
#endif //__NTMBS_H
|
||||
|
||||
|
|
|
@ -91,12 +91,9 @@
|
|||
|
||||
//--PACKAGE Helpers
|
||||
|
||||
#define TSS_Package( pkg ) \
|
||||
pkg::GetInstance() // Access "the" Package obj
|
||||
|
||||
#define TSS_Dependency( pkg ) \
|
||||
TSS_Package( pkg ) // Declare a Package Depend.
|
||||
#define TSS_Package(pkg) pkg::GetInstance() // Access "the" Package obj
|
||||
|
||||
#define TSS_Dependency(pkg) TSS_Package(pkg) // Declare a Package Depend.
|
||||
|
||||
|
||||
#define TSS_BeginPackage(pkg) \
|
||||
|
@ -107,7 +104,8 @@
|
|||
|
||||
|
||||
#define TSS_EndPackage(pkg) \
|
||||
};
|
||||
} \
|
||||
;
|
||||
|
||||
#define TSS_ImplementPackage(pkg) \
|
||||
pkg& pkg::GetInstance() \
|
||||
|
@ -123,21 +121,19 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//--STRINGTABLE Helperfs
|
||||
|
||||
#define TSS_GetString( pkg, id ) \
|
||||
TSS_Package( pkg ).GetString( id ) // Access the Message String
|
||||
#define TSS_GetString(pkg, id) TSS_Package(pkg).GetString(id) // Access the Message String
|
||||
|
||||
|
||||
#define TSS_DECLARE_STRINGTABLE \
|
||||
public: \
|
||||
Messages::String \
|
||||
GetString( \
|
||||
Messages::ConstKeyRef id ) const { \
|
||||
return m_messages.Get( id ); } \
|
||||
Messages::String GetString(Messages::ConstKeyRef id) const \
|
||||
{ \
|
||||
return m_messages.Get(id); \
|
||||
} \
|
||||
void LoadStrings(); \
|
||||
\
|
||||
private: \
|
||||
Messages m_messages // Decare a Stringtable
|
||||
|
||||
|
@ -145,30 +141,36 @@
|
|||
#ifdef DEBUG
|
||||
# define TSS_BeginStringtable(pkg) \
|
||||
void pkg::LoadStrings() \
|
||||
{ cDebug d( #pkg "::LoadStrings()" ); \
|
||||
{ \
|
||||
cDebug d(#pkg "::LoadStrings()"); \
|
||||
d.TraceDebug("Loading strings for " #pkg " package.\n"); \
|
||||
Messages::Pair astr[] = { // Define a Stringtable
|
||||
#else // DEBUG
|
||||
# define TSS_BeginStringtable(pkg) \
|
||||
void pkg::LoadStrings() \
|
||||
{ Messages::Pair astr[] = { // Define a Stringtable
|
||||
{ \
|
||||
Messages::Pair astr[] = { // Define a Stringtable
|
||||
#endif // DEBUG
|
||||
|
||||
#define TSS_EndStringtable(pkg) \
|
||||
}; m_messages.Put( \
|
||||
astr, astr + countof(astr) ); } // End define Strintable
|
||||
} \
|
||||
; \
|
||||
m_messages.Put(astr, astr + countof(astr)); \
|
||||
} // End define Strintable
|
||||
|
||||
|
||||
#define TSS_StringEntry( id, s ) \
|
||||
Messages::Pair( id, s ) // Stringtable Entry
|
||||
#define TSS_StringEntry(id, s) Messages::Pair(id, s) // Stringtable Entry
|
||||
|
||||
#define TSS_BeginStringIds(pns) \
|
||||
namespace pns { \
|
||||
enum { // Define String IDs
|
||||
namespace pns \
|
||||
{ \
|
||||
enum \
|
||||
{ // Define String IDs
|
||||
|
||||
#define TSS_EndStringIds(pns) \
|
||||
}; } // End define String IDs
|
||||
|
||||
} \
|
||||
; \
|
||||
} // End define String IDs
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
@ -194,11 +196,9 @@
|
|||
//
|
||||
//
|
||||
|
||||
template< class CharT >
|
||||
class cPackageBase_
|
||||
template<class CharT> class cPackageBase_
|
||||
{
|
||||
public:
|
||||
|
||||
typedef cMessages_<int, CharT> Messages;
|
||||
|
||||
void LoadStrings()
|
||||
|
@ -208,4 +208,3 @@ class cPackageBase_
|
|||
|
||||
|
||||
#endif //__PACKAGE_H
|
||||
|
||||
|
|
|
@ -249,7 +249,6 @@
|
|||
# endif
|
||||
|
||||
|
||||
|
||||
/* XXX: COMP may now not resolve, because autoconf may
|
||||
* detect GCC. This is done in the hopes that all
|
||||
* COMP detections, and indeed both OS & COMP detechtions
|
||||
|
@ -293,7 +292,9 @@
|
|||
|
||||
|
||||
// complier detection
|
||||
#define IS_KAI (COMP == COMP_KAI_GCC || COMP == COMP_KAI_SUNPRO || COMP == COMP_KAI_GLIBC || COMP == COMP_KAI_VISUALAGE || COMP == COMP_KAI_HPANSIC || COMP == COMP_KAI_IRIX || COMP == COMP_KAI_OSF1ALPHA)
|
||||
# define IS_KAI \
|
||||
(COMP == COMP_KAI_GCC || COMP == COMP_KAI_SUNPRO || COMP == COMP_KAI_GLIBC || COMP == COMP_KAI_VISUALAGE || \
|
||||
COMP == COMP_KAI_HPANSIC || COMP == COMP_KAI_IRIX || COMP == COMP_KAI_OSF1ALPHA)
|
||||
# define IS_MSVC (COMP == COMP_MSVC)
|
||||
# define IS_SUNPRO (COMP == COMP_SUNPRO)
|
||||
|
||||
|
@ -306,9 +307,12 @@
|
|||
# define IS_KAI_3_4 (IS_KAI && (COMP == COMP_KAI_IRIX || COMP == COMP_KAI_OSF1ALPHA || COMP == COMP_KAI_GLIBC))
|
||||
|
||||
// Used in twlocale
|
||||
#define USE_STD_CPP_LOCALE_WORKAROUND (IS_SUNPRO || (IS_KAI && !IS_KAI_3_4)) // TODO:BAM -- name this something more general.
|
||||
# define USE_STD_CPP_LOCALE_WORKAROUND \
|
||||
(IS_SUNPRO || (IS_KAI && !IS_KAI_3_4)) // TODO:BAM -- name this something more general.
|
||||
# define USE_CLIB_LOCALE IS_KAI || HAVE_GCC
|
||||
#define USES_CLIB_DATE_FUNCTION ( USE_CLIB_LOCALE || IS_SUNPRO || IS_MSVC ) // if we use clib, can't use C++ time_put, and SUNPRO and MSVC add characters
|
||||
# define USES_CLIB_DATE_FUNCTION \
|
||||
(USE_CLIB_LOCALE || IS_SUNPRO || \
|
||||
IS_MSVC) // if we use clib, can't use C++ time_put, and SUNPRO and MSVC add characters
|
||||
//#define USE_CLIB_LOCALE (IS_ALPHA || IS_IRIX || (IS_KAI && !IS_KAI_3_4))
|
||||
|
||||
// Threading API
|
||||
|
@ -375,7 +379,4 @@ typedef unsigned long ptr_size_type; // true for all of our current platforms
|
|||
# endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __PLATFORM_H
|
||||
|
||||
|
|
|
@ -149,4 +149,3 @@ void cRefCountObj::Delete() const
|
|||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,10 @@ public:
|
|||
virtual void AddRef() const;
|
||||
virtual void Release() const;
|
||||
|
||||
int GetRefCount() const { return mRefCount; }
|
||||
int GetRefCount() const
|
||||
{
|
||||
return mRefCount;
|
||||
}
|
||||
// sometimes it is useful to know an object's refrence
|
||||
protected:
|
||||
virtual ~cRefCountObj();
|
||||
|
@ -82,6 +85,7 @@ private:
|
|||
static int objectCounter;
|
||||
static int referenceCounter;
|
||||
friend void TestRefCountObj();
|
||||
|
||||
public:
|
||||
static bool AllRefCountObjDestoryed()
|
||||
{
|
||||
|
@ -91,4 +95,3 @@ public:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "error.h" // for: eInternal
|
||||
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Classes Declared in this module
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -75,19 +74,15 @@ template< class KEY, class CHR > class cMessages_;
|
|||
// INVARIANTS:
|
||||
//
|
||||
//
|
||||
template< class KeyT, class RscT >
|
||||
class cResources_
|
||||
template<class KeyT, class RscT> class cResources_
|
||||
{
|
||||
//--Type Definitions
|
||||
|
||||
private:
|
||||
|
||||
typedef
|
||||
std::map< KeyT, RscT > Table; // Storage Rep
|
||||
typedef std::map<KeyT, RscT> Table; // Storage Rep
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Type definitions
|
||||
|
||||
typedef KeyT Key; // The resource id
|
||||
|
@ -101,11 +96,9 @@ class cResources_
|
|||
typedef typename Table::value_type Pair;
|
||||
|
||||
|
||||
|
||||
//--Interface.
|
||||
|
||||
public:
|
||||
|
||||
// Observers
|
||||
|
||||
ConstValueRef Get(ConstKeyRef) const;
|
||||
|
@ -120,16 +113,13 @@ class cResources_
|
|||
//--Implementation.
|
||||
|
||||
protected:
|
||||
|
||||
static ConstValueRef DefaultValueRef(); // NOTE:
|
||||
|
||||
private:
|
||||
|
||||
Table m_table;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// cMessages_<KEY,CHAR> -- Specialization of Resources_ for message strings
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -168,19 +158,14 @@ class cResources_
|
|||
// must be a valid character type as defined by the STDCPP standard.
|
||||
//
|
||||
//
|
||||
template< class KeyT, class CharT >
|
||||
class cMessages_ : public cResources_< KeyT, const CharT* >
|
||||
template<class KeyT, class CharT> class cMessages_ : public cResources_<KeyT, const CharT*>
|
||||
{
|
||||
//--Type definitions
|
||||
|
||||
protected:
|
||||
|
||||
typedef
|
||||
cResources_<KeyT, const CharT* >
|
||||
Resources;
|
||||
typedef cResources_<KeyT, const CharT*> Resources;
|
||||
|
||||
public:
|
||||
|
||||
typedef std::basic_string<CharT> String;
|
||||
typedef const KeyT& ConstKeyRef;
|
||||
|
||||
|
@ -188,7 +173,6 @@ class cMessages_ : public cResources_< KeyT, const CharT* >
|
|||
//--Interface.
|
||||
|
||||
public:
|
||||
|
||||
String Get(ConstKeyRef) const;
|
||||
std::string GetAnsi(ConstKeyRef) const;
|
||||
#if SUPPORTS_WCHART
|
||||
|
@ -197,7 +181,6 @@ class cMessages_ : public cResources_< KeyT, const CharT* >
|
|||
};
|
||||
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// IMPLEMENTATION: cResources_<KEY_TYPE, RESOURCE_TYPE>
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -208,8 +191,7 @@ class cMessages_ : public cResources_< KeyT, const CharT* >
|
|||
#define Resource_Class cResources_<KeyT, RscT>
|
||||
|
||||
|
||||
Resource_Template
|
||||
void Resource_Class::Put( const Pair* beg, const Pair* end )
|
||||
Resource_Template void Resource_Class::Put(const Pair* beg, const Pair* end)
|
||||
{
|
||||
for (const Pair* at = beg; at != end; ++at)
|
||||
{
|
||||
|
@ -222,9 +204,7 @@ void Resource_Class::Put( const Pair* beg, const Pair* end )
|
|||
}
|
||||
|
||||
// By value allows the user to Resource_table.Put( 6, "Literal" );
|
||||
Resource_Template
|
||||
inline
|
||||
void Resource_Class::Put( ConstKeyRef id, Value sResource )
|
||||
Resource_Template inline void Resource_Class::Put(ConstKeyRef id, Value sResource)
|
||||
{
|
||||
if (m_table.insert(Pair(id, sResource)).second == false)
|
||||
{
|
||||
|
@ -233,9 +213,7 @@ void Resource_Class::Put( ConstKeyRef id, Value sResource )
|
|||
}
|
||||
}
|
||||
|
||||
Resource_Template
|
||||
typename Resource_Class::ConstValueRef
|
||||
Resource_Class::Get( ConstKeyRef id ) const
|
||||
Resource_Template typename Resource_Class::ConstValueRef Resource_Class::Get(ConstKeyRef id) const
|
||||
{
|
||||
typename Table::const_iterator at = m_table.find(id);
|
||||
|
||||
|
@ -253,9 +231,7 @@ Resource_Class::Get( ConstKeyRef id ) const
|
|||
}
|
||||
}
|
||||
|
||||
Resource_Template
|
||||
typename Resource_Class::ConstValueRef
|
||||
Resource_Class::DefaultValueRef()
|
||||
Resource_Template typename Resource_Class::ConstValueRef Resource_Class::DefaultValueRef()
|
||||
{
|
||||
static Value _default;
|
||||
return _default;
|
||||
|
@ -266,7 +242,6 @@ Resource_Class::DefaultValueRef()
|
|||
#undef Resource_Class //Resources_<KeyT,RscT>
|
||||
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// IMPLEMENTATION: cMessages_<KEY_TYPE, RESOURCE_TYPE>
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -277,16 +252,10 @@ Resource_Class::DefaultValueRef()
|
|||
#define Message_Class cMessages_<KeyT, CharT>
|
||||
|
||||
|
||||
Message_Template
|
||||
inline
|
||||
typename Message_Class::String
|
||||
Message_Class::Get( ConstKeyRef id ) const
|
||||
Message_Template inline typename Message_Class::String Message_Class::Get(ConstKeyRef id) const
|
||||
{
|
||||
typename Message_Class::Value msg = Resources::Get(id);
|
||||
return
|
||||
( msg == this->DefaultValueRef() )
|
||||
? String()
|
||||
: String( msg );
|
||||
return (msg == this->DefaultValueRef()) ? String() : String(msg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,25 +268,18 @@ namespace tss
|
|||
/* WARNING:RAD -- Cannot use StringUtil or CodeConvert since
|
||||
these use ErrorMessages and String Resources! */
|
||||
|
||||
inline
|
||||
void
|
||||
ToNTMBS( std::string& nbs, const std::string& src )
|
||||
inline void ToNTMBS(std::string& nbs, const std::string& src)
|
||||
{
|
||||
nbs.assign(src);
|
||||
}
|
||||
|
||||
#if SUPPORTS_WCHART
|
||||
|
||||
inline
|
||||
void
|
||||
ToNTMBS( std::string& nbs, const std::wstring& wcs )
|
||||
inline void ToNTMBS(std::string& nbs, const std::wstring& wcs)
|
||||
{
|
||||
nbs.resize(MB_CUR_MAX * wcs.size());
|
||||
|
||||
size_t nWrote =
|
||||
::wcstombs(
|
||||
const_cast< char * >( nbs.c_str() ),
|
||||
wcs.c_str(), nbs.size() + 1 );
|
||||
size_t nWrote = ::wcstombs(const_cast<char*>(nbs.c_str()), wcs.c_str(), nbs.size() + 1);
|
||||
|
||||
if (nWrote == (size_t)-1)
|
||||
{
|
||||
|
@ -328,23 +290,16 @@ namespace tss
|
|||
nbs.resize(nWrote);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
ToNTWCS( std::wstring& dst, const std::wstring& src )
|
||||
inline void ToNTWCS(std::wstring& dst, const std::wstring& src)
|
||||
{
|
||||
dst.assign(src);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
ToNTWCS( std::wstring& wcs, const std::string& nbs )
|
||||
inline void ToNTWCS(std::wstring& wcs, const std::string& nbs)
|
||||
{
|
||||
wcs.resize(nbs.size());
|
||||
|
||||
size_t nWrote =
|
||||
::mbstowcs(
|
||||
const_cast< wchar_t * >( wcs.c_str() ),
|
||||
nbs.c_str(), wcs.size() + 1 );
|
||||
size_t nWrote = ::mbstowcs(const_cast<wchar_t*>(wcs.c_str()), nbs.c_str(), wcs.size() + 1);
|
||||
|
||||
if (nWrote == (size_t)-1)
|
||||
{
|
||||
|
@ -355,14 +310,11 @@ namespace tss
|
|||
wcs.resize(nWrote);
|
||||
}
|
||||
#endif //SUPPORTS_WCHART
|
||||
}//rsc::
|
||||
}//tss::
|
||||
} // namespace rsc
|
||||
} // namespace tss
|
||||
|
||||
|
||||
Message_Template
|
||||
inline
|
||||
std::string
|
||||
Message_Class::GetAnsi( ConstKeyRef id ) const
|
||||
Message_Template inline std::string Message_Class::GetAnsi(ConstKeyRef id) const
|
||||
{
|
||||
typename Message_Class::Value msg = Resources::Get(id);
|
||||
|
||||
|
@ -381,10 +333,7 @@ Message_Class::GetAnsi( ConstKeyRef id ) const
|
|||
|
||||
#if SUPPORTS_WCHART
|
||||
|
||||
Message_Template
|
||||
inline
|
||||
std::wstring
|
||||
Message_Class::GetWide( ConstKeyRef id ) const
|
||||
Message_Template inline std::wstring Message_Class::GetWide(ConstKeyRef id) const
|
||||
{
|
||||
Value msg = Resources::Get(id);
|
||||
|
||||
|
@ -409,7 +358,6 @@ Message_Class::GetWide( ConstKeyRef id ) const
|
|||
#endif //__RESOURCES_H
|
||||
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// OLD CODE * OLD CODE * OLD CODE * OLD CODE * OLD CODE * OLD CODE * OLD CODE
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -431,18 +379,12 @@ Message_Class::GetWide( ConstKeyRef id ) const
|
|||
# define ENUM_TYPE const int
|
||||
#endif
|
||||
|
||||
template<>
|
||||
class cMessages_<ENUM_TYPE, char> :
|
||||
public cResources_< ENUM_TYPE, const char* >
|
||||
template<> class cMessages_<ENUM_TYPE, char> : public cResources_<ENUM_TYPE, const char*>
|
||||
{
|
||||
protected:
|
||||
|
||||
typedef
|
||||
cResources_< ENUM_TYPE, const char* >
|
||||
Resources;
|
||||
typedef cResources_<ENUM_TYPE, const char*> Resources;
|
||||
|
||||
public:
|
||||
|
||||
typedef std::string String;
|
||||
typedef int ConstKeyRef; // Better than <const int&>
|
||||
|
||||
|
@ -450,9 +392,7 @@ class cMessages_<ENUM_TYPE, char> :
|
|||
String Get(ConstKeyRef id) const
|
||||
{
|
||||
Value msg = Resources::Get(id);
|
||||
return ( msg != DefaultValueRef() )
|
||||
? String( msg )
|
||||
: String();
|
||||
return (msg != DefaultValueRef()) ? String(msg) : String();
|
||||
}
|
||||
|
||||
String GetAnsi(ConstKeyRef id) const
|
||||
|
@ -471,8 +411,7 @@ class cMessages_<ENUM_TYPE, char> :
|
|||
}
|
||||
else
|
||||
{
|
||||
String::size_type
|
||||
N = String::traits_type::length( msg );
|
||||
String::size_type N = String::traits_type::length(msg);
|
||||
|
||||
std::wstring dst(N, 0x00);
|
||||
std::ctype<wchar_t>().widen(msg, msg + N, dst.begin());
|
||||
|
@ -485,18 +424,12 @@ class cMessages_<ENUM_TYPE, char> :
|
|||
|
||||
#if SUPPORTS_WCHART
|
||||
|
||||
template<>
|
||||
class cMessages_<const int, wchar_t> :
|
||||
public cResources_< const int, const wchar_t* >
|
||||
template<> class cMessages_<const int, wchar_t> : public cResources_<const int, const wchar_t*>
|
||||
{
|
||||
protected:
|
||||
|
||||
typedef
|
||||
cResources_<const int, const wchar_t* >
|
||||
Resources;
|
||||
typedef cResources_<const int, const wchar_t*> Resources;
|
||||
|
||||
public:
|
||||
|
||||
typedef std::wstring String;
|
||||
typedef int ConstKeyRef; // Better than <const int&>
|
||||
|
||||
|
@ -520,8 +453,7 @@ class cMessages_<const int, wchar_t> :
|
|||
}
|
||||
else
|
||||
{
|
||||
String::size_type
|
||||
N = String::traits_type::length( msg );
|
||||
String::size_type N = String::traits_type::length(msg);
|
||||
|
||||
std::string dst(N, 0x00);
|
||||
std::ctype<CharT>().narrow(msg, msg + N, '?', dst.begin());
|
||||
|
@ -539,5 +471,3 @@ class cMessages_<const int, wchar_t> :
|
|||
# endif //SUPPORTS_WCHART
|
||||
|
||||
#endif //RAD_OLDCODE
|
||||
|
||||
|
||||
|
|
|
@ -36,8 +36,13 @@
|
|||
#include "serializable.h"
|
||||
|
||||
#if IS_SUNPRO
|
||||
iTypedSerializable::~iTypedSerializable() {}
|
||||
iSerializable::~iSerializable() {}
|
||||
iTyped::~iTyped() {}
|
||||
iTypedSerializable::~iTypedSerializable()
|
||||
{
|
||||
}
|
||||
iSerializable::~iSerializable()
|
||||
{
|
||||
}
|
||||
iTyped::~iTyped()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -82,7 +82,9 @@ public:
|
|||
virtual void Write(iSerializer* pSerializer) const = 0; // throw (eSerializer, eArchive)
|
||||
// objects implement these methods to read and write themselves to a serializer.
|
||||
|
||||
virtual ~iSerializable() {}
|
||||
virtual ~iSerializable()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class iTypedSerializable : public iTyped, public iSerializable
|
||||
|
@ -95,11 +97,22 @@ public:
|
|||
// Return the current version of that this serializable object writes.
|
||||
// As a convention version number should be (major_version << 16) | minor_version.
|
||||
|
||||
static int32 MkVersion(int16 major, int16 minor) { return (int32)(((uint32)major << 16) | (uint32)minor); }
|
||||
static int16 MajorVersion(int32 version) { return (int16)((uint32)version >> 16); }
|
||||
static int16 MinorVersion(int32 version) { return (int16)version; }
|
||||
static int32 MkVersion(int16 major, int16 minor)
|
||||
{
|
||||
return (int32)(((uint32)major << 16) | (uint32)minor);
|
||||
}
|
||||
static int16 MajorVersion(int32 version)
|
||||
{
|
||||
return (int16)((uint32)version >> 16);
|
||||
}
|
||||
static int16 MinorVersion(int32 version)
|
||||
{
|
||||
return (int16)version;
|
||||
}
|
||||
|
||||
virtual ~iTypedSerializable() {}
|
||||
virtual ~iTypedSerializable()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////
|
||||
|
@ -122,4 +135,3 @@ public: \
|
|||
}
|
||||
|
||||
#endif // __SERIALIZABLE_H
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ class iSerializable;
|
|||
////////////////////////////////////////////////////////////
|
||||
TSS_BEGIN_EXCEPTION_NO_CTOR(eSerializer, eError)
|
||||
// TODO: What else to add to this enumeration? Locked File? Temp file?
|
||||
enum DataSourceType {
|
||||
enum DataSourceType
|
||||
{
|
||||
TY_UNDEFINED = 0,
|
||||
TY_FILE,
|
||||
TY_TEMPFILE,
|
||||
|
@ -58,10 +59,9 @@ TSS_BEGIN_EXCEPTION_NO_CTOR( eSerializer, eError )
|
|||
};
|
||||
|
||||
eSerializer(const TSTRING& msg, const TSTRING& dataSource = _T(""), DataSourceType paramType = TY_UNDEFINED)
|
||||
: eError( msg ),
|
||||
mDataSource( dataSource ),
|
||||
mSourceType( paramType )
|
||||
{}
|
||||
: eError(msg), mDataSource(dataSource), mSourceType(paramType)
|
||||
{
|
||||
}
|
||||
|
||||
virtual TSTRING GetMsg() const;
|
||||
|
||||
|
@ -78,8 +78,7 @@ TSS_END_EXCEPTION();
|
|||
#define TSS_SERIALIZER_EXCEPTION(except) \
|
||||
TSS_BEGIN_EXCEPTION_NO_CTOR(except, eSerializer) \
|
||||
except(const TSTRING& msg, const TSTRING& dataSource = _T(""), DataSourceType paramType = TY_UNDEFINED) \
|
||||
: eSerializer( msg, dataSource, paramType ) \
|
||||
{}; \
|
||||
: eSerializer(msg, dataSource, paramType){}; \
|
||||
TSS_END_EXCEPTION()
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -139,7 +138,10 @@ public:
|
|||
virtual void WriteString(const TSTRING& s) = 0;
|
||||
virtual void WriteBlob(const void* pBlob, int count) = 0;
|
||||
|
||||
virtual TSTRING GetFileName() const { return _T(""); }
|
||||
virtual TSTRING GetFileName() const
|
||||
{
|
||||
return _T("");
|
||||
}
|
||||
// derived classes can implement this to return the file name associated with the serializer.
|
||||
// it is only used in error reporting.
|
||||
|
||||
|
@ -156,10 +158,10 @@ public:
|
|||
E_NUMITEMS
|
||||
};
|
||||
|
||||
virtual ~iSerializer() {}
|
||||
virtual ~iSerializer()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -79,11 +79,8 @@ static uint32 util_GetCRC( const cType& type )
|
|||
//#############################################################################
|
||||
// class cSerializerImpl
|
||||
//#############################################################################
|
||||
cSerializerImpl::cSerializerImpl(cArchive& archive, Mode action, const TSTRING& fileName) :
|
||||
mpArchive(&archive),
|
||||
mMode(action),
|
||||
mbInit(false),
|
||||
mFileName( fileName )
|
||||
cSerializerImpl::cSerializerImpl(cArchive& archive, Mode action, const TSTRING& fileName)
|
||||
: mpArchive(&archive), mMode(action), mbInit(false), mFileName(fileName)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -235,7 +232,6 @@ void cSerializerImpl::WriteObjectDynCreate(const iTypedSerializable* pObj)
|
|||
mpArchive->WriteInt32(0);
|
||||
// ... then write the object.
|
||||
pObj->Write(this);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,7 +316,10 @@ iTypedSerializable* cSerializerImpl::ReadObjectDynCreate()
|
|||
else
|
||||
{
|
||||
// already serialized; just return this object.
|
||||
d.TraceDetail("Adding refrence to previously serialized object [%d] %s(%p)\n", objIdx, pObj->GetType().AsString(), pObj);
|
||||
d.TraceDetail("Adding refrence to previously serialized object [%d] %s(%p)\n",
|
||||
objIdx,
|
||||
pObj->GetType().AsString(),
|
||||
pObj);
|
||||
pObj->AddRef();
|
||||
}
|
||||
|
||||
|
@ -495,4 +494,3 @@ TSTRING cSerializerImpl::GetFileName() const
|
|||
{
|
||||
return mFileName;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,11 @@ class cArchive;
|
|||
class cSerializerImpl : public iSerializer
|
||||
{
|
||||
public:
|
||||
enum Mode { S_READ, S_WRITE };
|
||||
enum Mode
|
||||
{
|
||||
S_READ,
|
||||
S_WRITE
|
||||
};
|
||||
cSerializerImpl(cArchive& archive, Mode action, const TSTRING& fileName = _T(""));
|
||||
// fileName is only used for error reporting purposes
|
||||
virtual ~cSerializerImpl();
|
||||
|
@ -128,7 +132,4 @@ private:
|
|||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -35,11 +35,14 @@
|
|||
#include "archive.h"
|
||||
#include "serializer.h"
|
||||
|
||||
namespace {
|
||||
template<class FROM, class TO>
|
||||
int64 CopyImpl(TO* pTo, FROM* pFrom, int64 amt)
|
||||
namespace
|
||||
{
|
||||
enum { BUF_SIZE = 8192 };
|
||||
template<class FROM, class TO> int64 CopyImpl(TO* pTo, FROM* pFrom, int64 amt)
|
||||
{
|
||||
enum
|
||||
{
|
||||
BUF_SIZE = 8192
|
||||
};
|
||||
int8 buf[BUF_SIZE];
|
||||
int64 amtLeft = amt;
|
||||
|
||||
|
@ -58,7 +61,7 @@ int64 CopyImpl(TO* pTo, FROM* pFrom, int64 amt)
|
|||
// return the amount copied ...
|
||||
return (amt - amtLeft);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
int64 cSerializerUtil::Copy(iSerializer* pDest, cArchive* pSrc, int64 amt)
|
||||
|
@ -70,4 +73,3 @@ int64 cSerializerUtil::Copy( cArchive* pDest, iSerializer* pSrc, int64 amt )
|
|||
{
|
||||
return CopyImpl(pDest, pSrc, amt);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,4 +51,3 @@ public:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -69,4 +69,3 @@ void cSerializableWString::Write(iSerializer* pSerializer) const
|
|||
pSerializer->WriteInt32(len);
|
||||
pSerializer->WriteBlob(mString.data(), len);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,4 +81,3 @@ public:
|
|||
typedef cSerializableNString cSerializableTSTRING;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -42,4 +42,3 @@
|
|||
iSerRefCountObj::~iSerRefCountObj()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ public:
|
|||
|
||||
protected:
|
||||
virtual ~iSerRefCountObj();
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////
|
||||
|
@ -83,4 +82,3 @@ public: \
|
|||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -154,4 +154,3 @@ cSerRefCountTableMap::~cSerRefCountTableMap()
|
|||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -89,4 +89,3 @@ public:
|
|||
};
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
|
|
@ -36,5 +36,3 @@
|
|||
//
|
||||
|
||||
#include "stdcore.h"
|
||||
|
||||
|
||||
|
|
|
@ -114,7 +114,6 @@
|
|||
//--Include Platform Specific Declarations
|
||||
|
||||
|
||||
|
||||
//--Include Common Core Declarations
|
||||
|
||||
#include "./tchar.h"
|
||||
|
@ -124,4 +123,3 @@
|
|||
|
||||
|
||||
#endif //__STDCORE_H
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@
|
|||
#include "hashtable.h"
|
||||
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// String Cache
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -103,19 +102,14 @@ public:
|
|||
|
||||
namespace /* Module Local */
|
||||
{
|
||||
typedef
|
||||
cHashTable< wc16_string,
|
||||
TSTRING,
|
||||
tss_hash_key_compare,
|
||||
tss_hash_key_convert >
|
||||
hashtable_t;
|
||||
typedef cHashTable<wc16_string, TSTRING, tss_hash_key_compare, tss_hash_key_convert> hashtable_t;
|
||||
|
||||
hashtable_t& tss_GetHashTable()
|
||||
{
|
||||
static hashtable_t s_table;
|
||||
return s_table;
|
||||
}
|
||||
}//Anon.
|
||||
} // namespace
|
||||
|
||||
|
||||
inline void tss_insert_in_hash(const wc16_string& lhs, const TSTRING& rhs)
|
||||
|
@ -134,8 +128,7 @@ inline bool tss_find_in_hash( const wc16_string& lhs, TSTRING& rhs )
|
|||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/*static*/
|
||||
std::string::const_iterator
|
||||
cStringUtil::Convert( std::string& nbs, const wc16_string& dbs )
|
||||
std::string::const_iterator cStringUtil::Convert(std::string& nbs, const wc16_string& dbs)
|
||||
{
|
||||
#if IS_AROS
|
||||
nbs.resize(dbs.length());
|
||||
|
@ -169,10 +162,8 @@ cStringUtil::Convert( std::string& nbs, const wc16_string& dbs )
|
|||
|
||||
nbs.resize(dbs.size() * MB_CUR_MAX);
|
||||
|
||||
int nWrote =
|
||||
iCodeConverter::GetInstance()->Convert(
|
||||
(char*)nbs.c_str(), nbs.size(),
|
||||
dbs.c_str(), dbs.size() ); // c_str() because must be null terminated
|
||||
int nWrote = iCodeConverter::GetInstance()->Convert(
|
||||
(char*)nbs.c_str(), nbs.size(), dbs.c_str(), dbs.size()); // c_str() because must be null terminated
|
||||
|
||||
d.TraceDetail(_T("iCodeConverter returned %d\n"), nWrote);
|
||||
|
||||
|
@ -189,8 +180,7 @@ cStringUtil::Convert( std::string& nbs, const wc16_string& dbs )
|
|||
}
|
||||
|
||||
/*static*/
|
||||
wc16_string::const_iterator
|
||||
cStringUtil::Convert( wc16_string& dbs, const std::string& nbs )
|
||||
wc16_string::const_iterator cStringUtil::Convert(wc16_string& dbs, const std::string& nbs)
|
||||
{
|
||||
#if IS_AROS
|
||||
dbs.resize(nbs.length());
|
||||
|
@ -206,10 +196,8 @@ cStringUtil::Convert( wc16_string& dbs, const std::string& nbs )
|
|||
|
||||
// d.TraceDebug( "converting <%s>\n", nbs.c_str() );
|
||||
|
||||
int nWrote =
|
||||
iCodeConverter::GetInstance()->Convert(
|
||||
(WCHAR16*)dbs.c_str(), dbs.length(),
|
||||
nbs.c_str(), nbs.size() ); // c_str() because must be null terminated
|
||||
int nWrote = iCodeConverter::GetInstance()->Convert(
|
||||
(WCHAR16*)dbs.c_str(), dbs.length(), nbs.c_str(), nbs.size()); // c_str() because must be null terminated
|
||||
|
||||
d.TraceDetail(_T("iCodeConverter returned %d\n"), nWrote);
|
||||
|
||||
|
@ -237,8 +225,7 @@ cStringUtil::Convert( wc16_string& dbs, const std::string& nbs )
|
|||
#if SUPPORTS_WCHART && WCHAR_REP_IS_UCS2
|
||||
|
||||
/*static*/
|
||||
std::wstring::const_iterator
|
||||
cStringUtil::Convert( std::wstring& wcs, const wc16_string& dbs )
|
||||
std::wstring::const_iterator cStringUtil::Convert(std::wstring& wcs, const wc16_string& dbs)
|
||||
{
|
||||
if (dbs.size() != 0)
|
||||
{
|
||||
|
@ -257,8 +244,7 @@ cStringUtil::Convert( std::wstring& wcs, const wc16_string& dbs )
|
|||
}
|
||||
|
||||
/*static*/
|
||||
wc16_string::const_iterator
|
||||
cStringUtil::Convert( wc16_string& dbs, const std::wstring& wcs )
|
||||
wc16_string::const_iterator cStringUtil::Convert(wc16_string& dbs, const std::wstring& wcs)
|
||||
{
|
||||
if (wcs.size() != 0)
|
||||
{
|
||||
|
@ -272,8 +258,7 @@ cStringUtil::Convert( wc16_string& dbs, const std::wstring& wcs )
|
|||
}
|
||||
|
||||
/*static*/
|
||||
std::wstring::const_iterator
|
||||
cStringUtil::Convert( std::wstring& wcs, const std::string& nbs )
|
||||
std::wstring::const_iterator cStringUtil::Convert(std::wstring& wcs, const std::string& nbs)
|
||||
{
|
||||
if (nbs.size() != 0)
|
||||
{
|
||||
|
@ -292,8 +277,7 @@ cStringUtil::Convert( std::wstring& wcs, const std::string& nbs )
|
|||
}
|
||||
|
||||
/*static*/
|
||||
std::string::const_iterator
|
||||
cStringUtil::Convert( std::string& nbs, const std::wstring& wcs )
|
||||
std::string::const_iterator cStringUtil::Convert(std::string& nbs, const std::wstring& wcs)
|
||||
{
|
||||
if (wcs.size() != 0)
|
||||
{
|
||||
|
@ -324,8 +308,7 @@ cStringUtil::Convert( std::string& nbs, const std::wstring& wcs )
|
|||
// TstrToStr
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string
|
||||
cStringUtil::TstrToStr( const TSTRING& tstr )
|
||||
std::string cStringUtil::TstrToStr(const TSTRING& tstr)
|
||||
{
|
||||
std::string s;
|
||||
cStringUtil::Convert(s, tstr);
|
||||
|
|
|
@ -59,9 +59,7 @@ namespace cStringUtil
|
|||
|
||||
/// Handle Like-Types (xstring to xstring)
|
||||
|
||||
inline
|
||||
const char *
|
||||
Convert( std::string& lhs, const std::string& rhs )
|
||||
inline const char* Convert(std::string& lhs, const std::string& rhs)
|
||||
{
|
||||
lhs = rhs;
|
||||
return lhs.c_str();
|
||||
|
@ -69,33 +67,25 @@ namespace cStringUtil
|
|||
|
||||
/// Specialize Everything Else
|
||||
|
||||
std::string::const_iterator
|
||||
Convert( std::string&, const wc16_string& );
|
||||
std::string::const_iterator Convert(std::string&, const wc16_string&);
|
||||
|
||||
wc16_string::const_iterator
|
||||
Convert( wc16_string&, const std::string& );
|
||||
wc16_string::const_iterator Convert(wc16_string&, const std::string&);
|
||||
|
||||
#if SUPPORTS_WCHART && WCHAR_REP_IS_UCS2
|
||||
|
||||
inline
|
||||
std::wstring::const_iterator
|
||||
Convert( std::wstring& lhs, const std::wstring& rhs )
|
||||
inline std::wstring::const_iterator Convert(std::wstring& lhs, const std::wstring& rhs)
|
||||
{
|
||||
lhs = rhs;
|
||||
return lhs.c_str();
|
||||
}
|
||||
|
||||
std::wstring::const_iterator
|
||||
Convert( std::wstring&, const wc16_string& );
|
||||
std::wstring::const_iterator Convert(std::wstring&, const wc16_string&);
|
||||
|
||||
std::wstring::const_iterator
|
||||
Convert( std::wstring&, const std::string& );
|
||||
std::wstring::const_iterator Convert(std::wstring&, const std::string&);
|
||||
|
||||
std::string::const_iterator
|
||||
Convert( std::string&, const std::wstring& );
|
||||
std::string::const_iterator Convert(std::string&, const std::wstring&);
|
||||
|
||||
wc16_string::const_iterator
|
||||
Convert( wc16_string&, const std::wstring& );
|
||||
wc16_string::const_iterator Convert(wc16_string&, const std::wstring&);
|
||||
|
||||
#endif //SUPPORTS_WCHART
|
||||
|
||||
|
@ -115,16 +105,15 @@ namespace cStringUtil
|
|||
// convert a TSTRING to a wc16_string
|
||||
|
||||
|
||||
template <class IterT>
|
||||
void splitstring(IterT& iter,
|
||||
const TSTRING& str,
|
||||
const TSTRING& delims) {
|
||||
template<class IterT> void splitstring(IterT& iter, const TSTRING& str, const TSTRING& delims)
|
||||
{
|
||||
|
||||
TSTRING::size_type where;
|
||||
TSTRING tmpStr;
|
||||
TSTRING workingString = str;
|
||||
|
||||
while (workingString.length() > 0) {
|
||||
while (workingString.length() > 0)
|
||||
{
|
||||
|
||||
where = workingString.find_first_of(delims, 0);
|
||||
|
||||
|
@ -138,14 +127,11 @@ namespace cStringUtil
|
|||
workingString.erase(0, where + 1);
|
||||
|
||||
iter.push_back(tmpStr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}//cStringUtil::
|
||||
} // namespace cStringUtil
|
||||
|
||||
/*
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -203,4 +189,3 @@ namespace std
|
|||
*/
|
||||
|
||||
#endif //__STRINGUTIL_H
|
||||
|
||||
|
|
|
@ -57,7 +57,9 @@ class cTaskTimer
|
|||
|
||||
|
||||
public:
|
||||
cTaskTimer(const TSTRING& name) : mName(name), mTotalTime(0), mStartTime(0), mNumStarts(0) {}
|
||||
cTaskTimer(const TSTRING& name) : mName(name), mTotalTime(0), mStartTime(0), mNumStarts(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline ~cTaskTimer()
|
||||
{
|
||||
|
@ -86,20 +88,33 @@ public:
|
|||
mStartTime = 0;
|
||||
}
|
||||
|
||||
bool IsRunning() { return (mStartTime != 0); }
|
||||
void Reset() { mNumStarts = mStartTime = mTotalTime = 0; }
|
||||
uint32 GetTotalTime() const { return mTotalTime; }
|
||||
uint32 GetNumTimesStarted() const { return mNumStarts; }
|
||||
const std::string& GetName() const { return mName; }
|
||||
bool IsRunning()
|
||||
{
|
||||
return (mStartTime != 0);
|
||||
}
|
||||
void Reset()
|
||||
{
|
||||
mNumStarts = mStartTime = mTotalTime = 0;
|
||||
}
|
||||
uint32 GetTotalTime() const
|
||||
{
|
||||
return mTotalTime;
|
||||
}
|
||||
uint32 GetNumTimesStarted() const
|
||||
{
|
||||
return mNumStarts;
|
||||
}
|
||||
const std::string& GetName() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
private:
|
||||
TSTRING mName;
|
||||
uint32 mTotalTime;
|
||||
uint32 mStartTime;
|
||||
uint32 mNumStarts;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -126,4 +126,3 @@ typedef std::ifstream TIFSTREAM;
|
|||
# endif
|
||||
|
||||
#endif // __TCHAR_H
|
||||
|
||||
|
|
|
@ -83,5 +83,3 @@ int64 cTimeUtil::GetTime()
|
|||
{
|
||||
return time(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,4 +73,3 @@ public:
|
|||
};
|
||||
|
||||
#endif //__TIMECONVERT_H
|
||||
|
||||
|
|
|
@ -83,8 +83,7 @@ void util_SignalHandler( int sig )
|
|||
|
||||
void tw_psignal(int sig, const TCHAR* str)
|
||||
{
|
||||
const TCHAR *siglist[NSIG] = {
|
||||
_T("Unknown Signal"),
|
||||
const TCHAR* siglist[NSIG] = {_T("Unknown Signal"),
|
||||
_T("Hangup"),
|
||||
_T("Interrupt"),
|
||||
_T("Quit"),
|
||||
|
@ -114,10 +113,7 @@ void tw_psignal(int sig, const TCHAR *str)
|
|||
_T("Stopped (tty input)"),
|
||||
_T("Stopped (tty output)"),
|
||||
_T("Urgent Socket Condition"),
|
||||
_T("File Lock Lost")
|
||||
};
|
||||
_T("File Lock Lost")};
|
||||
|
||||
_ftprintf(stderr, _T("%s %s\n"), str, sig < NSIG ? siglist[sig] : siglist[0]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
#include <bits/signum.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
typedef void (*tw_sighandler_t)(int);
|
||||
}
|
||||
|
||||
|
@ -64,4 +65,3 @@ tw_sighandler_t tw_HandleSignal( int sig );
|
|||
|
||||
|
||||
#endif //__TW_SIGNAL_H
|
||||
|
||||
|
|
|
@ -96,4 +96,3 @@ bool cInterpretInt::InterpretInt( const TSTRING& str, int* pi )
|
|||
|
||||
return fFormatOK;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,11 +86,19 @@ private:
|
|||
//
|
||||
// private functionality
|
||||
//
|
||||
virtual int GetMax() { return LIMIT_MAX; };
|
||||
virtual int GetMin() { return LIMIT_MIN; };
|
||||
virtual int GetMax()
|
||||
{
|
||||
return LIMIT_MAX;
|
||||
};
|
||||
virtual int GetMin()
|
||||
{
|
||||
return LIMIT_MIN;
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~cInterpretInt() {}
|
||||
virtual ~cInterpretInt()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
@ -105,11 +113,19 @@ private:
|
|||
LIMIT_MAX = 1000000
|
||||
};
|
||||
|
||||
virtual int GetMax() { return LIMIT_MAX; };
|
||||
virtual int GetMin() { return LIMIT_MIN; };
|
||||
virtual int GetMax()
|
||||
{
|
||||
return LIMIT_MAX;
|
||||
};
|
||||
virtual int GetMin()
|
||||
{
|
||||
return LIMIT_MIN;
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~cSeverityLimits() {}
|
||||
virtual ~cSeverityLimits()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
@ -124,12 +140,19 @@ private:
|
|||
LIMIT_MAX = 1000000
|
||||
};
|
||||
|
||||
virtual int GetMax() { return LIMIT_MAX; };
|
||||
virtual int GetMin() { return LIMIT_MIN; };
|
||||
virtual int GetMax()
|
||||
{
|
||||
return LIMIT_MAX;
|
||||
};
|
||||
virtual int GetMin()
|
||||
{
|
||||
return LIMIT_MIN;
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~cRecurseDepthLimits() {}
|
||||
virtual ~cRecurseDepthLimits()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif //__TWLIMITS_H
|
||||
|
||||
|
|
|
@ -101,7 +101,6 @@ void cTWLocale::InitGlobalLocale()
|
|||
std::locale::global(l);
|
||||
d.TraceDebug("locale changed to the system default std::locale (C++): <%s>\n", l.name().c_str());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -128,11 +127,9 @@ TSTRING cTWLocale::FormatNumberAsHex( int32 i )
|
|||
}
|
||||
*/
|
||||
|
||||
template< class numT, class CharT >
|
||||
class cFormatNumberUtil
|
||||
template<class numT, class CharT> class cFormatNumberUtil
|
||||
{
|
||||
public:
|
||||
|
||||
// TODO:BAM -- these functions should really maybe take a stringstream that has been
|
||||
// already set up for formatting (basefield, locale, etc.) that way we can merge
|
||||
//. the FormatNumberAsHex function as well
|
||||
|
@ -143,9 +140,7 @@ public:
|
|||
// cFormatNumberUtil::FormatNumber( const std::basic_string< CharT >& s, bool fCStyleFormatting = false )
|
||||
//-----------------------------------------------------------------------------
|
||||
// EFFECTS: Does all actual formatting for FormatNumber methods
|
||||
static
|
||||
numT
|
||||
Format( const std::basic_string< CharT >& s, bool fCStyleFormatting )
|
||||
static numT Format(const std::basic_string<CharT>& s, bool fCStyleFormatting)
|
||||
{
|
||||
static const std::num_get<CharT>* png;
|
||||
std::basic_istringstream<CharT> ss(s);
|
||||
|
@ -155,12 +150,7 @@ public:
|
|||
if (fCStyleFormatting)
|
||||
ss.imbue(std::locale::classic());
|
||||
|
||||
tss::GetFacet( ss.getloc(), png ).get(
|
||||
ss,
|
||||
std::istreambuf_iterator< CharT >(),
|
||||
ss,
|
||||
state,
|
||||
n );
|
||||
tss::GetFacet(ss.getloc(), png).get(ss, std::istreambuf_iterator<CharT>(), ss, state, n);
|
||||
|
||||
|
||||
if ((state & std::ios_base::failbit) != 0)
|
||||
|
@ -175,9 +165,7 @@ public:
|
|||
//-----------------------------------------------------------------------------
|
||||
// EFFECTS: Does all actual formatting for FormatNumber methods
|
||||
//
|
||||
static
|
||||
std::basic_string< CharT >&
|
||||
Format( numT n, std::basic_string< CharT >& sBuf, bool fCStyleFormatting = false )
|
||||
static std::basic_string<CharT>& Format(numT n, std::basic_string<CharT>& sBuf, bool fCStyleFormatting = false)
|
||||
{
|
||||
static const std::num_put<CharT>* pnp;
|
||||
std::basic_ostringstream<CharT> ss;
|
||||
|
@ -315,7 +303,8 @@ TSTRING& util_FormatTimeC( struct tm* ptm, TSTRING& strBuf )
|
|||
TCHAR achTimeBuf[256];
|
||||
|
||||
/* XXX: This should check (#ifdef) for strftime - PH */
|
||||
size_t nbWritten = _tcsftime( achTimeBuf, countof( achTimeBuf ),
|
||||
size_t nbWritten = _tcsftime(achTimeBuf,
|
||||
countof(achTimeBuf),
|
||||
|
||||
#if IS_MSVC // MSVC uses proprietary '#'
|
||||
_T("%#c"),
|
||||
|
@ -331,4 +320,3 @@ TSTRING& util_FormatTimeC( struct tm* ptm, TSTRING& strBuf )
|
|||
|
||||
return strBuf;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,11 +111,10 @@ namespace tss
|
|||
#if USE_STD_CPP_LOCALE_WORKAROUND
|
||||
return std::use_facet(l, pf);
|
||||
#else
|
||||
return std::use_facet< FacetT >( l ); (void)pf; // This is C++ standard
|
||||
return std::use_facet<FacetT>(l);
|
||||
(void)pf; // This is C++ standard
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace tss
|
||||
|
||||
#endif //__TWLOCALE_H
|
||||
|
||||
|
||||
|
|
|
@ -42,4 +42,3 @@ enum Languages
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
const TCHAR* AsString() const;
|
||||
bool operator==(const cType& rhs) const;
|
||||
bool operator!=(const cType& rhs) const;
|
||||
|
||||
private:
|
||||
TSTRING mString;
|
||||
};
|
||||
|
@ -62,7 +63,9 @@ public:
|
|||
// (b) returning that object in their implementation of GetType()
|
||||
// You can use the macros below to simplify the process
|
||||
|
||||
virtual ~iTyped() {}
|
||||
virtual ~iTyped()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////
|
||||
|
@ -116,8 +119,7 @@ const cType& CLASS::GetType() const\
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// inline implementation
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
inline cType::cType(const TCHAR* name) :
|
||||
mString(name)
|
||||
inline cType::cType(const TCHAR* name) : mString(name)
|
||||
{
|
||||
ASSERT(!mString.empty());
|
||||
}
|
||||
|
@ -140,4 +142,3 @@ inline bool cType::operator!=(const cType& rhs) const
|
|||
|
||||
|
||||
#endif //__TYPED_H
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// standard TSS types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -157,27 +156,19 @@ inline int16 SWAPBYTES16(int16 i)
|
|||
{
|
||||
|
||||
return ((uint16)i >> 8) | ((uint16)i << 8);
|
||||
|
||||
}
|
||||
|
||||
inline int32 SWAPBYTES32(int32 i)
|
||||
{
|
||||
return ((uint32)i >> 24) |
|
||||
(((uint32)i & 0x00ff0000) >> 8) |
|
||||
(((uint32)i & 0x0000ff00) << 8) |
|
||||
((uint32)i << 24);
|
||||
return ((uint32)i >> 24) | (((uint32)i & 0x00ff0000) >> 8) | (((uint32)i & 0x0000ff00) << 8) | ((uint32)i << 24);
|
||||
}
|
||||
|
||||
inline int64 SWAPBYTES64(int64 i)
|
||||
{
|
||||
return ((uint64)i >> 56) |
|
||||
(((uint64)i & 0x00ff000000000000ULL) >> 40) |
|
||||
(((uint64)i & 0x0000ff0000000000ULL) >> 24) |
|
||||
(((uint64)i & 0x000000ff00000000ULL) >> 8) |
|
||||
(((uint64)i & 0x00000000ff000000ULL) << 8) |
|
||||
(((uint64)i & 0x0000000000ff0000ULL) << 24) |
|
||||
(((uint64)i & 0x000000000000ff00ULL) << 40) |
|
||||
((uint64)i << 56);
|
||||
return ((uint64)i >> 56) | (((uint64)i & 0x00ff000000000000ULL) >> 40) |
|
||||
(((uint64)i & 0x0000ff0000000000ULL) >> 24) | (((uint64)i & 0x000000ff00000000ULL) >> 8) |
|
||||
(((uint64)i & 0x00000000ff000000ULL) << 8) | (((uint64)i & 0x0000000000ff0000ULL) << 24) |
|
||||
(((uint64)i & 0x000000000000ff00ULL) << 40) | ((uint64)i << 56);
|
||||
}
|
||||
|
||||
|
||||
|
@ -210,7 +201,4 @@ inline int64 SWAPBYTES64(int64 i)
|
|||
# endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __TYPES_H
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
#include <errno.h>
|
||||
|
||||
// TODO: JEB: make this look like eFileError
|
||||
eUnix::eUnix( const TCHAR* szFunctionName, const TCHAR* szObjectName, bool fCallGetLastError)
|
||||
: eError( _T(""))
|
||||
eUnix::eUnix(const TCHAR* szFunctionName, const TCHAR* szObjectName, bool fCallGetLastError) : eError(_T(""))
|
||||
{
|
||||
ASSERT(szFunctionName || szObjectName || fCallGetLastError);
|
||||
//
|
||||
|
|
|
@ -53,6 +53,4 @@ TSS_BEGIN_EXCEPTION( eUnix, eError )
|
|||
TSS_END_EXCEPTION()
|
||||
|
||||
|
||||
|
||||
#endif //__unixexcept_H
|
||||
|
||||
|
|
|
@ -108,7 +108,6 @@
|
|||
#endif //HAVE_SYS_STATFS_H
|
||||
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// DEFINES AND MACROS
|
||||
//=========================================================================
|
||||
|
@ -143,10 +142,12 @@ template< typename T > static inline void util_ZeroMemory( T& obj );
|
|||
//=========================================================================
|
||||
|
||||
cUnixFSServices::cUnixFSServices() : mResolveNames(true)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
cUnixFSServices::~cUnixFSServices()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// *** VIRTUAL FUNCTION CODE ***
|
||||
|
@ -177,7 +178,6 @@ void cUnixFSServices::GetHostID( TSTRING& name ) const
|
|||
#else
|
||||
ret << 999999;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// returns "/" for unix and "\\" for win32
|
||||
|
@ -272,9 +272,12 @@ TSTRING& cUnixFSServices::MakeTempFilename( TSTRING& strName ) const
|
|||
|
||||
#ifdef HAVE_MKSTEMP
|
||||
// create temp filename and check to see if mkstemp failed
|
||||
if ((fd = mkstemp( szTemplate )) == -1) {
|
||||
if ((fd = mkstemp(szTemplate)) == -1)
|
||||
{
|
||||
throw eFSServicesGeneric(strName);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
close(fd);
|
||||
}
|
||||
pchTempFileName = szTemplate;
|
||||
|
@ -284,7 +287,8 @@ TSTRING& cUnixFSServices::MakeTempFilename( TSTRING& strName ) const
|
|||
pchTempFileName = mktemp(szTemplate);
|
||||
|
||||
//check to see if mktemp failed
|
||||
if ( pchTempFileName == NULL || strlen(pchTempFileName) == 0) {
|
||||
if (pchTempFileName == NULL || strlen(pchTempFileName) == 0)
|
||||
{
|
||||
throw eFSServicesGeneric(strName);
|
||||
}
|
||||
#endif
|
||||
|
@ -304,7 +308,8 @@ void cUnixFSServices::GetTempDirName( TSTRING& strName ) const
|
|||
strName = mTempPath;
|
||||
}
|
||||
|
||||
void cUnixFSServices::SetTempDirName(TSTRING& tmpPath) {
|
||||
void cUnixFSServices::SetTempDirName(TSTRING& tmpPath)
|
||||
{
|
||||
|
||||
mTempPath = tmpPath;
|
||||
}
|
||||
|
@ -369,29 +374,40 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const
|
|||
#endif
|
||||
|
||||
// set the file type
|
||||
if(S_ISREG(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_FILE;
|
||||
else if(S_ISDIR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_DIR;
|
||||
else if(S_ISLNK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_SYMLINK;
|
||||
else if(S_ISBLK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_BLOCKDEV;
|
||||
else if(S_ISCHR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_CHARDEV;
|
||||
else if(S_ISFIFO(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_FIFO;
|
||||
if (S_ISREG(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_FILE;
|
||||
else if (S_ISDIR(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_DIR;
|
||||
else if (S_ISLNK(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_SYMLINK;
|
||||
else if (S_ISBLK(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_BLOCKDEV;
|
||||
else if (S_ISCHR(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_CHARDEV;
|
||||
else if (S_ISFIFO(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_FIFO;
|
||||
#ifdef S_ISSOCK
|
||||
else if(S_ISSOCK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_SOCK;
|
||||
else if (S_ISSOCK(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_SOCK;
|
||||
#endif
|
||||
|
||||
#if HAVE_DOOR_CREATE
|
||||
else if(S_ISDOOR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_DOOR;
|
||||
else if (S_ISDOOR(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_DOOR;
|
||||
#endif
|
||||
|
||||
#if HAVE_PORT_CREATE
|
||||
else if(S_ISPORT(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_PORT;
|
||||
else if (S_ISPORT(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_PORT;
|
||||
#endif
|
||||
|
||||
#ifdef S_ISNAM
|
||||
else if(S_ISNAM(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_NAMED;
|
||||
else if (S_ISNAM(statbuf.st_mode))
|
||||
stat.mFileType = cFSStatArgs::TY_NAMED;
|
||||
#endif
|
||||
|
||||
else stat.mFileType = cFSStatArgs::TY_INVALID;
|
||||
else
|
||||
stat.mFileType = cFSStatArgs::TY_INVALID;
|
||||
}
|
||||
|
||||
void cUnixFSServices::GetMachineName(TSTRING& strName) const
|
||||
|
@ -573,7 +589,6 @@ bool cUnixFSServices::GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const
|
|||
}
|
||||
|
||||
|
||||
|
||||
#ifndef S_ISVTX // DOS/DJGPP doesn't have this
|
||||
# define S_ISVTX 0
|
||||
#endif
|
||||
|
@ -990,8 +1005,7 @@ bool util_PathFind( TSTRING& strFullPath, const TSTRING& strFilename )
|
|||
pchTemp++;
|
||||
else
|
||||
fMorePaths = false;
|
||||
}
|
||||
while( !fFoundFile && fMorePaths );
|
||||
} while (!fFoundFile && fMorePaths);
|
||||
}
|
||||
|
||||
return (fFoundFile);
|
||||
|
@ -1142,7 +1156,6 @@ bool util_GetNextPathElement( const TSTRING& strPathC, TSTRING& strElem, int ind
|
|||
// left, then tell the caller that there aren't that many elemnts
|
||||
if (nextSep == TSTRING::npos && i < index)
|
||||
fMoreSeps = false;
|
||||
|
||||
}
|
||||
else
|
||||
fMoreSeps = false;
|
||||
|
@ -1168,11 +1181,7 @@ bool util_TrailingSep( TSTRING& str, bool fLeaveSep )
|
|||
bool fWasSep = false;
|
||||
|
||||
// if there's a trailing sep
|
||||
if(
|
||||
! str.empty()
|
||||
&&
|
||||
str[ str.size() - 1 ] == TW_SLASH
|
||||
)
|
||||
if (!str.empty() && str[str.size() - 1] == TW_SLASH)
|
||||
{
|
||||
if (!fLeaveSep)
|
||||
str.resize(str.size() - 1);
|
||||
|
@ -1198,11 +1207,11 @@ bool util_TrailingSep( TSTRING& str, bool fLeaveSep )
|
|||
void util_RemoveTrailingSeps(TSTRING& str)
|
||||
{
|
||||
while (util_TrailingSep(str, false))
|
||||
{}
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> static inline void util_ZeroMemory(T& obj)
|
||||
{
|
||||
memset(&obj, 0, sizeof(obj));
|
||||
}
|
||||
|
||||
|
|
|
@ -159,10 +159,8 @@ class cUnixFSServices : public iFSServices
|
|||
virtual TSTRING GetErrString() const;
|
||||
|
||||
private:
|
||||
|
||||
TSTRING mTempPath;
|
||||
bool mResolveNames;
|
||||
};
|
||||
|
||||
#endif //__UNIXFSSERVICES_H
|
||||
|
||||
|
|
|
@ -54,7 +54,8 @@
|
|||
// Argument : CmpFuncT less : Comparison function. Must return as 'std::less'.
|
||||
// Will be called as: 'bool less( *FwdIterT, CmpObjT )'.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template< class FwdIterT, class CmpObjT, class CmpFuncT > FwdIterT UpperBound( FwdIterT first, FwdIterT last, const CmpObjT& obj, CmpFuncT less )
|
||||
template<class FwdIterT, class CmpObjT, class CmpFuncT>
|
||||
FwdIterT UpperBound(FwdIterT first, FwdIterT last, const CmpObjT& obj, CmpFuncT less)
|
||||
{
|
||||
// count elements in set
|
||||
int nElemsInSet = 0;
|
||||
|
@ -89,4 +90,3 @@ template< class FwdIterT, class CmpObjT, class CmpFuncT > FwdIterT UpperBound( F
|
|||
}
|
||||
|
||||
#endif // __UPPERBOUND_H
|
||||
|
||||
|
|
|
@ -38,18 +38,15 @@
|
|||
#ifdef TW_OLD_OPENBSD_VARARGS
|
||||
# undef va_start
|
||||
# ifdef __GNUC__
|
||||
# define va_start(ap, last) \
|
||||
((ap) = (va_list)__builtin_next_arg(last))
|
||||
# define va_start(ap, last) ((ap) = (va_list)__builtin_next_arg(last))
|
||||
# else
|
||||
# define va_start(ap, last) \
|
||||
((ap) = (va_list)&(last) + __va_size(last))
|
||||
# define va_start(ap, last) ((ap) = (va_list) & (last) + __va_size(last))
|
||||
# endif
|
||||
#endif // TW_OLD_OPENBSD_VARARGS
|
||||
|
||||
iUserNotify* iUserNotify::mpInstance = 0;
|
||||
|
||||
iUserNotify::iUserNotify(int verboseLevel) :
|
||||
mVerboseLevel(verboseLevel)
|
||||
iUserNotify::iUserNotify(int verboseLevel) : mVerboseLevel(verboseLevel)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -110,5 +107,3 @@ void iUserNotify::Notify(int verboseLevel, const TCHAR* format, ...)
|
|||
HandleNotify(verboseLevel, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -80,12 +80,14 @@ public:
|
|||
|
||||
iUserNotify(int verboseLevel = 0);
|
||||
virtual ~iUserNotify();
|
||||
|
||||
protected:
|
||||
virtual void HandleNotify(int level, const TCHAR* format, va_list& args) = 0;
|
||||
// this is implemented in derived classes to implement the specific type of
|
||||
// notification desired
|
||||
|
||||
int mVerboseLevel;
|
||||
|
||||
private:
|
||||
static iUserNotify* mpInstance;
|
||||
};
|
||||
|
@ -129,4 +131,3 @@ inline void iUserNotify::SetInstance(iUserNotify* pInst)
|
|||
|
||||
|
||||
#endif //__USERNOTIFY_H
|
||||
|
||||
|
|
|
@ -53,4 +53,3 @@ void cUserNotifyStdout::HandleNotify( int level, const TCHAR* format, va_list& a
|
|||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,4 +50,3 @@ public:
|
|||
};
|
||||
|
||||
#endif /* __USERNOTIFYSTDOUT_H */
|
||||
|
||||
|
|
|
@ -167,4 +167,3 @@ void cUserStringMemBased::AddString(int setID, int stringID, TCHAR* string)
|
|||
|
||||
setItr->second->insert(std::pair<int, TCHAR*>(stringID, string));
|
||||
}
|
||||
|
||||
|
|
|
@ -88,4 +88,3 @@ private:
|
|||
# endif /* _MSC_VER */
|
||||
|
||||
#endif // __USERSTRINGMEM_H
|
||||
|
||||
|
|
|
@ -80,13 +80,15 @@ public:
|
|||
|
||||
~wc16_string_impl(); // call Release() to delete
|
||||
private:
|
||||
void operator = (const wc16_string_impl& rhs) { return; } // don't call
|
||||
void operator=(const wc16_string_impl& rhs)
|
||||
{
|
||||
return;
|
||||
} // don't call
|
||||
};
|
||||
|
||||
static WCHAR16 NULL_WCHAR16 = 0;
|
||||
|
||||
wc16_string::wc16_string()
|
||||
: mpData(0)
|
||||
wc16_string::wc16_string() : mpData(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -134,20 +136,17 @@ int wc16_string::compare(const wc16_string& rhs) const
|
|||
return memcmp(c_str(), rhs.c_str(), length() * sizeof(WCHAR16));
|
||||
}
|
||||
|
||||
wc16_string::size_type
|
||||
wc16_string::length() const
|
||||
wc16_string::size_type wc16_string::length() const
|
||||
{
|
||||
return mpData ? mpData->length : 0;
|
||||
}
|
||||
|
||||
wc16_string::size_type
|
||||
wc16_string::size() const
|
||||
wc16_string::size_type wc16_string::size() const
|
||||
{
|
||||
return mpData ? mpData->length : 0;
|
||||
}
|
||||
|
||||
wc16_string::const_iterator
|
||||
wc16_string::c_str() const
|
||||
wc16_string::const_iterator wc16_string::c_str() const
|
||||
{
|
||||
if (mpData == 0)
|
||||
return &NULL_WCHAR16;
|
||||
|
@ -157,35 +156,24 @@ wc16_string::c_str() const
|
|||
return mpData->pString;
|
||||
}
|
||||
|
||||
wc16_string::const_iterator
|
||||
wc16_string::begin() const
|
||||
wc16_string::const_iterator wc16_string::begin() const
|
||||
{
|
||||
return (const_cast<wc16_string*>(this))->begin();
|
||||
}
|
||||
|
||||
wc16_string::iterator
|
||||
wc16_string::begin()
|
||||
wc16_string::iterator wc16_string::begin()
|
||||
{
|
||||
return mpData ? mpData->pString : &NULL_WCHAR16;
|
||||
}
|
||||
|
||||
wc16_string::const_iterator
|
||||
wc16_string::end() const
|
||||
wc16_string::const_iterator wc16_string::end() const
|
||||
{
|
||||
return
|
||||
const_cast< iterator >(
|
||||
mpData
|
||||
? mpData->pString + mpData->length
|
||||
: &NULL_WCHAR16 );
|
||||
return const_cast<iterator>(mpData ? mpData->pString + mpData->length : &NULL_WCHAR16);
|
||||
}
|
||||
|
||||
wc16_string::iterator
|
||||
wc16_string::end()
|
||||
wc16_string::iterator wc16_string::end()
|
||||
{
|
||||
return
|
||||
mpData
|
||||
? mpData->pString + mpData->length
|
||||
: &NULL_WCHAR16;
|
||||
return mpData ? mpData->pString + mpData->length : &NULL_WCHAR16;
|
||||
}
|
||||
|
||||
wc16_string::const_iterator wc16_string::data() const
|
||||
|
@ -339,4 +327,3 @@ void wc16_string_impl::CopyString(const wc16_string_impl& rhs)
|
|||
|
||||
memcpy(this->pString, rhs.pString, newlen * sizeof(WCHAR16));
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ class wc16_string_impl;
|
|||
class wc16_string
|
||||
{
|
||||
public:
|
||||
|
||||
typedef WCHAR16 value_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
|
@ -110,9 +109,7 @@ public:
|
|||
void swapbytes(); // useful to convert to network byte order
|
||||
|
||||
private:
|
||||
|
||||
wc16_string_impl* mpData;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -45,26 +45,43 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// cBlock
|
||||
//-----------------------------------------------------------------------------
|
||||
template <int SIZE>
|
||||
class cBlock
|
||||
template<int SIZE> class cBlock
|
||||
{
|
||||
public:
|
||||
enum { INVALID_NUM = -1 };
|
||||
enum
|
||||
{
|
||||
INVALID_NUM = -1
|
||||
};
|
||||
|
||||
cBlock();
|
||||
|
||||
void SetDirty () { mbDirty = true; }
|
||||
bool IsDirty () const { return mbDirty; }
|
||||
int GetBlockNum () const { return mBlockNum; }
|
||||
int8* GetData() { return mpData; }
|
||||
void SetDirty()
|
||||
{
|
||||
mbDirty = true;
|
||||
}
|
||||
bool IsDirty() const
|
||||
{
|
||||
return mbDirty;
|
||||
}
|
||||
int GetBlockNum() const
|
||||
{
|
||||
return mBlockNum;
|
||||
}
|
||||
int8* GetData()
|
||||
{
|
||||
return mpData;
|
||||
}
|
||||
|
||||
bool AssertValid() const;
|
||||
// this asserts and returns false if the guard bytes have been corrupted
|
||||
bool IsValidAddr(int8* pAddr) const;
|
||||
// returns true if pAddr falls within mpData
|
||||
protected:
|
||||
enum { NUM_GUARD_BLOCKS = 8, // associated with BYTE_ALIGN: see ctor for info
|
||||
GUARD_BLOCK_VAL = 0xAB }; // odd, non-zero value for debugging
|
||||
enum
|
||||
{
|
||||
NUM_GUARD_BLOCKS = 8, // associated with BYTE_ALIGN: see ctor for info
|
||||
GUARD_BLOCK_VAL = 0xAB
|
||||
}; // odd, non-zero value for debugging
|
||||
|
||||
// guardMin and guardMax are used to detect bad writes
|
||||
uint8 mGuardMin[NUM_GUARD_BLOCKS];
|
||||
|
@ -77,10 +94,7 @@ protected:
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ctor
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <int SIZE>
|
||||
inline cBlock<SIZE>::cBlock()
|
||||
: mbDirty (false),
|
||||
mBlockNum (cBlock::INVALID_NUM)
|
||||
template<int SIZE> inline cBlock<SIZE>::cBlock() : mbDirty(false), mBlockNum(cBlock::INVALID_NUM)
|
||||
{
|
||||
// To prevent misaligned memory access, the size of the data and the
|
||||
// number of guard blocks must be a multiple of the byte alignment
|
||||
|
@ -104,17 +118,12 @@ inline cBlock<SIZE>::cBlock()
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ctor
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <int SIZE>
|
||||
inline bool cBlock<SIZE>::AssertValid() const
|
||||
template<int SIZE> inline bool cBlock<SIZE>::AssertValid() const
|
||||
{
|
||||
// determine if guard bites have been accidentally overwritten
|
||||
for (int i = 0; i < NUM_GUARD_BLOCKS; i++)
|
||||
{
|
||||
if(
|
||||
( mGuardMin[i] != (uint8) GUARD_BLOCK_VAL )
|
||||
||
|
||||
( mGuardMax[i] != (uint8) GUARD_BLOCK_VAL )
|
||||
)
|
||||
if ((mGuardMin[i] != (uint8)GUARD_BLOCK_VAL) || (mGuardMax[i] != (uint8)GUARD_BLOCK_VAL))
|
||||
{
|
||||
ASSERT(false);
|
||||
return false;
|
||||
|
@ -124,8 +133,7 @@ inline bool cBlock<SIZE>::AssertValid() const
|
|||
return true;
|
||||
}
|
||||
|
||||
template <int SIZE>
|
||||
inline bool cBlock<SIZE>::IsValidAddr(int8* pAddr) const
|
||||
template<int SIZE> inline bool cBlock<SIZE>::IsValidAddr(int8* pAddr) const
|
||||
{
|
||||
return ((pAddr >= &mpData[0]) && (pAddr <= &mpData[SIZE - 1]));
|
||||
}
|
||||
|
@ -134,17 +142,28 @@ inline bool cBlock<SIZE>::IsValidAddr(int8* pAddr) const
|
|||
//-----------------------------------------------------------------------------
|
||||
// cBlockImpl
|
||||
//-----------------------------------------------------------------------------
|
||||
template <int SIZE>
|
||||
class cBlockImpl : public cBlock<SIZE>
|
||||
template<int SIZE> class cBlockImpl : public cBlock<SIZE>
|
||||
{
|
||||
public:
|
||||
enum { INVALID_NUM = -1 };
|
||||
enum
|
||||
{
|
||||
INVALID_NUM = -1
|
||||
};
|
||||
|
||||
cBlockImpl();
|
||||
|
||||
void SetBlockNum ( int blockNum ) { cBlock<SIZE>::mBlockNum = blockNum; }
|
||||
void SetTimestamp( uint32 timestamp ) { mTimestamp = timestamp; }
|
||||
uint32 GetTimestamp() const { return mTimestamp; }
|
||||
void SetBlockNum(int blockNum)
|
||||
{
|
||||
cBlock<SIZE>::mBlockNum = blockNum;
|
||||
}
|
||||
void SetTimestamp(uint32 timestamp)
|
||||
{
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
uint32 GetTimestamp() const
|
||||
{
|
||||
return mTimestamp;
|
||||
}
|
||||
|
||||
void Write(cBidirArchive& arch); //throw( eArchive )
|
||||
void Read(cBidirArchive& arch, int blockNum = INVALID_NUM); //throw( eArchive )
|
||||
|
@ -156,18 +175,14 @@ protected:
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ctor
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <int SIZE>
|
||||
inline cBlockImpl<SIZE>::cBlockImpl()
|
||||
: cBlock<SIZE> ( ),
|
||||
mTimestamp (0)
|
||||
template<int SIZE> inline cBlockImpl<SIZE>::cBlockImpl() : cBlock<SIZE>(), mTimestamp(0)
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Write
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <int SIZE>
|
||||
inline void cBlockImpl<SIZE>::Write( cBidirArchive& arch ) //throw( eArchive )
|
||||
template<int SIZE> inline void cBlockImpl<SIZE>::Write(cBidirArchive& arch) //throw( eArchive )
|
||||
{
|
||||
ASSERT(mbDirty);
|
||||
ASSERT((mBlockNum >= 0) && (((mBlockNum + 1) * SIZE) <= arch.Length()));
|
||||
|
@ -181,8 +196,7 @@ inline void cBlockImpl<SIZE>::Write( cBidirArchive& arch ) //throw( eArchive )
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Read
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <int SIZE>
|
||||
inline void cBlockImpl<SIZE>::Read( cBidirArchive& arch, int blockNum ) //throw( eArchive )
|
||||
template<int SIZE> inline void cBlockImpl<SIZE>::Read(cBidirArchive& arch, int blockNum) //throw( eArchive )
|
||||
{
|
||||
if (blockNum != INVALID_NUM)
|
||||
cBlock<SIZE>::mBlockNum = blockNum;
|
||||
|
@ -198,4 +212,3 @@ inline void cBlockImpl<SIZE>::Read( cBidirArchive& arch, int blockNum ) //throw(
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -52,11 +52,7 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ctor
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
cBlockFile::cBlockFile()
|
||||
: mNumPages (-1),
|
||||
mNumBlocks (-1),
|
||||
mTimer (0),
|
||||
mpArchive (0)
|
||||
cBlockFile::cBlockFile() : mNumPages(-1), mNumBlocks(-1), mTimer(0), mpArchive(0)
|
||||
{
|
||||
#ifdef _BLOCKFILE_DEBUG
|
||||
|
||||
|
@ -230,7 +226,6 @@ cBlockFile::Block* cBlockFile::GetBlock( int blockNum ) //throw (eArchive)
|
|||
AssertValid();
|
||||
#endif
|
||||
return &(*earliestIter);
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -310,10 +305,14 @@ void cBlockFile::TraceContents(int dl) const
|
|||
int cnt = 0;
|
||||
for (BlockVector::const_iterator i = mvPagedBlocks.begin(); i != mvPagedBlocks.end(); i++, cnt++)
|
||||
{
|
||||
d.Trace( dl, "Page[%d] Block Num=%d Timestamp=%d Dirty=%s\n", cnt, i->GetBlockNum(), i->GetTimestamp(), i->IsDirty() ? "true" : "false");
|
||||
d.Trace(dl,
|
||||
"Page[%d] Block Num=%d Timestamp=%d Dirty=%s\n",
|
||||
cnt,
|
||||
i->GetBlockNum(),
|
||||
i->GetTimestamp(),
|
||||
i->IsDirty() ? "true" : "false");
|
||||
}
|
||||
d.Trace(dl, "-------------------------\n");
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -331,7 +330,11 @@ void cBlockFile::AssertValid() const
|
|||
{
|
||||
cDebug d("cBlockFile::AssertValid");
|
||||
d.Trace(cDebug::D_DEBUG, "FATAL ERROR!!!\n");
|
||||
d.Trace(cDebug::D_DEBUG, "mpArchive->Length() = %d \n\t!= blocksize * numblocks = %d * %d\n", int(mpArchive->Length()), int(GetBlockSize()), int(GetNumBlocks()));
|
||||
d.Trace(cDebug::D_DEBUG,
|
||||
"mpArchive->Length() = %d \n\t!= blocksize * numblocks = %d * %d\n",
|
||||
int(mpArchive->Length()),
|
||||
int(GetBlockSize()),
|
||||
int(GetNumBlocks()));
|
||||
d.Trace(cDebug::D_DEBUG, "now tracing the contents...\n");
|
||||
TraceContents(cDebug::D_DEBUG);
|
||||
}
|
||||
|
@ -346,8 +349,7 @@ void cBlockFile::AssertValid() const
|
|||
// make sure the block number is valid
|
||||
//
|
||||
int blockNum = i->GetBlockNum();
|
||||
ASSERT( (blockNum == cBlock<BLOCK_SIZE>::INVALID_NUM) ||
|
||||
( (blockNum >= 0) && (blockNum < GetNumBlocks()) ) );
|
||||
ASSERT((blockNum == cBlock<BLOCK_SIZE>::INVALID_NUM) || ((blockNum >= 0) && (blockNum < GetNumBlocks())));
|
||||
//
|
||||
// make sure the time stamp is less than or equal to the timer time...
|
||||
//
|
||||
|
@ -359,4 +361,3 @@ void cBlockFile::AssertValid() const
|
|||
}
|
||||
|
||||
#endif //_BLOCKFILE_DEBUG
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue