本文整理汇总了C++中USStream类的典型用法代码示例。如果您正苦于以下问题:C++ USStream类的具体用法?C++ USStream怎么用?C++ USStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了USStream类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: WriteStream
//----------------------------------------------------------------//
size_t USStream::WriteStream ( USStream& source, size_t size ) {
if ( !( source.GetCaps () & CAN_READ )) return 0;
if ( !( this->GetCaps () & CAN_WRITE )) return 0;
u8 buffer [ LOCAL_BUFFER ];
size_t readSize = 0;
size_t total = 0;
do {
if (( total + LOCAL_BUFFER ) > size ) {
readSize = source.ReadBytes ( buffer, size - total );
}
else {
readSize = source.ReadBytes ( buffer, LOCAL_BUFFER );
}
if ( readSize ) {
total += this->WriteBytes ( buffer, readSize );
}
} while ( readSize == LOCAL_BUFFER );
return total;
}
开发者ID:Inzaghi2012,项目名称:moai-dev,代码行数:28,代码来源:USStream.cpp
示例2: WriteDecls
//----------------------------------------------------------------//
void USLuaSerializer::WriteDecls ( USStream& stream ) {
stream.Print ( "--Declaring Objects\n" );
stream.Print ( "local objects = {\n\n" );
this->WriteTableDecls ( stream );
this->WriteInstanceDecls ( stream );
stream.Print ( "}\n\n" );
}
开发者ID:,项目名称:,代码行数:11,代码来源:
示例3: WriteTableDecls
//----------------------------------------------------------------//
void USLuaSerializer::WriteTableDecls ( USStream& stream ) {
if ( !this->mTableMap.size ()) return;
stream.Print ( "\t--Declaring Tables\n" );
TableMapIt tableIt = this->mTableMap.begin ();
for ( ; tableIt != this->mTableMap.end (); ++tableIt ) {
uintptr tableID = tableIt->first;
stream.Print ( "\t[ 0x%08X ] = {},\n", tableID );
}
stream.Print ( "\n" );
}
开发者ID:,项目名称:,代码行数:15,代码来源:
示例4: WriteTableInitializer
//----------------------------------------------------------------//
u32 USLuaSerializer::WriteTableInitializer ( USStream& stream, USLuaState& state, int idx, cc8* prefix ) {
u32 count = 0;
u32 itr = state.PushTableItr ( idx );
while ( state.TableItrNext ( itr )) {
switch ( lua_type ( state, -2 )) {
case LUA_TSTRING: {
stream.Print ( "\t%s [ \"%s\" ] = ", prefix, lua_tostring ( state, -2 ));
break;
}
case LUA_TNUMBER: {
stream.Print ( "\t%s [ %s ]\t= ", prefix, lua_tostring ( state, -2 ));
break;
}
};
switch ( lua_type ( state, -1 )) {
case LUA_TBOOLEAN: {
int value = lua_toboolean ( state, -1 );
cc8* str = ( value ) ? "true": "false";
stream.Print ( "%s\n", str );
break;
}
case LUA_TTABLE: {
uintptr tableID = ( uintptr )lua_topointer ( state, -1 );
if ( this->mTableMap.contains ( tableID )) {
stream.Print ( "objects [ 0x%08X ]\n", tableID );
}
break;
}
case LUA_TSTRING: {
STLString str = _escapeString ( lua_tostring ( state, -1 ));
stream.Print ( "\"%s\"\n", str.c_str ());
break;
}
case LUA_TNUMBER: {
stream.Print ( "%s\n", lua_tostring ( state, -1 ));
break;
}
case LUA_TUSERDATA: {
USLuaObject* object = state.GetLuaObject < USLuaObject >( -1 );
u32 instanceID = this->GetID ( object );
stream.Print ( "objects [ 0x%08X ]\n", instanceID );
break;
}
case LUA_TLIGHTUSERDATA: {
stream.Print ( "%p,\n", lua_touserdata ( state, -1 ));
break;
}
};
++count;
}
return count;
}
开发者ID:,项目名称:,代码行数:60,代码来源:
示例5: WriteObjectInits
//----------------------------------------------------------------//
void MOAISerializer::WriteObjectInits ( USStream& stream ) {
if ( !this->mPending.size ()) return;
while ( this->mPending.size ()) {
MOAILuaObject* object = this->mPending.front ();
assert ( object );
this->mPending.pop_front ();
u32 id = this->GetID ( object );
stream.Print ( "\t--%s\n", object->TypeName ());
stream.Print ( "\tserializer:initObject (\n" );
MOAILuaClass* type = object->GetLuaClass ();
if ( type->IsSingleton ()) {
stream.Print ( "\t\t%s.get (),\n", object->TypeName ());
}
else {
stream.Print ( "\t\tobjects [ 0x%08X ],\n", id );
}
MOAILuaStateHandle state = MOAILuaRuntime::Get ().State ();
object->PushMemberTable ( state );
stream.Print ( "\t\tobjects [ 0x%08X ],\n", this->AffirmMemberID ( state, -1 ));
state.Pop ( 1 );
// this should fill the table for the class
lua_newtable ( state );
object->SerializeOut ( state, *this );
stream.Print ( "\t\t{" );
if ( this->WriteTable ( stream, state, -1, 3 )) {
stream.Print ( "\t\t}\n" );
}
else {
stream.Print ( "}\n" );
}
state.Pop ( 1 );
stream.Print ( "\t)\n\n" );
}
}
开发者ID:,项目名称:,代码行数:47,代码来源:
示例6: WriteInstanceDecls
//----------------------------------------------------------------//
void USLuaSerializer::WriteInstanceDecls ( USStream& stream ) {
if ( !this->mInstanceMap.size ()) return;
stream.Print ( "\t--Declaring Instances\n" );
InstanceMapIt instanceIt;
instanceIt = this->mInstanceMap.begin ();
for ( ; instanceIt != this->mInstanceMap.end (); ++instanceIt ) {
USLuaObject* object = instanceIt->second;
if ( !object ) continue;
uintptr id = this->GetID ( object );
USLuaClass* type = object->GetLuaClass ();
if ( !type->IsSingleton ()) {
stream.Print ( "\t[ 0x%08X ] = serializer:register ( %s.new (), 0x%08X ),\n", id, object->TypeName (), id );
}
}
stream.Print ( "\n" );
}
开发者ID:,项目名称:,代码行数:22,代码来源:
示例7: WriteObjectDecls
//----------------------------------------------------------------//
void MOAISerializer::WriteObjectDecls ( USStream& stream ) {
if ( !this->mObjectMap.size ()) return;
stream.Print ( "\t--Declaring Instances\n" );
ObjectMapIt objectIt;
objectIt = this->mObjectMap.begin ();
for ( ; objectIt != this->mObjectMap.end (); ++objectIt ) {
MOAILuaObject* object = objectIt->second;
if ( !object ) continue;
uintptr id = this->GetID ( object );
MOAILuaClass* type = object->GetLuaClass ();
if ( !type->IsSingleton ()) {
stream.Print ( "\t[ 0x%08X ] = serializer:registerObjectID ( %s.new (), 0x%08X ),\n", id, object->TypeName (), id );
}
}
stream.Print ( "\n" );
}
开发者ID:,项目名称:,代码行数:22,代码来源:
示例8: DebugTimeStamp
UString DebugTimeStamp()
{
using namespace std::chrono;
USStream ss;
system_clock::time_point now_point = system_clock::now();
std::time_t now_time = system_clock::to_time_t(now_point);
#ifdef VIX_SYS_WINDOWS
tm pTime;
localtime_s(&pTime, &now_time);
char buffer[VIX_BUFSIZE];
asctime_s(buffer, &pTime);
ss << buffer;
#else
ss << asctime(localtime(&now_time));
#endif
return ss.str();
}
开发者ID:Narinyir,项目名称:VixenEngine,代码行数:21,代码来源:vix_debugutil.cpp
示例9: WriteTableInits
//----------------------------------------------------------------//
void USLuaSerializer::WriteTableInits ( USStream& stream ) {
if ( !this->mTableMap.size ()) return;
stream.Print ( "\t--Initializing Tables\n" );
stream.Print ( "\tlocal table\n\n" );
USLuaStateHandle state = USLuaRuntime::Get ().State ();
TableMapIt tableIt = this->mTableMap.begin ();
for ( ; tableIt != this->mTableMap.end (); ++tableIt ) {
uintptr tableID = tableIt->first;
stream.Print ( "\ttable = objects [ 0x%08X ]\n", tableID );
USLuaRef& tableRef = tableIt->second;
state.Push ( tableRef );
this->WriteTableInitializer ( stream, state, -1, "table" );
state.Pop ( 1 );
stream.Print ( "\n" );
}
}
开发者ID:,项目名称:,代码行数:24,代码来源:
示例10: Pipe
//----------------------------------------------------------------//
u32 USStream::Pipe ( USStream& source, u32 size ) {
u8 buffer [ LOCAL_BUFFER ];
u32 readSize = 0;
u32 total = 0;
do {
if (( total + LOCAL_BUFFER ) > size ) {
readSize = source.ReadBytes ( buffer, size - total );
}
else {
readSize = source.ReadBytes ( buffer, LOCAL_BUFFER );
}
if ( readSize ) {
total += this->WriteBytes ( buffer, readSize );
}
} while ( readSize == LOCAL_BUFFER );
return total;
}
开发者ID:Odie,项目名称:moai-beta,代码行数:25,代码来源:USStream.cpp
示例11: OpenCipher
//----------------------------------------------------------------//
void USCipherStream::OpenCipher ( USStream& stream, USCipher& cipher ) {
assert ( &stream != this );
this->Clear ();
this->mStream = &stream;
this->mCipher = &cipher;
this->mPlainBlockSize = cipher.GetPlainBlockSize ();
this->mCryptBlockSize = cipher.GetCryptBlockSize ();
this->mCryptBaseAddr = stream.GetCursor ();
this->mPlaintext = ( u8* )calloc ( 1, this->mPlainBlockSize );
this->mCrypttext = ( u8* )calloc ( 1, this->mCryptBlockSize );
this->mIsDirty = false;
this->mPlainCursor = 0;
this->mBlockID = 0xffffffff;
this->SyncBlock ( true );
}
开发者ID:mobilehub,项目名称:moai-beta,代码行数:24,代码来源:USCipherStream.cpp
示例12: WriteReturnList
//----------------------------------------------------------------//
void MOAISerializer::WriteReturnList ( USStream& stream ) {
if ( !this->mReturnList.size ()) return;
stream.Print ( "\n" );
stream.Print ( "--Returning Tables\n" );
stream.Print ( "return " );
ReturnListIt returnListIt = this->mReturnList.begin ();
for ( ; returnListIt != this->mReturnList.end (); ++returnListIt ) {
if ( returnListIt != this->mReturnList.begin ()) {
stream.Print ( ", " );
}
u32 id = *returnListIt;
stream.Print ( "objects [ 0x%08X ]", id );
}
stream.Print ( "\n" );
}
开发者ID:,项目名称:,代码行数:21,代码来源:
示例13: SerializeToStream
//----------------------------------------------------------------//
void USLuaSerializer::SerializeToStream ( USStream& stream ) {
stream.Print ( "%s\n", this->GetFileMagic ());
stream.Print ( "serializer = ... or %s.new ()\n", this->TypeName ());
stream.Print ( "\n" );
// write the initializer first, in a function
stream.Print ( "local function init ( objects )\n\n" );
this->WriteTableInits ( stream );
this->WriteInstanceInits ( stream );
stream.Print ( "end\n\n" );
// now write the decls
this->WriteDecls ( stream );
// call the initializer
stream.Print ( "init ( objects )\n" );
this->WriteReturnList ( stream );
}
开发者ID:,项目名称:,代码行数:22,代码来源:
示例14: WriteInstanceInits
//----------------------------------------------------------------//
void USLuaSerializer::WriteInstanceInits ( USStream& stream ) {
if ( !this->mPending.size ()) return;
while ( this->mPending.size ()) {
USLuaObject* object = this->mPending.front ();
assert ( object );
this->mPending.pop_front ();
u32 id = this->GetID ( object );
stream.Print ( "\t--%s\n", object->TypeName ());
USLuaClass* type = object->GetLuaClass ();
if ( type->IsSingleton ()) {
stream.Print ( "\tserializer:initInstance ( %s.get (), {", object->TypeName ());
}
else {
stream.Print ( "\tserializer:initInstance ( objects [ 0x%08X ], {", id );
}
USLuaStateHandle state = USLuaRuntime::Get ().State ();
lua_newtable ( state );
// this should push the table for the class
object->SerializeOut ( state, *this );
if ( this->WriteTable ( stream, state, -1, 2 )) {
stream.Print ( "\t})\n" );
}
else {
stream.Print ( "})\n" );
}
stream.Print ( "\n" );
}
}
开发者ID:,项目名称:,代码行数:38,代码来源:
示例15: DumpAsCPPHeader
//----------------------------------------------------------------//
void USHexDump::DumpAsCPPHeader ( USStream& stream, cc8* name, const void* data, size_t size, u32 columns ) {
size_t count;
u8 buffer;
stream.Print ( "#ifndef _%s_H\n", name );
stream.Print ( "#define _%s_H\n", name );
stream.Print ( "\n" );
stream.Print ( "#define %s_SIZE 0x%08X\n", name, ( uint )size );
stream.Print ( "\n" );
stream.Print ( "unsigned char %s [] = {\n\t", name );
for ( count = 0; count < size; count ++ ) {
if ( count ) {
if ( !( count % columns )) {
stream.Print ( "\n\t" );
}
else {
stream.Print ( " " );
}
}
buffer = (( u8* )data )[ count ];
stream.Print ( "0x%02X,", buffer );
};
if ((( count - 1 ) % columns )) {
stream.Print ( "\n" );
}
stream.Print ( "};\n" );
stream.Print ( "\n" );
stream.Print ( "#endif\n" );
}
开发者ID:Inzaghi2012,项目名称:moai-dev,代码行数:36,代码来源:USHexDump.cpp
示例16: _pngFlush
//----------------------------------------------------------------//
static void _pngFlush ( png_structp png ) {
USStream* stream = ( USStream* )png_get_io_ptr ( png );
stream->Flush ();
}
开发者ID:,项目名称:,代码行数:6,代码来源:
示例17: _pngWrite
//----------------------------------------------------------------//
static void _pngWrite ( png_structp png, png_bytep buffer, png_size_t size ) {
USStream* stream = ( USStream* )png_get_io_ptr ( png );
stream->WriteBytes ( buffer, ( u32 )size );
}
开发者ID:,项目名称:,代码行数:6,代码来源:
示例18: WriteTable
//----------------------------------------------------------------//
u32 USLuaSerializer::WriteTable ( USStream& stream, USLuaState& state, int idx, u32 tab ) {
STLString indent;
for ( u32 i = 0; i < tab; ++i ) {
indent.append ( "\t" );
}
u32 count = 0;
u32 itr = state.PushTableItr ( idx );
while ( state.TableItrNext ( itr )) {
if ( count == 0 ) {
stream.Print ( "\n" );
}
switch ( lua_type ( state, -2 )) {
case LUA_TSTRING: {
stream.Print ( "%s[ \"%s\" ] = ", indent.c_str (), lua_tostring ( state, -2 ));
break;
}
case LUA_TNUMBER: {
stream.Print ( "%s[ %s ]\t= ", indent.c_str (), lua_tostring ( state, -2 ));
break;
}
};
switch ( lua_type ( state, -1 )) {
case LUA_TBOOLEAN: {
int value = lua_toboolean ( state, -1 );
cc8* str = ( value ) ? "true": "false";
stream.Print ( "%s,\n", str );
break;
}
case LUA_TTABLE: {
uintptr tableID = ( uintptr )lua_topointer ( state, -1 );
if ( this->mTableMap.contains ( tableID )) {
stream.Print ( "objects [ 0x%08X ],\n", tableID );
}
else {
stream.Print ( "{" );
if ( this->WriteTable ( stream, state, -1, tab + 1 )) {
stream.Print ( "%s},\n", indent.c_str ());
}
else {
stream.Print ( "},\n" );
}
}
break;
}
case LUA_TSTRING: {
STLString str = _escapeString ( lua_tostring ( state, -1 ));
stream.Print ( "\"%s\",\n", str.c_str ());
break;
}
case LUA_TNUMBER: {
stream.Print ( "%s,\n", lua_tostring ( state, -1 ));
break;
}
case LUA_TLIGHTUSERDATA: {
stream.Print ( "%p,\n", lua_touserdata ( state, -1 ));
break;
}
};
++count;
}
return count;
}
开发者ID:,项目名称:,代码行数:74,代码来源:
注:本文中的USStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论