本文整理汇总了C++中rocket::core::String类的典型用法代码示例。如果您正苦于以下问题:C++ String类的具体用法?C++ String怎么用?C++ String使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReduceRML
// reduces an rml string to a common format so two rml strings can be compared
static Rocket::Core::String ReduceRML( const Rocket::Core::String &rml )
{
Rocket::Core::String ret;
Rocket::Core::String::size_type length = rml.Length();
ret.Reserve( length );
for ( int i = 0; i < length; i++ )
{
if ( rml[ i ] == ' ' || rml[ i ] == '\n' )
{
continue;
}
if ( rml[ i ] == '"' )
{
ret += '\'';
}
else
{
ret += rml[ i ];
}
}
return ret;
}
示例2: ParseDataSource
// Sets up data source and table from a given string.
bool DataSourceListener::ParseDataSource(DataSource*& data_source, Rocket::Core::String& table_name, const Rocket::Core::String& data_source_name)
{
if (data_source_name.Length() == 0)
{
data_source = NULL;
table_name = "";
return false;
}
Rocket::Core::StringList data_source_parts;
Rocket::Core::StringUtilities::ExpandString(data_source_parts, data_source_name, '.');
DataSource* new_data_source = DataSource::GetDataSource(data_source_parts[0].CString());
if (data_source_parts.size() != 2 || !new_data_source)
{
Rocket::Core::Log::Message(Rocket::Core::Log::LT_ERROR, "Bad data source name %s", data_source_name.CString());
data_source = NULL;
table_name = "";
return false;
}
data_source = new_data_source;
table_name = data_source_parts[1];
return true;
}
示例3: M_Menu_Open_Cmd_f_
void UI_Main::M_Menu_Open_Cmd_f_( bool modal ) {
int i;
if( !self ) {
return;
}
if( trap::Cmd_Argc() < 2 ) {
return;
}
Rocket::Core::URL url;
url.SetFileName( trap::Cmd_Argv( 1 ) );
url.SetExtension( "rml" );
for( i = 2; i < trap::Cmd_Argc() - 1; i += 2 ) {
url.SetParameter( trap::Cmd_Argv( i ), trap::Cmd_Argv( i + 1 ) );
}
Rocket::Core::String urlString = url.GetURL();
//Com_Printf( "UI_Main::M_Menu_Open_f %s\n", urlString.CString() );
NavigationStack *nav = self->navigations[UI_CONTEXT_MAIN].front();
if( !nav ) {
return;
}
nav->pushDocument( urlString.CString(), modal );
self->showUI( true );
}
示例4: GetInnerRML
// Gets the markup and content of the element.
void ElementDataGrid::GetInnerRML(Rocket::Core::String& content) const
{
// The only content we have is the columns, and inside them the header elements.
for (size_t i = 0; i < columns.size(); i++)
{
Core::Element* header_element = header->GetChild((int)i);
Rocket::Core::String column_fields;
for (size_t j = 0; j < columns[i].fields.size(); j++)
{
if (j != columns[i].fields.size() - 1)
{
column_fields.Append(",");
}
column_fields.Append(columns[i].fields[j]);
}
Rocket::Core::String width_attribute = header_element->GetAttribute<Rocket::Core::String>("width", "");
content.Append(Rocket::Core::String(column_fields.Length() + 32, "<col fields=\"%s\"", column_fields.CString()));
if (!width_attribute.Empty())
content.Append(Rocket::Core::String(width_attribute.Length() + 32, " width=\"%s\"", width_attribute.CString()));
content.Append(">");
header_element->GetInnerRML(content);
content.Append("</col>");
}
}
示例5: SetAttr
void ElementStyleProxy::SetAttr(const char* _key, const char* value)
{
// Switch underscores to dashes, as the script interface can't use -'s
Rocket::Core::String key = Rocket::Core::String(_key).Replace("_", "-");
element->SetProperty(key.CString(), value);
}
示例6: if
Rocket::Core::FileHandle UI_FileInterface::Open(const Rocket::Core::String & path)
{
int filenum = 0;
int length = -1;
Rocket::Core::URL url( path );
Rocket::Core::String protocol = url.GetProtocol();
// local
if( protocol.Empty() || protocol == "file" ) {
Rocket::Core::String path2( url.GetPathedFileName() );
if( path2[0] == '/' ) {
path2.Erase( 0, 1 );
}
length = trap::FS_FOpenFile( path2.CString(), &filenum, FS_READ );
}
else if( protocol == "http" ) {
// allow blocking download of remote resources
length = trap::FS_FOpenFile( path.CString(), &filenum, FS_READ );
}
if( length == -1 )
return 0;
// cache file length
fileSizeMap[filenum] = length;
// Com_Printf("UI_FileInterface opened %s\n", path2.CString() );
return static_cast<Rocket::Core::FileHandle>( filenum );
}
示例7: LogMessage
bool ShellSystemInterface::LogMessage(Rocket::Core::Log::Type type, const Rocket::Core::String& message) {
#ifdef _WIN32
OutputDebugStringA(message.CString());
OutputDebugStringA("\n");
#endif
printf("[ROCK] %s\n", message.CString());
return true;
}
示例8: PreprocessCode
void ElementDocumentWrapper::PreprocessCode(Rocket::Core::String &code, Rocket::Core::Stream *stream)
{
// Load in the script
Rocket::Core::String buffer;
stream->Read(buffer, stream->Length());
// Strip comments and build up code
code = "";
size_t i = 0;
size_t line_start = 0;
enum ParseState { START, COMMENT, DATA };
ParseState state = START;
while (i < buffer.Length())
{
// Python doesn't like \r's, strip them
if (buffer[i] == '\r')
{
buffer.Erase(i, 1);
// Make sure we get out if there are no characters left
if (i == buffer.Length())
continue;
}
switch (state)
{
case START:
{
// Check for the start of comments or non whitespace data
if (buffer[i] == '#')
state = COMMENT;
else if (!Rocket::Core::StringUtilities::IsWhitespace(buffer[i]))
state = DATA;
}
break;
default:
{
// If we've hit the end of the line, process as required
if (buffer[i] == '\n')
{
if (state == DATA)
code += buffer.Substring(line_start, i - line_start + 1);
state = START;
line_start = i + 1;
}
}
break;
}
i++;
}
}
示例9: DoString
void Interpreter::DoString(const Rocket::Core::String& code, const Rocket::Core::String& name)
{
if(luaL_loadbuffer(_L,code.CString(),code.Length(), name.CString()) != 0)
Report(_L);
else
{
if(lua_pcall(_L,0,0,0) != 0)
Report(_L);
}
}
示例10: GetQuantity
unsigned short UiObjectQuantityPicker::GetQuantity(void) const
{
Rocket::Controls::ElementFormControl* control = reinterpret_cast<Rocket::Controls::ElementFormControl*>(_line_edit);
Rocket::Core::String string = control->GetValue();
std::stringstream stream;
unsigned short amount;
stream << string.CString();
stream >> amount;
return (amount);
}
示例11: GetElementUserData
void* GetElementUserData(Rocket::Core::Element *element, const Rocket::Core::String& key) {
void *result = NULL;
if (element != NULL) {
Rocket::Core::Variant *value = element->GetAttribute(key);
if (value != NULL) {
Rocket::Core::String strval;
value->GetInto(strval);
sscanf(strval.CString(), "%x", &result);
}
}
return result;
}
示例12: processSingleplayerCreate
void MainMenu::processSingleplayerCreate(Rocket::Core::Event& event)
{
const Rocket::Core::String& id = event.GetCurrentElement()->GetId();
if (id == "back") {
m_mainMenuSingleplayerCreate->Hide();
} else if (id == "start") {
Rocket::Core::Element* playerNameInput = m_mainMenuSingleplayerCreate->GetElementById("playerName");
Rocket::Core::String playerName = playerNameInput->GetAttribute("value")->Get<Rocket::Core::String>();
hideSubmenus();
m_client->startSinglePlayer(playerName.CString());
}
}
示例13: ProcessEvent
void FormSignalListener::ProcessEvent(Rocket::Core::Event& event) {
const Rocket::Core::Dictionary *d = event.GetParameters();
UISignalData *data = new UISignalData();
Rocket::Core::String s;
Rocket::Core::Variant *v;
int n;
while (d->Iterate(n, s, v)) {
Rocket::Core::String val = v->Get<Rocket::Core::String>();
data->set(string(s.CString()), string(val.CString()));
}
PyScripting::getInstance()->broadcast(signal_name,{data}, true, true);
}
示例14: message
Rocket::Core::String ElementStyleProxy::GetAttr(const char* _key)
{
// Switch underscores to dashes, as the script interface can't use -'s
Rocket::Core::String key = Rocket::Core::String(_key).Replace("_", "-");
const Property* property = element->GetProperty(key.CString());
if ( !property )
{
Rocket::Core::String message(128, "Invalid style property %s", _key);
PyErr_SetString(PyExc_KeyError, message.CString());
python::throw_error_already_set();
}
return property->ToString();
}
示例15: GetParameter
virtual void GetParameter(const char* parameter, char* buffer, size_t buffer_size ) const
{
Rocket::Core::String strvalue = "";
if( m_Event.GetParameters() )
{
m_Event.GetParameters()->GetInto( parameter, strvalue );
}
#ifdef _WIN32
strcpy_s( buffer, buffer_size, strvalue.CString() );
#else
strncpy( buffer, strvalue.CString(), buffer_size); //not quite the same, but similar safe effect.
#endif
}