本文整理汇总了C++中String::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Clear方法的具体用法?C++ String::Clear怎么用?C++ String::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NybbleizeString
String NybbleizeString(const String & s)
{
String retStr;
ByteBuffer inBuf; inBuf.AdoptBuffer(s.Length(), (uint8 *) s());
status_t ret = NybbleizeData(inBuf, retStr);
(void) inBuf.ReleaseBuffer();
if (ret != B_NO_ERROR) retStr.Clear();
return retStr;
}
示例2: LoadRegions
void GCContent::LoadRegions(String & regionsFile, GenomeSequence &genome, bool invertRegion)
{
if(regionsFile.Length()==0) return;
if(genome.sequenceLength()==0) error("No reference genome loaded!\n");
IFILE fhRegions;
fhRegions = ifopen(regionsFile.c_str(),"r");
if(fhRegions==NULL)
error("Open regions file %s failed!\n", regionsFile.c_str());
regionIndicator.resize(genome.sequenceLength());
StringArray tokens;
String buffer;
int len;
fprintf(stderr, "Loading region list...");
while (!ifeof(fhRegions)){
buffer.ReadLine(fhRegions);
if (buffer.IsEmpty() || buffer[0] == '#') continue;
tokens.AddTokens(buffer, WHITESPACE);
if(tokens.Length() < 3) continue;
genomeIndex_t startGenomeIndex = 0;
int chromosomeIndex = tokens[1].AsInteger();
// use chromosome name (token[0]) and position (token[1]) to query genome index.
startGenomeIndex = genome.getGenomePosition(tokens[0].c_str(), chromosomeIndex);
if(startGenomeIndex >= regionIndicator.size() ) {
//fprintf(stderr, "WARNING: region list section %s position %u is not found in the reference and skipped...\n", tokens[0].c_str(), chromosomeIndex);
continue;
}
len = tokens[2].AsInteger() - tokens[1].AsInteger() + 1;
for(uint32_t i=startGenomeIndex; i<startGenomeIndex+len; i++)
regionIndicator[i] = true;
tokens.Clear();
buffer.Clear();
}
if (invertRegion) {
fprintf(stderr, " invert region...");
for (uint32_t i = 0; i < regionIndicator.size(); i++) {
regionIndicator[i] = !regionIndicator[i];
}
}
ifclose(fhRegions);
fprintf(stderr, "DONE!\n");
}
示例3: GetSignificantString
bool StringHash::GetSignificantString(StringHash hash, String& strOut)
{
if (!gSignificantLookup.TryGetValue(hash, strOut))
{
strOut.Clear();
return false;
}
return true;
}
示例4: ValidateProcess
bool AnnotationInterface::ValidateProcess( const ProcessImplementation& p, String& whyNot ) const
{
const AnnotationInstance* r = dynamic_cast<const AnnotationInstance*>( &p );
if ( r == 0 )
{
whyNot = "Not a Annotation instance.";
return false;
}
whyNot.Clear();
return true;
}
示例5: TemplateParams
String Parser::TemplateParams(String& param)
{
const char *pos = lex.Pos();
CheckKey('<');
int level = 1;
String id;
bool gp = true;
for(;;) {
if(lex.IsId() && gp)
id = lex.GetId();
else
if(Key(',')) {
ScAdd(param, id);
id.Clear();
gp = true;
}
else
if(Key('=')) {
if(!id.IsEmpty()) {
ScAdd(param, id);
id.Clear();
}
gp = false;
}
else
if(Key('>')) {
level--;
if(level <= 0) {
ScAdd(param, id);
break;
}
}
else
if(Key('<'))
level++;
else
++lex;
}
return String(pos, lex.Pos());
}
示例6: FromControlState
void CIVPad::FromControlState(CControlState controlState, bool bCurrent)
{
#ifdef EXT_LOG
CLogFile::Printf(__FUNCSIG__);
#endif
// Do we not have a valid pad?
if(!m_pPad)
return;
strTemp.Clear();
strTemp.AppendF("%i",controlState.ucInVehicleMove[1]);
if(atoi(strTemp.Get()) > 128) {
controlState.ucInVehicleMove[0] = (unsigned char)'128';
controlState.ucInVehicleMove[1] = (unsigned char)'255';
GET_ANALOG_KEY(INPUT_VEH_MOVE_LEFT, controlState.ucInVehicleMove[0]);
GET_ANALOG_KEY(INPUT_VEH_MOVE_RIGHT, controlState.ucInVehicleMove[1]);
GET_ANALOG_KEY(INPUT_VEH_MOVE_UP, controlState.ucInVehicleMove[2]);
GET_ANALOG_KEY(INPUT_VEH_MOVE_DOWN, controlState.ucInVehicleMove[3]);
}
else {
GET_ANALOG_KEY(INPUT_VEH_MOVE_LEFT, controlState.ucInVehicleMove[0]);
GET_ANALOG_KEY(INPUT_VEH_MOVE_RIGHT, controlState.ucInVehicleMove[1]);
GET_ANALOG_KEY(INPUT_VEH_MOVE_UP, controlState.ucInVehicleMove[2]);
GET_ANALOG_KEY(INPUT_VEH_MOVE_DOWN, controlState.ucInVehicleMove[3]);
}
GET_ANALOG_KEY(INPUT_MOVE_UP, controlState.ucOnFootMove[2]);
GET_ANALOG_KEY(INPUT_MOVE_DOWN, controlState.ucOnFootMove[3]);
GET_ANALOG_KEY(INPUT_VEH_BRAKE, controlState.ucInVehicleTriggers[0]);
GET_ANALOG_KEY(INPUT_VEH_ACCELERATE, controlState.ucInVehicleTriggers[1]);
GET_ANALOG_KEY(INPUT_VEH_MOVE_LEFT_2, controlState.ucInVehicleMove2[0]);
GET_ANALOG_KEY(INPUT_VEH_MOVE_RIGHT_2, controlState.ucInVehicleMove2[1]);
// Binary keys
GET_BINARY_KEY(INPUT_ENTER, controlState.keys.bEnterExitVehicle);
GET_BINARY_KEY(INPUT_SPRINT, controlState.keys.bSprint);
GET_BINARY_KEY(INPUT_JUMP, controlState.keys.bJump);
GET_BINARY_KEY(INPUT_ATTACK, controlState.keys.bAttack);
GET_BINARY_KEY(INPUT_ATTACK2, controlState.keys.bAttack2);
GET_BINARY_KEY(INPUT_AIM, controlState.keys.bAim);
GET_BINARY_KEY(INPUT_FREE_AIM, controlState.keys.bFreeAim);
GET_BINARY_KEY(INPUT_MELEE_ATTACK1, controlState.keys.bMeleeAttack1);
GET_BINARY_KEY(INPUT_MELEE_ATTACK2, controlState.keys.bMeleeAttack2);
GET_BINARY_KEY(INPUT_MELEE_KICK, controlState.keys.bMeleeKick);
GET_BINARY_KEY(INPUT_MELEE_BLOCK, controlState.keys.bMeleeBlock);
GET_BINARY_KEY(INPUT_VEH_HANDBRAKE, controlState.keys.bHandbrake);
GET_BINARY_KEY(INPUT_VEH_HANDBRAKE_ALT, controlState.keys.bHandbrake2);
GET_BINARY_KEY(INPUT_VEH_HORN, controlState.keys.bHorn);
GET_BINARY_KEY(INPUT_VEH_ATTACK, controlState.keys.bDriveBy);
GET_BINARY_KEY(INPUT_VEH_ATTACK2, controlState.keys.bHeliPrimaryFire);
}
示例7: NybbleizeData
status_t NybbleizeData(const uint8 * b, uint32 numBytes, String & retString)
{
if (retString.Prealloc(numBytes*2) != B_NO_ERROR) return B_ERROR;
retString.Clear();
for (uint32 i=0; i<numBytes; i++)
{
const uint8 c = b[i];
retString += ((c>>0)&0x0F)+'A';
retString += ((c>>4)&0x0F)+'A';
}
return B_NO_ERROR;
}
示例8: CanExecuteOn
bool DebayerInstance::CanExecuteOn( const View& view, String& whyNot ) const
{
if ( view.Image().IsComplexSample() )
whyNot = "Debayer cannot be executed on complex images.";
else if ( view.Image().Width() < 6 || view.Image().Height() < 6 )
whyNot = "Debayer needs an image of at least 6 by 6 pixels";
else
{
whyNot.Clear();
return true;
}
return false;
}
示例9:
result
MyCardManager::ReadNameCardFromFile(Tizen::Base::String& name, Tizen::Base::String& number, Tizen::Base::String& address)
{
File file;
String buffer;
int length;
result r = E_SUCCESS;
r = file.Construct(App::GetInstance()->GetAppRootPath() + NFC_BUMP_MY_CARD_INFO_PATH, "r", false);
TryReturn(r == E_SUCCESS, r, "Failed to open the file.");
r = file.Seek(FILESEEKPOSITION_BEGIN, 0);
TryReturn(r == E_SUCCESS, r, "Failed to repositions the file pointer.");
//read user's name from data file
r = file.Read(buffer);
TryReturn(r == E_SUCCESS, r, "Failed to read my name from file.");
length = buffer.GetLength();
buffer.SubString(0, length - 1, name);
buffer.Clear();
//read user's phone number from data file
r = file.Read(buffer);
TryReturn(r == E_SUCCESS, r, "Failed to read my phone number from file.");
length = buffer.GetLength();
buffer.SubString(0, length - 1, number);
buffer.Clear();
//read user's e-mail address from data file
r = file.Read(buffer);
TryReturn(r == E_SUCCESS, r, "Failed to read my e-mail address from file.");
length = buffer.GetLength();
buffer.SubString(0, length - 1, address);
return r;
}
示例10: IdePaste
void Ide::IdePaste(String& data)
{
data.Clear();
if(AcceptFiles(Clipboard())) {
Vector<String> s = GetFiles(Clipboard());
for(int i = 0; i < s.GetCount(); i++)
if(FileExists(s[i]) && IsTextFile(s[i], 10000)) {
int64 len = GetFileLength(s[i]);
if(len > 5000000 || data.GetLength() + len < 5000000)
data.Cat(LoadFile(s[i]));
}
}
}
示例11: __EditCompleted
void ColorCalibrationInterface::__EditCompleted( Edit& sender )
{
try
{
String id = sender.Text();
id.Trim();
if ( id == TARGET_IMAGE )
id.Clear();
if ( !id.IsEmpty() )
{
bool valid;
size_type p = id.Find( "->" );
if ( p == String::notFound )
valid = id.IsValidIdentifier();
else
valid = id.Left( p ).IsValidIdentifier() && id.Substring( p+2 ).IsValidIdentifier();
if ( !valid )
throw Error( "Invalid view identifier: " + id );
}
if ( sender == GUI->WhiteReferenceView_Edit )
{
instance.whiteReferenceViewId = id;
sender.SetText( WHITE_REFERENCE_ID );
}
else if ( sender == GUI->BackgroundReferenceView_Edit )
{
instance.backgroundReferenceViewId = id;
sender.SetText( BACKGROUND_REFERENCE_ID );
}
return;
}
catch ( ... )
{
if ( sender == GUI->WhiteReferenceView_Edit )
sender.SetText( WHITE_REFERENCE_ID );
else if ( sender == GUI->BackgroundReferenceView_Edit )
sender.SetText( BACKGROUND_REFERENCE_ID );
try
{
throw;
}
ERROR_HANDLER
sender.SelectAll();
sender.Focus();
}
}
示例12: PatternMatchMulti
bool PatternMatchMulti(const char *p, const char *s) {
String pt;
while(*p) {
if(*p == ';' || *p == ',' || *p == ' ') {
if(PatternMatch(pt, s)) return true;
p++;
while(*p == ';' || *p == ',' || *p == ' ') p++;
pt.Clear();
}
else
pt.Cat(*p++);
}
return pt.IsEmpty() ? false : PatternMatch(pt, s);
}
示例13:
void Sqlite3Connection::Cancel()
{
if (current_stmt) {
// if (sqlite3_reset(current_stmt) != SQLITE_OK)
// session.SetError(sqlite3_errmsg(db), "Resetting statement: " + current_stmt_string);
// if (sqlite3_finalize(current_stmt) != SQLITE_OK)
// session.SetError(sqlite3_errmsg(db), "Finalizing statement: "+ current_stmt_string);
//this seems to be the correct way how to do error recovery...
sqlite3_finalize(current_stmt);
current_stmt = NULL;
current_stmt_string.Clear();
parse = true;
}
}
示例14: SetOld
bool Speller::SetOld(const String& _data)
{
data = _data;
const char *s = data;
if(s >= data.End()) {
data.Clear();
return false;
}
charset = *s++;
s++;// reserved for prefixes
dict = *s++;
for(int i = 0; i < 256 - dict; i++) {
if(s >= data.End()) {
data.Clear();
return false;
}
voc[i] = s;
while(*s) s++;
s++;
}
line.Clear();
while(s < data.End()) {
if(s + 8 >= data.End()) {
data.Clear();
return false;
}
int code = Peek32le(s);
s += 4;
int len = Peek32le(s);
s += 4;
Line& l = line.Add(code);
l.begin = (const byte *)s;
s += len;
l.end = (const byte *)s;
};
return true;
}
示例15: GetExePath
/**
* Retrieves the full path of the executable.
*
* @param argv0 The first command-line argument.
* @returns The path.
*/
String Application::GetExePath(const String& argv0)
{
String executablePath;
#ifndef _WIN32
char buffer[MAXPATHLEN];
if (getcwd(buffer, sizeof(buffer)) == NULL) {
BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("getcwd")
<< boost::errinfo_errno(errno));
}
String workingDirectory = buffer;
if (argv0[0] != '/')
executablePath = workingDirectory + "/" + argv0;
else
executablePath = argv0;
bool foundSlash = false;
for (size_t i = 0; i < argv0.GetLength(); i++) {
if (argv0[i] == '/') {
foundSlash = true;
break;
}
}
if (!foundSlash) {
const char *pathEnv = getenv("PATH");
if (pathEnv != NULL) {
std::vector<String> paths;
boost::algorithm::split(paths, pathEnv, boost::is_any_of(":"));
bool foundPath = false;
BOOST_FOREACH(String& path, paths) {
String pathTest = path + "/" + argv0;
if (access(pathTest.CStr(), X_OK) == 0) {
executablePath = pathTest;
foundPath = true;
break;
}
}
if (!foundPath) {
executablePath.Clear();
BOOST_THROW_EXCEPTION(std::runtime_error("Could not determine executable path."));
}
}