本文整理汇总了C++中UTF8::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ UTF8::c_str方法的具体用法?C++ UTF8::c_str怎么用?C++ UTF8::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::c_str方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
int FPID::Parse( const UTF8& aId )
{
clear();
size_t cnt = aId.length() + 1;
char tmp[cnt]; // C string for speed
std::strcpy( tmp, aId.c_str() );
const char* rev = EndsWithRev( tmp, tmp+aId.length(), '/' );
size_t revNdx;
size_t partNdx;
int offset;
//=====<revision>=========================================
if( rev )
{
revNdx = rev - aId.c_str();
// no need to check revision, EndsWithRev did that.
revision = aId.substr( revNdx );
--revNdx; // back up to omit the '/' which precedes the rev
}
else
{
revNdx = aId.size();
}
//=====<nickname>==========================================
if( ( partNdx = aId.find( ':' ) ) != aId.npos )
{
offset = SetLibNickname( aId.substr( 0, partNdx ) );
if( offset > -1 )
{
return offset;
}
++partNdx; // skip ':'
}
else
{
partNdx = 0;
}
//=====<footprint name>====================================
if( partNdx >= revNdx )
return partNdx;
SetFootprintName( aId.substr( partNdx, revNdx ) );
return -1;
}
示例2: Format
UTF8 FPID::Format( const UTF8& aLogicalLib, const UTF8& aFootprintName,
const UTF8& aRevision )
throw( PARSE_ERROR )
{
UTF8 ret;
int offset;
if( aLogicalLib.size() )
{
offset = okLogical( aLogicalLib );
if( offset != -1 )
{
THROW_PARSE_ERROR( _( "Illegal character found in logical library name" ),
wxString::FromUTF8( aLogicalLib.c_str() ),
aLogicalLib.c_str(),
0,
offset );
}
ret += aLogicalLib;
ret += ':';
}
if( aRevision.size() )
{
offset = okRevision( aRevision );
if( offset != -1 )
{
THROW_PARSE_ERROR( _( "Illegal character found in revision" ),
wxString::FromUTF8( aRevision.c_str() ),
aRevision.c_str(),
0,
offset );
}
ret += '/';
ret += aRevision;
}
return ret;
}
示例3: Parse
int FPID::Parse( const UTF8& aId )
{
clear();
const char* buffer = aId.c_str();
const char* rev = EndsWithRev( buffer, buffer+aId.length(), '/' );
size_t revNdx;
size_t partNdx;
int offset;
//=====<revision>=========================================
// in a FPID like discret:R3/rev4
if( rev )
{
revNdx = rev - buffer;
// no need to check revision, EndsWithRev did that.
revision = aId.substr( revNdx );
--revNdx; // back up to omit the '/' which precedes the rev
}
else
{
revNdx = aId.size();
}
//=====<nickname>==========================================
if( ( partNdx = aId.find( ':' ) ) != aId.npos )
{
offset = SetLibNickname( aId.substr( 0, partNdx ) );
if( offset > -1 )
{
return offset;
}
++partNdx; // skip ':'
}
else
{
partNdx = 0;
}
//=====<footprint name>====================================
if( partNdx >= revNdx )
return partNdx; // Error: no footprint name.
// Be sure the footprint name is valid.
// Some chars can be found in board file (in old board files
// or converted files from an other EDA tool
std::string fpname = aId.substr( partNdx, revNdx-partNdx );
ReplaceIllegalFileNameChars( &fpname, '_' );
SetFootprintName( UTF8( fpname ) );
return -1;
}
示例4: main
int main()
{
std::string str = "input";
UTF8 u0 = L"wide string";
UTF8 u1 = "initial";
wxString wx = wxT( "input2" );
printf( "u0:'%s'\n", u0.c_str() );
printf( "u1:'%s'\n", u1.c_str() );
u1 = str;
wxString wx2 = u1;
// force a std::string into a UTF8, then into a wxString, then copy construct:
wxString wx3 = (UTF8&) u1;
UTF8 u2 = wx2;
u2 += 'X';
printf( "u2:'%s'\n", u2.c_str() );
// key accomplishments here:
// 1) passing a UTF8 to a function which normally takes a wxString.
// 2) return a wxString back into a UTF8.
UTF8 result = wxFunctionTaking_wxString( u2 );
printf( "result:'%s'\n", result.c_str() );
// test the unicode iterator:
for( UTF8::uni_iter it = u2.ubegin(); it < u2.uend(); )
{
// test post-increment:
printf( " _%02x_", *it++ );
}
printf( "\n" );
UTF8::uni_iter it = u2.ubegin();
UTF8::uni_iter it2 = it++;
printf( "post_inc:'%c' should be 'i'\n", *it2 );
it2 = ++it;
printf( "pre_inc:'%c' should be 'p'\n", *it2 );
printf( "u[1]:'%c' should be 'n'\n", u2[1] );
return 0;
}
示例5: throw
FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
{
UTF8 id = aId;
int offset = Parse( id );
if( offset != -1 )
{
THROW_PARSE_ERROR( _( "Illegal character found in FPID string" ),
aId,
id.c_str(),
0,
offset );
}
}
示例6: callee
void callee( const wxString& aString )
{
UTF8 arg = aString;
printf( "%s: '%s'\n", __func__, arg.c_str() );
}