本文整理汇总了C++中StrBuf::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ StrBuf::Length方法的具体用法?C++ StrBuf::Length怎么用?C++ StrBuf::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrBuf
的用法示例。
在下文中一共展示了StrBuf::Length方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int P4ClientAPI::Except( const char *func, const char *msg )
{
StrBuf m;
StrBuf errors;
StrBuf warnings;
bool terminate = false;
m << "[" << func << "] " << msg;
// Now append any errors and warnings to the text
ui.GetResults().FmtErrors( errors );
ui.GetResults().FmtWarnings( warnings );
if( errors.Length() )
{
m << "\n" << errors;
terminate= true;
}
if( exceptionLevel > 1 && warnings.Length() )
{
m << "\n" << warnings;
terminate= true;
}
if( terminate )
m << "\n\n";
if ( exceptionLevel )
{
luaL_error( L, m.Text() );
return 0;
}
lua_pushnil( L );
if( apiLevel < 68 ) {
lua_pushstring( L, m.Text() );
} else {
// return a list with three elements:
// the string value, the list of errors and list of warnings
// P4Exception will sort out what's what
lua_newtable( L );
lua_pushstring( L, m.Text() );
lua_rawseti( L, -2, 1 );
lua_rawgeti( L, LUA_REGISTRYINDEX, ui.GetResults().GetErrors() );
lua_rawseti( L, -2, 2 );
lua_rawgeti( L, LUA_REGISTRYINDEX, ui.GetResults().GetWarnings() );
lua_rawseti( L, -2, 3 );
}
return 2;
}
示例2: ReadConnectionSettings
static void ReadConnectionSettings( lua_State* L, StrBuf& connection )
{
char* buffer = new char[ connection.Length() + 1 ];
strcpy( buffer, connection.Text() );
lua_createtable( L, 3, 0 );
char* start = buffer;
char* ptr = buffer;
int index = 1;
while ( *ptr ) {
if ( *ptr == ',' ) {
lua_pushlstring( L, start, ptr - start );
lua_rawseti( L, -2, index );
++index;
++ptr;
if ( *ptr == ' ' )
++ptr;
start = ptr;
}
else
++ptr;
}
lua_pushlstring( L, start, ptr - start );
lua_rawseti( L, -2, index );
delete[] buffer;
}
示例3: L
P4ClientAPI::P4ClientAPI( lua_State *L )
: L( L )
, specMgr( L )
, ui( L, &specMgr )
{
debug = 0;
server2 = 0;
depth = 0;
exceptionLevel = 2;
maxResults = 0;
maxScanRows = 0;
maxLockTime = 0;
prog = "unnamed p4lua script";
apiLevel = atoi( P4Tag::l_client );
enviro = new Enviro;
// cb.client = this;
InitFlags();
// Enable form parsing
client.SetProtocol( "specstring", "" );
//
// Load the current working directory, and any P4CONFIG file in place
//
HostEnv henv;
StrBuf cwd;
henv.GetCwd( cwd, enviro );
if( cwd.Length() )
enviro->Config( cwd );
//
// Load the current ticket file. Start with the default, and then
// override it if P4TICKETS is set.
//
const char *t;
henv.GetTicketFile( ticketFile );
if( t = enviro->Get( "P4TICKETS" ) ) {
ticketFile = t;
}
//
// Do the same for P4CHARSET
//
const char *lc;
if( ( lc = enviro->Get( "P4CHARSET" )) ) {
SetCharset(lc);
}
}
示例4:
int
P4ClientApi::Except( const char *func, const char *msg )
{
StrBuf m;
StrBuf errors;
StrBuf warnings;
int terminate = 0;
m << "[" << func << "] " << msg;
// Now append any errors and warnings to the text
ui.GetResults().FmtErrors( errors );
ui.GetResults().FmtWarnings( warnings );
if( errors.Length() )
{
m << "\n" << errors;
terminate++;
}
if( exceptionLevel > 1 && warnings.Length() )
{
m << "\n" << warnings;
terminate++;
}
if( terminate )
m << "\n\n";
if ( exceptionLevel )
{
luaL_error( L, m.Text() );
return 0;
}
lua_pushnil( L );
lua_pushstring( L, m.Text() );
return 2;
}
示例5: L
P4ClientApi::P4ClientApi( lua_State *L )
: L( L )
, specMgr( L )
, ui( L, &specMgr )
, keepAliveRef( LUA_NOREF )
{
initCount = 0;
debug = 0;
server2 = 0;
depth = 0;
exceptionLevel = 2;
maxResults = 0;
maxScanRows = 0;
maxLockTime = 0;
apiLevel = atoi( P4Tag::l_client );
enviro = new Enviro;
prog = "unnamed p4lua script";
cb.client = this;
// Enable form parsing, and set tagged mode on by default
mode |= M_PARSE_FORMS + M_TAGGED ;
client.SetProtocol( "specstring", "" );
//
// Load any P4CONFIG file
//
HostEnv henv;
StrBuf cwd;
henv.GetCwd( cwd, enviro );
if( cwd.Length() )
enviro->Config( cwd );
//
// Load the current ticket file. Start with the default, and then
// override it if P4TICKETS is set.
//
const char *t;
henv.GetTicketFile( ticketFile );
if( t = enviro->Get( "P4TICKETS" ) )
ticketFile = t;
//
// Load the current P4CHARSET if set.
//
if( client.GetCharset().Length() )
SetCharset( client.GetCharset().Text() );
}
示例6: getRepr
void LuaMessage::getRepr()
{
StrBuf a;
StrBuf b;
err.Fmt( a, EF_PLAIN );
b << "[";
b << "Gen:" << err.GetGeneric();
b << "/Sev:" << err.GetSeverity();
b << "]: ";
b << a;
lua_pushlstring( L, b.Text(), b.Length() );
}
示例7: sprintf
static int p4_map_inspect(lua_State* L) {
P4MapMaker* m = p4_checkmap(L, 1);
StrBuf b;
StrBuf tb;
tb.Alloc( 32 );
sprintf( tb.Text(), "%p", (void*) m );
tb.SetLength();
b << "#<P4::Map:" << tb << "> ";
m->Inspect( b );
lua_pushlstring(L, b.Text(), b.Length());
return 1;
}
示例8: getText
void LuaMessage::getText()
{
StrBuf buf;
err.Fmt(buf, EF_PLAIN);
lua_pushlstring( L, buf.Text(), buf.Length() );
}