本文整理汇总了C++中string::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ string::Length方法的具体用法?C++ string::Length怎么用?C++ string::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string
的用法示例。
在下文中一共展示了string::Length方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawTexture
/* SectorInfoOverlay::drawTexture
* Draws a texture box with name underneath for [texture]
*******************************************************************/
void SectorInfoOverlay::drawTexture(float alpha, int x, int y, string texture, string pos)
{
double scale = (gl_font_size / 12.0);
int tex_box_size = 80 * scale;
int line_height = 16 * scale;
// Get colours
rgba_t col_bg = ColourConfiguration::getColour("map_overlay_background");
rgba_t col_fg = ColourConfiguration::getColour("map_overlay_foreground");
col_fg.a = col_fg.a*alpha;
// Get texture
GLTexture* tex = MapEditor::textureManager().getFlat(
texture,
Game::configuration().featureSupported(Game::Feature::MixTexFlats)
);
// Valid texture
if (texture != "-" && tex != &(GLTexture::missingTex()))
{
// Draw background
glEnable(GL_TEXTURE_2D);
OpenGL::setColour(255, 255, 255, 255*alpha, 0);
glPushMatrix();
glTranslated(x, y - tex_box_size - line_height, 0);
GLTexture::bgTex().draw2dTiled(tex_box_size, tex_box_size);
glPopMatrix();
// Draw texture
OpenGL::setColour(255, 255, 255, 255*alpha, 0);
Drawing::drawTextureWithin(tex, x, y - tex_box_size - line_height, x + tex_box_size, y - line_height, 0);
glDisable(GL_TEXTURE_2D);
// Draw outline
OpenGL::setColour(col_fg.r, col_fg.g, col_fg.b, 255*alpha, 0);
glDisable(GL_LINE_SMOOTH);
Drawing::drawRect(x, y - tex_box_size - line_height, x + tex_box_size, y - line_height);
}
// Unknown texture
else if (tex == &(GLTexture::missingTex()))
{
// Draw unknown icon
GLTexture* icon = MapEditor::textureManager().getEditorImage("thing/unknown");
glEnable(GL_TEXTURE_2D);
OpenGL::setColour(180, 0, 0, 255*alpha, 0);
Drawing::drawTextureWithin(icon, x, y - tex_box_size - line_height, x + tex_box_size, y - line_height, 0, 0.15);
// Set colour to red (for text)
col_fg = col_fg.ampf(1.0f, 0.0f, 0.0f, 1.0f);
}
// Draw texture name
if (texture.Length() > 8)
texture = texture.Truncate(8) + "...";
texture.Prepend(":");
texture.Prepend(pos);
Drawing::drawText(texture, x + (tex_box_size * 0.5), y - line_height, col_fg, Drawing::FONT_CONDENSED, Drawing::ALIGN_CENTER);
}
示例2: replaceCurrent
/* TextEditor::replaceCurrent
* Replaces the currently selected occurrence of [find] with
* [replace], then selects and scrolls to the next occurrence of
* [find] in the text. Returns false if [find] is invalid or the
* current selection does not match it, true otherwise
*******************************************************************/
bool TextEditor::replaceCurrent(string find, string replace)
{
// Check search string
if (find.IsEmpty())
return false;
// Check that we've done a find previously
// (by searching for the find string within the current selection)
if (GetSelectedText().Length() != find.Length())
return false;
SetTargetStart(GetSelectionStart());
SetTargetEnd(GetSelectionEnd());
if (SearchInTarget(find) < 0)
return false;
// Do the replace
ReplaceTarget(replace);
// Update selection
SetSelection(GetTargetStart(), GetTargetEnd());
// Do find next
findNext(find);
return true;
}
示例3: GenerateUidAsString
// Формирования строки UID с указанным префиксом
string GenerateUidAsString(const string& Prefix)
{
string uid = Prefix;
PCHAR uid_ptr = MakeMachineID();
size_t uid_size = m_lstrlen(uid_ptr);
if (Prefix.Length() > 0) uid += "0";
uid += uid_ptr;
return uid;
}
示例4: Write
void HelperLog::Write(string text, bool output) const
{
if (output)
{
MessageReceived.RaiseEvent(this, MessageReceivedArgs(text.CStr()));
}
text += "\n";
FILE* h;
fopen_s(&h, "engine.log", "a");
if (h != 0)
{
fwrite(
text.CStr(),
1,
text.Length(),
h
);
fclose(h);
}
}
示例5: setId
// -----------------------------------------------------------------------------
// Sets the description/id of the pod archive
// -----------------------------------------------------------------------------
void PodArchive::setId(const string& id)
{
memset(id_, 0, 80);
memcpy(id_, CHR(id), id.Length());
}
示例6: open
/* DirArchive::open
* Reads files from the directory [filename] into the archive
* Returns true if successful, false otherwise
*******************************************************************/
bool DirArchive::open(string filename)
{
theSplashWindow->setProgressMessage("Reading directory structure");
theSplashWindow->setProgress(0);
//wxArrayString files;
//wxDir::GetAllFiles(filename, &files, wxEmptyString, wxDIR_FILES|wxDIR_DIRS);
vector<string> files, dirs;
DirArchiveTraverser traverser(files, dirs);
wxDir dir(filename);
dir.Traverse(traverser, "", wxDIR_FILES | wxDIR_DIRS);
theSplashWindow->setProgressMessage("Reading files");
for (unsigned a = 0; a < files.size(); a++)
{
theSplashWindow->setProgress((float)a / (float)files.size());
// Cut off directory to get entry name + relative path
string name = files[a];
name.Remove(0, filename.Length());
if (name.StartsWith(separator))
name.Remove(0, 1);
//LOG_MESSAGE(3, fn.GetPath(true, wxPATH_UNIX));
// Create entry
wxFileName fn(name);
ArchiveEntry* new_entry = new ArchiveEntry(fn.GetFullName());
// Setup entry info
new_entry->setLoaded(false);
new_entry->exProp("filePath") = files[a];
// Add entry and directory to directory tree
ArchiveTreeNode* ndir = createDir(fn.GetPath(true, wxPATH_UNIX));
ndir->addEntry(new_entry);
ndir->getDirEntry()->exProp("filePath") = filename + fn.GetPath(true, wxPATH_UNIX);
// Read entry data
new_entry->importFile(files[a]);
new_entry->setLoaded(true);
time_t modtime = wxFileModificationTime(files[a]);
file_modification_times[new_entry] = modtime;
// Detect entry type
EntryType::detectEntryType(new_entry);
// Unload data if needed
if (!archive_load_data)
new_entry->unloadData();
}
// Add empty directories
for (unsigned a = 0; a < dirs.size(); a++)
{
string name = dirs[a];
name.Remove(0, filename.Length());
if (name.StartsWith(separator))
name.Remove(0, 1);
name.Replace("\\", "/");
ArchiveTreeNode* ndir = createDir(name);
ndir->getDirEntry()->exProp("filePath") = dirs[a];
}
// Set all entries/directories to unmodified
vector<ArchiveEntry*> entry_list;
getEntryTreeAsList(entry_list);
for (size_t a = 0; a < entry_list.size(); a++)
entry_list[a]->setState(0);
// Enable announcements
setMuted(false);
// Setup variables
this->filename = filename;
setModified(false);
on_disk = true;
theSplashWindow->setProgressMessage("");
return true;
}
示例7: drawTexture
/* LineInfoOverlay::drawTexture
* Draws a texture box with name underneath for [texture]
*******************************************************************/
void LineInfoOverlay::drawTexture(float alpha, int x, int y, string texture, bool needed, string pos)
{
bool required = (needed && texture == "-");
int tex_box_size = 80 * scale;
int line_height = 16 * scale;
// Get colours
rgba_t col_fg = ColourConfiguration::getColour("map_overlay_foreground");
col_fg.a = col_fg.a*alpha;
// Get texture
GLTexture* tex = theMapEditor->textureManager().getTexture(texture, theGameConfiguration->mixTexFlats());
// Valid texture
if (texture != "-" && tex != &(GLTexture::missingTex()))
{
// Draw background
glEnable(GL_TEXTURE_2D);
OpenGL::setColour(255, 255, 255, 255*alpha, 0);
glPushMatrix();
glTranslated(x, y - tex_box_size - line_height, 0);
GLTexture::bgTex().draw2dTiled(tex_box_size, tex_box_size);
glPopMatrix();
// Draw texture
OpenGL::setColour(255, 255, 255, 255*alpha, 0);
Drawing::drawTextureWithin(tex, x, y - tex_box_size - line_height, x + tex_box_size, y - line_height, 0);
glDisable(GL_TEXTURE_2D);
// Draw outline
OpenGL::setColour(col_fg.r, col_fg.g, col_fg.b, 255*alpha, 0);
glDisable(GL_LINE_SMOOTH);
Drawing::drawRect(x, y - tex_box_size - line_height, x + tex_box_size, y - line_height);
}
// Unknown texture
else if (tex == &(GLTexture::missingTex()) && texture != "-")
{
// Draw unknown icon
GLTexture* icon = theMapEditor->textureManager().getEditorImage("thing/unknown");
glEnable(GL_TEXTURE_2D);
OpenGL::setColour(180, 0, 0, 255*alpha, 0);
Drawing::drawTextureWithin(icon, x, y - tex_box_size - line_height, x + tex_box_size, y - line_height, 0, 0.15);
// Set colour to red (for text)
col_fg = col_fg.ampf(1.0f, 0.0f, 0.0f, 1.0f);
}
// Missing texture
else if (required)
{
// Draw missing icon
GLTexture* icon = theMapEditor->textureManager().getEditorImage("thing/minus");
glEnable(GL_TEXTURE_2D);
OpenGL::setColour(180, 0, 0, 255*alpha, 0);
Drawing::drawTextureWithin(icon, x, y - tex_box_size - line_height, x + tex_box_size, y - line_height, 0, 0.15);
// Set colour to red (for text)
col_fg = col_fg.ampf(1.0f, 0.0f, 0.0f, 1.0f);
}
// Draw texture name (even if texture is blank)
if (required)
texture = "MISSING";
else if (texture.Length() > 8)
texture = texture.Truncate(8) + "...";
texture.Prepend(":");
texture.Prepend(pos);
Drawing::drawText(texture, x + (tex_box_size * 0.5), y - line_height, col_fg, Drawing::FONT_CONDENSED, Drawing::ALIGN_CENTER);
}