本文整理汇总了C++中String::BeginsWith方法的典型用法代码示例。如果您正苦于以下问题:C++ String::BeginsWith方法的具体用法?C++ String::BeginsWith怎么用?C++ String::BeginsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::BeginsWith方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Error
void PixInsightX11Installer::CopyFiles( const String& targetDir, const String& sourceDir )
{
if ( !targetDir.BeginsWith( '/' ) )
throw Error( "CopyFiles(): Relative target directory." );
if ( !sourceDir.BeginsWith( '/' ) )
throw Error( "CopyFiles(): Relative source directory." );
if ( targetDir.EndsWith( '/' ) || sourceDir.EndsWith( '/' ) )
throw Error( "CopyFiles(): Incorrectly terminated directories." );
if ( !File::DirectoryExists( targetDir ) )
throw Error( "CopyFiles(): Nonexistent target directory." );
if ( !File::DirectoryExists( sourceDir ) )
throw Error( "CopyFiles(): Nonexistent source directory." );
StringList sourceItems = SearchDirectory( sourceDir );
size_type sourceDirLen = sourceDir.Length();
for ( StringList::const_iterator i = sourceItems.Begin(); i != sourceItems.End(); ++i )
{
String relSourcePath = *i;
relSourcePath.DeleteLeft( sourceDirLen );
String targetPath = targetDir + relSourcePath;
if ( targetPath.EndsWith( '/' ) )
{
/*
* Create a subdirectory
*/
targetPath.Delete( targetPath.UpperBound() );
if ( !File::DirectoryExists( targetPath ) )
{
File::CreateDirectory( targetPath );
String sourcePath = *i;
sourcePath.Delete( sourcePath.UpperBound() );
File::CopyTimesAndPermissions( targetPath, sourcePath );
}
}
else
{
/*
* Copy a file
*/
/*
* ### N.B. We don't have to create subdirectories here becase they
* have been reported by SearchDirectory(), and we are creating them
* before copying files. SearchDirectory() promises that all
* subdirectories are reported before their contained files.
*/
/*
String targetSubdir = File::ExtractDirectory( targetPath );
if ( targetSubdir.EndsWith( '/' ) )
targetSubdir.Delete( targetSubdir.UpperBound() );
if ( !File::DirectoryExists( targetSubdir ) )
File::CreateDirectory( targetSubdir );
*/
File::CopyFile( targetPath, *i );
}
}
}
示例2: LoadConfigFile
//-----------------------------------------------------------------------------------------------------------------------------------------------------
VOID Configuration::LoadConfigFile(LPCTSTR Filename)
{
TextStream T(File::Open(Filename, FileMode::OPEN));
while(!T.EndOfStream())
{
String L = T.ReadLine();
if (L.BeginsWith("#"))
continue;
String::Iterator i = L.Find('=');
if (i != L.End())
{
String Name = L.Substr(L.Begin(), i);
String Value = L.Substr(i+1, L.End());
if (m_Schema.Contains(Name))
{
Item I = m_Schema.Get(Name);
if ((I.m_Source & ConfigurationSource::FILE) == 0)
continue;
I.m_Present = TRUE;
}
m_ConfigValues.Add(Name,Value);
}
}
}
示例3:
String PixInsightX11Installer::Unquoted( const String& s )
{
String r = s;
if ( s.BeginsWith( '\"' ) )
if ( s.EndsWith( '\"' ) )
{
r.DeleteRight( r.UpperBound() );
r.DeleteLeft( 1 );
}
if ( s.BeginsWith( '\'' ) )
if ( s.EndsWith( '\'' ) )
{
r.DeleteRight( r.UpperBound() );
r.DeleteLeft( 1 );
}
return r;
}
示例4: SetProperty
void PropertyWindow::SetProperty()
{
if(property->GetOption().second!=-1 && textField->GetText().length() > 0)
{
String value = textField->GetText();
try {
switch(properties[property->GetOption().second].Type)
{
case StructProperty::Integer:
case StructProperty::ParticleType:
{
int v;
if(value.length() > 2 && value.BeginsWith("0x"))
{
//0xC0FFEE
v = value.Substr(2).ToNumber<unsigned int>(Format::Hex());
}
else if(value.length() > 1 && value.BeginsWith("#"))
{
//#C0FFEE
v = value.Substr(1).ToNumber<unsigned int>(Format::Hex());
}
else
{
int type;
if ((type = sim->GetParticleType(value.ToUtf8())) != -1)
{
v = type;
#ifdef DEBUG
std::cout << "Got type from particle name" << std::endl;
#endif
}
else
{
v = value.ToNumber<int>();
}
}
if (properties[property->GetOption().second].Name == "type" && (v < 0 || v >= PT_NUM || !sim->elements[v].Enabled))
{
new ErrorMessage("Could not set property", "Invalid particle type");
return;
}
#ifdef DEBUG
std::cout << "Got int value " << v << std::endl;
#endif
tool->propValue.Integer = v;
break;
}
case StructProperty::UInteger:
{
unsigned int v;
if(value.length() > 2 && value.BeginsWith("0x"))
{
//0xC0FFEE
v = value.Substr(2).ToNumber<unsigned int>(Format::Hex());
}
else if(value.length() > 1 && value.BeginsWith("#"))
{
//#C0FFEE
v = value.Substr(1).ToNumber<unsigned int>(Format::Hex());
}
else
{
v = value.ToNumber<unsigned int>();
}
#ifdef DEBUG
std::cout << "Got uint value " << v << std::endl;
#endif
tool->propValue.UInteger = v;
break;
}
case StructProperty::Float:
{
if (value.EndsWith("C"))
{
float v = value.SubstrFromEnd(1).ToNumber<float>();
tool->propValue.Float = v + 273.15;
}
else if(value.EndsWith("F"))
{
float v = value.SubstrFromEnd(1).ToNumber<float>();
tool->propValue.Float = (v-32.0f)*5/9+273.15f;
}
else
{
tool->propValue.Float = value.ToNumber<float>();
}
#ifdef DEBUG
std::cout << "Got float value " << tool->propValue.Float << std::endl;
#endif
}
break;
default:
new ErrorMessage("Could not set property", "Invalid property");
return;
}
//.........这里部分代码省略.........