本文整理汇总了C++中USStream::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ USStream::Print方法的具体用法?C++ USStream::Print怎么用?C++ USStream::Print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USStream
的用法示例。
在下文中一共展示了USStream::Print方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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" );
}
示例2: 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" );
}
示例3: 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;
}
示例4: 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" );
}
}
示例5: 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" );
}
示例6: 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" );
}
示例7: 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" );
}
}
示例8: 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" );
}
示例9: 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 );
}
示例10: 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" );
}
}
示例11: 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;
}
示例12: 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" );
}