mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-13 18:17:49 -04:00
Fix line endings and tabs
This commit is contained in:
@ -1,16 +1,16 @@
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
set(plStreamLogger_SOURCES
|
||||
plStreamLogger.cpp
|
||||
)
|
||||
|
||||
set(plStreamLogger_HEADERS
|
||||
plStreamLogger.h
|
||||
)
|
||||
|
||||
add_library(plStreamLogger STATIC ${plStreamLogger_SOURCES} ${plStreamLogger_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${plStreamLogger_SOURCES})
|
||||
source_group("Header Files" FILES ${plStreamLogger_HEADERS})
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
set(plStreamLogger_SOURCES
|
||||
plStreamLogger.cpp
|
||||
)
|
||||
|
||||
set(plStreamLogger_HEADERS
|
||||
plStreamLogger.h
|
||||
)
|
||||
|
||||
add_library(plStreamLogger STATIC ${plStreamLogger_SOURCES} ${plStreamLogger_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${plStreamLogger_SOURCES})
|
||||
source_group("Header Files" FILES ${plStreamLogger_HEADERS})
|
||||
|
@ -1,204 +1,204 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plStreamLogger.h"
|
||||
#include "hsExceptions.h"
|
||||
|
||||
#ifdef STREAM_LOGGER
|
||||
|
||||
//
|
||||
// Base Stream Logger
|
||||
//
|
||||
|
||||
void plStreamLogger::LogEntry(plGenericType::Types type, unsigned int size, void* value, const char* desc)
|
||||
{
|
||||
if (fList)
|
||||
{
|
||||
plGenericVar var(desc);
|
||||
var.Value().SetVar(type,size,value);
|
||||
Event e(Event::kValue,size,var);
|
||||
fList->push_back(e);
|
||||
fEntryWaiting = false;
|
||||
}
|
||||
}
|
||||
|
||||
void plStreamLogger::ILogEntryWaiting()
|
||||
{
|
||||
fEntryWaiting = true;
|
||||
}
|
||||
|
||||
bool plStreamLogger::IsLogEntryWaiting()
|
||||
{
|
||||
return fEntryWaiting;
|
||||
}
|
||||
|
||||
//
|
||||
// Read-Only Logging Stream
|
||||
//
|
||||
|
||||
void hsReadOnlyLoggingStream::LogStringString(const char* s)
|
||||
{
|
||||
if (fList)
|
||||
{
|
||||
plGenericVar var;
|
||||
|
||||
var.SetName(s);
|
||||
fList->push_back(Event(Event::kString,0,var));
|
||||
}
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::LogSubStreamStart(const char* desc)
|
||||
{
|
||||
if (fList)
|
||||
{
|
||||
plGenericVar var;
|
||||
if (!fDescStack.empty())
|
||||
{
|
||||
var.SetName(fDescStack.front().c_str());
|
||||
fDescStack.pop_front();
|
||||
}
|
||||
else
|
||||
var.SetName(desc);
|
||||
fList->push_back(Event(Event::kSubStart,0,var));
|
||||
}
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::LogSubStreamEnd()
|
||||
{
|
||||
if (fList)
|
||||
{
|
||||
plGenericVar var;
|
||||
fList->push_back(Event(Event::kSubEnd,0,var));
|
||||
}
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::LogSubStreamPushDesc(const char* desc)
|
||||
{
|
||||
fDescStack.push_back(std::string(desc));
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::Rewind()
|
||||
{
|
||||
hsThrow( "can't rewind a logging stream");
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::FastFwd()
|
||||
{
|
||||
hsThrow( "can't fast forward a logging stream");
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::SetPosition(UInt32 position)
|
||||
{
|
||||
hsThrow( "can't set position on a logging stream");
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::Skip(UInt32 deltaByteCount)
|
||||
{
|
||||
hsReadOnlyStream::Skip(deltaByteCount);
|
||||
if (deltaByteCount > 0 && !IsLogEntryWaiting())
|
||||
{
|
||||
LogEntry(plGenericType::kNone,deltaByteCount,nil,"Unknown Skip");
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 hsReadOnlyLoggingStream::Read(UInt32 byteCount, void * buffer)
|
||||
{
|
||||
UInt32 ret = hsReadOnlyStream::Read(byteCount,buffer);
|
||||
if (ret > 0 && !IsLogEntryWaiting())
|
||||
{
|
||||
LogEntry(plGenericType::kNone,byteCount,nil,"Unknown Read");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void hsReadOnlyLoggingStream::LogSkip(UInt32 deltaByteCount, const char* desc)
|
||||
{
|
||||
ILogEntryWaiting();
|
||||
Skip(deltaByteCount);
|
||||
if (deltaByteCount > 0)
|
||||
{
|
||||
LogEntry(plGenericType::kNone,deltaByteCount,nil,desc);
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 hsReadOnlyLoggingStream::LogRead(UInt32 byteCount, void * buffer, const char* desc)
|
||||
{
|
||||
ILogEntryWaiting();
|
||||
UInt32 ret = Read(byteCount,buffer);
|
||||
if (ret > 0)
|
||||
{
|
||||
LogEntry(plGenericType::kNone,byteCount,nil,desc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
char *hsReadOnlyLoggingStream::LogReadSafeString()
|
||||
{
|
||||
LogSubStreamStart("push me");
|
||||
UInt16 numChars;
|
||||
LogReadSwap(&numChars,"NumChars");
|
||||
|
||||
numChars &= ~0xf000; // XXX: remove when hsStream no longer does this.
|
||||
if (numChars > 0)
|
||||
{
|
||||
char *name = TRACKED_NEW char[numChars+1];
|
||||
ILogEntryWaiting();
|
||||
UInt32 ret = Read(numChars, name);
|
||||
name[numChars] = '\0';
|
||||
if (ret > 0)
|
||||
{
|
||||
LogEntry(plGenericType::kString,ret,name,"Value");
|
||||
}
|
||||
LogSubStreamEnd();
|
||||
return name;
|
||||
}
|
||||
LogSubStreamEnd();
|
||||
return nil;
|
||||
}
|
||||
|
||||
char *hsReadOnlyLoggingStream::LogReadSafeStringLong()
|
||||
{
|
||||
LogSubStreamStart("push me");
|
||||
UInt32 numChars;
|
||||
LogReadSwap(&numChars,"NumChars");
|
||||
if (numChars > 0)
|
||||
{
|
||||
char *name = TRACKED_NEW char[numChars+1];
|
||||
ILogEntryWaiting();
|
||||
UInt32 ret = Read(numChars, name);
|
||||
name[numChars] = '\0';
|
||||
if (ret > 0)
|
||||
{
|
||||
LogEntry(plGenericType::kString,ret,name,"Value");
|
||||
}
|
||||
LogSubStreamEnd();
|
||||
return name;
|
||||
}
|
||||
LogSubStreamEnd();
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plStreamLogger.h"
|
||||
#include "hsExceptions.h"
|
||||
|
||||
#ifdef STREAM_LOGGER
|
||||
|
||||
//
|
||||
// Base Stream Logger
|
||||
//
|
||||
|
||||
void plStreamLogger::LogEntry(plGenericType::Types type, unsigned int size, void* value, const char* desc)
|
||||
{
|
||||
if (fList)
|
||||
{
|
||||
plGenericVar var(desc);
|
||||
var.Value().SetVar(type,size,value);
|
||||
Event e(Event::kValue,size,var);
|
||||
fList->push_back(e);
|
||||
fEntryWaiting = false;
|
||||
}
|
||||
}
|
||||
|
||||
void plStreamLogger::ILogEntryWaiting()
|
||||
{
|
||||
fEntryWaiting = true;
|
||||
}
|
||||
|
||||
bool plStreamLogger::IsLogEntryWaiting()
|
||||
{
|
||||
return fEntryWaiting;
|
||||
}
|
||||
|
||||
//
|
||||
// Read-Only Logging Stream
|
||||
//
|
||||
|
||||
void hsReadOnlyLoggingStream::LogStringString(const char* s)
|
||||
{
|
||||
if (fList)
|
||||
{
|
||||
plGenericVar var;
|
||||
|
||||
var.SetName(s);
|
||||
fList->push_back(Event(Event::kString,0,var));
|
||||
}
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::LogSubStreamStart(const char* desc)
|
||||
{
|
||||
if (fList)
|
||||
{
|
||||
plGenericVar var;
|
||||
if (!fDescStack.empty())
|
||||
{
|
||||
var.SetName(fDescStack.front().c_str());
|
||||
fDescStack.pop_front();
|
||||
}
|
||||
else
|
||||
var.SetName(desc);
|
||||
fList->push_back(Event(Event::kSubStart,0,var));
|
||||
}
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::LogSubStreamEnd()
|
||||
{
|
||||
if (fList)
|
||||
{
|
||||
plGenericVar var;
|
||||
fList->push_back(Event(Event::kSubEnd,0,var));
|
||||
}
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::LogSubStreamPushDesc(const char* desc)
|
||||
{
|
||||
fDescStack.push_back(std::string(desc));
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::Rewind()
|
||||
{
|
||||
hsThrow( "can't rewind a logging stream");
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::FastFwd()
|
||||
{
|
||||
hsThrow( "can't fast forward a logging stream");
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::SetPosition(UInt32 position)
|
||||
{
|
||||
hsThrow( "can't set position on a logging stream");
|
||||
}
|
||||
|
||||
void hsReadOnlyLoggingStream::Skip(UInt32 deltaByteCount)
|
||||
{
|
||||
hsReadOnlyStream::Skip(deltaByteCount);
|
||||
if (deltaByteCount > 0 && !IsLogEntryWaiting())
|
||||
{
|
||||
LogEntry(plGenericType::kNone,deltaByteCount,nil,"Unknown Skip");
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 hsReadOnlyLoggingStream::Read(UInt32 byteCount, void * buffer)
|
||||
{
|
||||
UInt32 ret = hsReadOnlyStream::Read(byteCount,buffer);
|
||||
if (ret > 0 && !IsLogEntryWaiting())
|
||||
{
|
||||
LogEntry(plGenericType::kNone,byteCount,nil,"Unknown Read");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void hsReadOnlyLoggingStream::LogSkip(UInt32 deltaByteCount, const char* desc)
|
||||
{
|
||||
ILogEntryWaiting();
|
||||
Skip(deltaByteCount);
|
||||
if (deltaByteCount > 0)
|
||||
{
|
||||
LogEntry(plGenericType::kNone,deltaByteCount,nil,desc);
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 hsReadOnlyLoggingStream::LogRead(UInt32 byteCount, void * buffer, const char* desc)
|
||||
{
|
||||
ILogEntryWaiting();
|
||||
UInt32 ret = Read(byteCount,buffer);
|
||||
if (ret > 0)
|
||||
{
|
||||
LogEntry(plGenericType::kNone,byteCount,nil,desc);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
char *hsReadOnlyLoggingStream::LogReadSafeString()
|
||||
{
|
||||
LogSubStreamStart("push me");
|
||||
UInt16 numChars;
|
||||
LogReadSwap(&numChars,"NumChars");
|
||||
|
||||
numChars &= ~0xf000; // XXX: remove when hsStream no longer does this.
|
||||
if (numChars > 0)
|
||||
{
|
||||
char *name = TRACKED_NEW char[numChars+1];
|
||||
ILogEntryWaiting();
|
||||
UInt32 ret = Read(numChars, name);
|
||||
name[numChars] = '\0';
|
||||
if (ret > 0)
|
||||
{
|
||||
LogEntry(plGenericType::kString,ret,name,"Value");
|
||||
}
|
||||
LogSubStreamEnd();
|
||||
return name;
|
||||
}
|
||||
LogSubStreamEnd();
|
||||
return nil;
|
||||
}
|
||||
|
||||
char *hsReadOnlyLoggingStream::LogReadSafeStringLong()
|
||||
{
|
||||
LogSubStreamStart("push me");
|
||||
UInt32 numChars;
|
||||
LogReadSwap(&numChars,"NumChars");
|
||||
if (numChars > 0)
|
||||
{
|
||||
char *name = TRACKED_NEW char[numChars+1];
|
||||
ILogEntryWaiting();
|
||||
UInt32 ret = Read(numChars, name);
|
||||
name[numChars] = '\0';
|
||||
if (ret > 0)
|
||||
{
|
||||
LogEntry(plGenericType::kString,ret,name,"Value");
|
||||
}
|
||||
LogSubStreamEnd();
|
||||
return name;
|
||||
}
|
||||
LogSubStreamEnd();
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,143 +1,143 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef PL_STREAM_LOGGER
|
||||
#define PL_STREAM_LOGGER
|
||||
|
||||
#include "hsStream.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "../../NucleusLib/pnNetCommon/plGenericVar.h"
|
||||
|
||||
class plStreamLogger
|
||||
{
|
||||
public:
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
kSubStart,
|
||||
kSubEnd,
|
||||
kValue,
|
||||
kString,
|
||||
};
|
||||
private:
|
||||
Type fType;
|
||||
plGenericVar fVar;
|
||||
unsigned int fSize;
|
||||
public:
|
||||
Event(Type type, unsigned int size, plGenericVar& var) : fType(type), fSize(size), fVar(var) { }
|
||||
Type GetType() { return fType; }
|
||||
const plGenericVar& GetVar() { return fVar; }
|
||||
unsigned int GetSize() { return fSize; }
|
||||
};
|
||||
|
||||
typedef std::list<Event> EventList;
|
||||
typedef std::list<std::string> DescStack;
|
||||
|
||||
#ifdef STREAM_LOGGER
|
||||
protected:
|
||||
|
||||
EventList* fList;
|
||||
bool fEntryWaiting; // don't log an "Unknown" b/c an entry is waiting
|
||||
DescStack fDescStack;
|
||||
|
||||
void ILogEntryWaiting();
|
||||
|
||||
public:
|
||||
plStreamLogger() : fEntryWaiting(false), fList(nil) { }
|
||||
const EventList* GetList() { return fList; }
|
||||
void LogSetList(EventList* el) { fList = el; }
|
||||
|
||||
void LogEntry(plGenericType::Types type, unsigned int size, void* value, const char* desc);
|
||||
bool IsLogEntryWaiting();
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifndef STREAM_LOGGER
|
||||
#define LogSetList(l) LogVoidFunc()
|
||||
#else
|
||||
|
||||
#define LOG_READ_SWAP(type, enumtype) \
|
||||
void LogReadSwap(type* value, const char* desc) \
|
||||
{ ILogEntryWaiting(); ReadSwap(value); LogEntry(plGenericType::enumtype,sizeof(type),value, desc);}
|
||||
|
||||
#define LOG_READ_SWAP_ARRAY(type, enumtype) \
|
||||
void LogReadSwapV(int count, type values[], const char* desc) \
|
||||
{ ILogEntryWaiting(); ReadSwap(count,values); int i; for (i=0; i < count; i++) LogEntry(plGenericType::enumtype,sizeof(type),&(values[i]), desc);}
|
||||
|
||||
class hsReadOnlyLoggingStream : public hsReadOnlyStream, public plStreamLogger
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
void Rewind();
|
||||
void FastFwd();
|
||||
void SetPosition(UInt32 position);
|
||||
|
||||
UInt32 Read(UInt32 byteCount, void * buffer);
|
||||
void Skip(UInt32 deltaByteCount);
|
||||
|
||||
UInt32 LogRead(UInt32 byteCount, void * buffer, const char* desc);
|
||||
char* LogReadSafeString();
|
||||
char* LogReadSafeStringLong();
|
||||
void LogSkip(UInt32 deltaByteCount, const char* desc);
|
||||
void LogStringString(const char* s);
|
||||
void LogSubStreamStart(const char* desc);
|
||||
void LogSubStreamEnd();
|
||||
void LogSubStreamPushDesc(const char* desc);
|
||||
|
||||
LOG_READ_SWAP(bool, kBool)
|
||||
LOG_READ_SWAP(UInt8, kUInt)
|
||||
LOG_READ_SWAP(UInt16, kUInt)
|
||||
LOG_READ_SWAP(UInt32, kUInt)
|
||||
LOG_READ_SWAP_ARRAY(UInt8, kUInt)
|
||||
LOG_READ_SWAP_ARRAY(UInt16, kUInt)
|
||||
LOG_READ_SWAP_ARRAY(UInt32, kUInt)
|
||||
|
||||
LOG_READ_SWAP(Int8, kInt)
|
||||
LOG_READ_SWAP(char, kChar)
|
||||
LOG_READ_SWAP(Int16, kInt)
|
||||
LOG_READ_SWAP(Int32, kInt)
|
||||
LOG_READ_SWAP(int, kInt)
|
||||
LOG_READ_SWAP_ARRAY(Int8, kInt)
|
||||
LOG_READ_SWAP_ARRAY(char, kChar)
|
||||
LOG_READ_SWAP_ARRAY(Int16, kInt)
|
||||
LOG_READ_SWAP_ARRAY(Int32, kInt)
|
||||
LOG_READ_SWAP_ARRAY(int, kInt)
|
||||
|
||||
LOG_READ_SWAP(float, kFloat)
|
||||
LOG_READ_SWAP(double, kDouble)
|
||||
LOG_READ_SWAP_ARRAY(float, kFloat)
|
||||
LOG_READ_SWAP_ARRAY(double, kDouble)
|
||||
|
||||
};
|
||||
|
||||
#endif //STREAM_LOGGER
|
||||
|
||||
#endif //PL_STREAM_LOGGER
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef PL_STREAM_LOGGER
|
||||
#define PL_STREAM_LOGGER
|
||||
|
||||
#include "hsStream.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "../../NucleusLib/pnNetCommon/plGenericVar.h"
|
||||
|
||||
class plStreamLogger
|
||||
{
|
||||
public:
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
kSubStart,
|
||||
kSubEnd,
|
||||
kValue,
|
||||
kString,
|
||||
};
|
||||
private:
|
||||
Type fType;
|
||||
plGenericVar fVar;
|
||||
unsigned int fSize;
|
||||
public:
|
||||
Event(Type type, unsigned int size, plGenericVar& var) : fType(type), fSize(size), fVar(var) { }
|
||||
Type GetType() { return fType; }
|
||||
const plGenericVar& GetVar() { return fVar; }
|
||||
unsigned int GetSize() { return fSize; }
|
||||
};
|
||||
|
||||
typedef std::list<Event> EventList;
|
||||
typedef std::list<std::string> DescStack;
|
||||
|
||||
#ifdef STREAM_LOGGER
|
||||
protected:
|
||||
|
||||
EventList* fList;
|
||||
bool fEntryWaiting; // don't log an "Unknown" b/c an entry is waiting
|
||||
DescStack fDescStack;
|
||||
|
||||
void ILogEntryWaiting();
|
||||
|
||||
public:
|
||||
plStreamLogger() : fEntryWaiting(false), fList(nil) { }
|
||||
const EventList* GetList() { return fList; }
|
||||
void LogSetList(EventList* el) { fList = el; }
|
||||
|
||||
void LogEntry(plGenericType::Types type, unsigned int size, void* value, const char* desc);
|
||||
bool IsLogEntryWaiting();
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#ifndef STREAM_LOGGER
|
||||
#define LogSetList(l) LogVoidFunc()
|
||||
#else
|
||||
|
||||
#define LOG_READ_SWAP(type, enumtype) \
|
||||
void LogReadSwap(type* value, const char* desc) \
|
||||
{ ILogEntryWaiting(); ReadSwap(value); LogEntry(plGenericType::enumtype,sizeof(type),value, desc);}
|
||||
|
||||
#define LOG_READ_SWAP_ARRAY(type, enumtype) \
|
||||
void LogReadSwapV(int count, type values[], const char* desc) \
|
||||
{ ILogEntryWaiting(); ReadSwap(count,values); int i; for (i=0; i < count; i++) LogEntry(plGenericType::enumtype,sizeof(type),&(values[i]), desc);}
|
||||
|
||||
class hsReadOnlyLoggingStream : public hsReadOnlyStream, public plStreamLogger
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
void Rewind();
|
||||
void FastFwd();
|
||||
void SetPosition(UInt32 position);
|
||||
|
||||
UInt32 Read(UInt32 byteCount, void * buffer);
|
||||
void Skip(UInt32 deltaByteCount);
|
||||
|
||||
UInt32 LogRead(UInt32 byteCount, void * buffer, const char* desc);
|
||||
char* LogReadSafeString();
|
||||
char* LogReadSafeStringLong();
|
||||
void LogSkip(UInt32 deltaByteCount, const char* desc);
|
||||
void LogStringString(const char* s);
|
||||
void LogSubStreamStart(const char* desc);
|
||||
void LogSubStreamEnd();
|
||||
void LogSubStreamPushDesc(const char* desc);
|
||||
|
||||
LOG_READ_SWAP(bool, kBool)
|
||||
LOG_READ_SWAP(UInt8, kUInt)
|
||||
LOG_READ_SWAP(UInt16, kUInt)
|
||||
LOG_READ_SWAP(UInt32, kUInt)
|
||||
LOG_READ_SWAP_ARRAY(UInt8, kUInt)
|
||||
LOG_READ_SWAP_ARRAY(UInt16, kUInt)
|
||||
LOG_READ_SWAP_ARRAY(UInt32, kUInt)
|
||||
|
||||
LOG_READ_SWAP(Int8, kInt)
|
||||
LOG_READ_SWAP(char, kChar)
|
||||
LOG_READ_SWAP(Int16, kInt)
|
||||
LOG_READ_SWAP(Int32, kInt)
|
||||
LOG_READ_SWAP(int, kInt)
|
||||
LOG_READ_SWAP_ARRAY(Int8, kInt)
|
||||
LOG_READ_SWAP_ARRAY(char, kChar)
|
||||
LOG_READ_SWAP_ARRAY(Int16, kInt)
|
||||
LOG_READ_SWAP_ARRAY(Int32, kInt)
|
||||
LOG_READ_SWAP_ARRAY(int, kInt)
|
||||
|
||||
LOG_READ_SWAP(float, kFloat)
|
||||
LOG_READ_SWAP(double, kDouble)
|
||||
LOG_READ_SWAP_ARRAY(float, kFloat)
|
||||
LOG_READ_SWAP_ARRAY(double, kDouble)
|
||||
|
||||
};
|
||||
|
||||
#endif //STREAM_LOGGER
|
||||
|
||||
#endif //PL_STREAM_LOGGER
|
||||
|
||||
|
@ -1,25 +1,25 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
Reference in New Issue
Block a user