本文整理汇总了C++中Stroka::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Stroka::empty方法的具体用法?C++ Stroka::empty怎么用?C++ Stroka::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stroka
的用法示例。
在下文中一共展示了Stroka::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FillDocInfo
void CDocListRetrieverFromDisc::FillDocInfo(SDocumentAttribtes& attrs)
{
Stroka strFilePath = m_SmartFileFind.GetFoundFilePath(m_iCurPath);
Stroka strURL;
if (strFilePath == m_strSearchDir) {
TStringBuf left, right;
PathHelper::Split(strFilePath, left, right);
strURL = ToString(right);
} else
strURL = strFilePath.substr(m_strSearchDir.size());
if (strURL.empty())
ythrow yexception() << "Can't build url for file \"" << strFilePath
<< "\" with searchdir \"" << m_strSearchDir << "\".";
TransformBackSlash(strURL);
attrs.m_strUrl = strURL;
Stroka strTime;
if (stroka(m_strLTM) == "file") {
CTime lw_time = m_SmartFileFind.GetFoundFileInfo(m_iCurPath).m_LastWriteTime;
strTime = lw_time.Format("%d.%m.%Y %H:%M:%S");
}
if (strTime.empty())
strTime = m_strStartTime;
attrs.m_strTitle = CharToWide(strTime);
attrs.m_strSource = strURL;
attrs.m_strTitle = CharToWide(attrs.m_strSource); // ??? rewriting
}
示例2: OpenOutput
static inline TAutoPtr<TOutputStream> OpenOutput(const Stroka& url) {
if (url.empty()) {
return new TBuffered<TFileOutput>(8192, Duplicate(1));
} else {
return new TBuffered<TFileOutput>(8192, url);
}
}
示例3: Init
bool CAgencyInfoRetriver::Init(const Stroka& strDoc2AgFile)
{
if (!strDoc2AgFile.empty() && isexist(strDoc2AgFile.c_str()))
m_DocId2AgNameFile = TFile(strDoc2AgFile.c_str(), OpenExisting | RdOnly);
return true;
}
示例4: AddAliasImpl
inline void TFile::AddAliasImpl(const Stroka& name) {
if (!name.empty() && !Is(name)) {
Aliases_.push_back(name);
if (!GeneratedDescriptor)
GeneratedDescriptor = NBuiltin::FindInGeneratedPool(name);
}
}
示例5: TryConsumeImportFileName
bool TDependencyCollectorInputStream::TryConsumeImportFileName(const NProtoBuf::io::Tokenizer::Token& token)
{
ImportProcessor.NextState(token);
if (!ImportProcessor.Found())
return false;
YASSERT(token.type == NProtoBuf::io::Tokenizer::TYPE_STRING);
// original imported file (unquoted)
Stroka original;
Tokenizer_.ParseString(token.text, &original);
// canonic file
const Stroka canonic = SourceTree->CanonicName(original);
if (canonic.empty() || canonic == original) {
// make a hint for this special case
if (original == STRINGBUF("base.proto"))
ErrorCollector->AddErrorAtCurrentFile(token.line, token.column,
"Importing base.proto by shortcut name is not allowed from arcadia. You should use full path instead: import \"kernel/gazetteer/base.proto\";");
return false; // just proceed with original file name
}
// restore quotes and replace original with canonic in further pipeline.
CanonicImportedFile.clear();
CanonicImportedFile.append('"');
EscapeC(canonic, CanonicImportedFile);
CanonicImportedFile.append('"');
return true;
}
示例6: SaveStateCollection
void CLRCollectionSet::SaveStateCollection(Stroka GrammarFileName, const CWorkGrammar* p_WorkGrammar) const
{
if (GrammarFileName.empty()) return;
FILE * fp = fopen(GrammarFileName.c_str(), "wb");
for (int i = 0; i < (int)m_ItemSets.size(); i++) {
fprintf(fp, "I%i =\n", i);
for (yset<CLRItem>::const_iterator it = m_ItemSets[i].begin(); it != m_ItemSets[i].end(); it++) {
fprintf(fp, "\t%s -> ", p_WorkGrammar->m_UniqueGrammarItems[it->m_pRule->m_LeftPart].m_ItemStrId.c_str());
for (int j = 0; j < (int)it->m_pRule->m_RightPart.m_Items.size(); j++) {
if (j == (int)it->m_DotSymbolNo)
fprintf(fp, "; ");
fprintf(fp, "%s ", p_WorkGrammar->m_UniqueGrammarItems[it->m_pRule->m_RightPart.m_Items[j]].m_ItemStrId.c_str());
}
if (it->m_DotSymbolNo == it->m_pRule->m_RightPart.m_Items.size())
fprintf(fp, "; ");
fprintf(fp, "\n");
}
fprintf(fp, "\n");
}
fprintf(fp, "\n");
for (ymap< CStateAndSymbol, size_t>::const_iterator it_goto = m_GotoFunction.begin(); it_goto != m_GotoFunction.end(); it_goto++)
fprintf(fp, "GOTO( I%" PRISZT ", %s ) = I%" PRISZT "\n", it_goto->first.m_StateNo, p_WorkGrammar->m_UniqueGrammarItems[it_goto->first.m_SymbolNo].m_ItemStrId.c_str(), it_goto->second);
fclose(fp);
}
示例7: Fix
static inline Stroka Fix(Stroka f) {
if (!f.empty() && IsDelim(f[+f - 1])) {
f.pop_back();
}
return f;
}
示例8: StripFileComponent
Stroka StripFileComponent(const Stroka& fileName)
{
Stroka dir = IsDir(fileName) ? fileName : GetDirName(fileName);
if (!dir.empty() && dir.back() != GetDirectorySeparator()) {
dir.append(GetDirectorySeparator());
}
return dir;
}
示例9: BitsetToString
Stroka BitsetToString(const yvector<TGramBitSet>& bitset, const Stroka& delim /*= ", "*/, const Stroka& groupdelim /*= ", "*/) {
Stroka s;
for (size_t i = 0; i < bitset.size(); ++i) {
if (!s.empty())
s += groupdelim;
s += bitset[i].ToString(~delim);
}
return s;
}
示例10: QuoteForHelp
// Like Stroka::Quote(), but does not quote digits-only string
static Stroka QuoteForHelp(const Stroka& str) {
if (str.empty())
return str.Quote();
for (size_t i = 0; i < str.size(); ++i) {
if (!isdigit(str[i]))
return str.Quote();
}
return str;
}
示例11: ParseListOfFacts
void CParserOptions::ParseListOfFacts(TXmlNodePtrBase piNode) {
TXmlNodePtrBase piFacts = piNode->children;
m_ParserOutputOptions.m_bShowFactsWithEmptyField = piNode.HasAttr("addEmpty");
for (; piFacts.Get() != NULL; piFacts = piFacts->next) {
if (!piFacts.HasName("fact"))
continue;
Stroka str = piFacts.GetAttr("name");
if (!str.empty())
AddFactToShow(str, !piFacts.HasAttr("noequality"));
}
}
示例12: StringToBitset
TGramBitSet StringToBitset(const Stroka& gram, const Stroka& delim /*= ",; "*/) {
if (gram.empty())
return TGramBitSet();
TGramBitSet res;
VectorStrok tokens;
SplitStrokuBySet(&tokens, ~gram, ~delim);
for (size_t i = 0; i < tokens.size(); ++i) {
TGrammar code = TGrammarIndex::GetCode(tokens[i]);
if (code != gInvalid)
res.Set(code);
}
return res;
}
示例13: WriteToLogFile
void WriteToLogFile(const Stroka& sGrammarFileLog, Stroka& str, bool bRW)
{
if (sGrammarFileLog.empty())
return;
str += '\n';
THolder<TFile> f;
if (bRW)
f.Reset(new TFile(sGrammarFileLog, CreateAlways | WrOnly | Seq));
else
f.Reset(new TFile(sGrammarFileLog, OpenAlways | WrOnly | Seq | ForAppend));
TFileOutput out(*f);
out.Write(str.c_str());
};
示例14: BuildMessageInheritanceGraph
bool TProtoParser::BuildMessageInheritanceGraph(const TDescriptor* msg_descr, const TSimpleHierarchy& graph)
{
for (int i = 0; i < msg_descr->nested_type_count(); ++i)
if (!BuildMessageInheritanceGraph(msg_descr->nested_type(i), graph))
return false;
// Find a base descriptor. There are two possible cases:
// 1) @msg_descr was taken from generated_pool (builtin) and it's base type name is stored in its GztProtoDerivedFrom option.
// 2) @msg_descr was read from disk .proto (using TDependencyCollector) and its base is remembered in the inheritance graph.
const Stroka* explicit_base_name = graph.GetBase(msg_descr->full_name());
const Stroka implicit_base_name = msg_descr->options().GetExtension(GztProtoDerivedFrom);
if (!explicit_base_name && !implicit_base_name) // no base class
return true;
const NProtoBuf::Descriptor* explicit_base_descr = NULL;
if (explicit_base_name) {
explicit_base_descr = ResolveBaseMessageByName(*explicit_base_name, msg_descr);
if (!explicit_base_descr)
return false;
}
const NProtoBuf::Descriptor* implicit_base_descr = NULL;
if (!implicit_base_name.empty()) {
implicit_base_descr = ResolveBaseMessageByName(implicit_base_name, msg_descr);
if (!implicit_base_descr)
return false;
}
if (explicit_base_descr && implicit_base_descr && explicit_base_descr != implicit_base_descr) {
Errors->AddError(msg_descr->file()->name(), -1, 0, NProtoBuf::strings::Substitute(
"Ambiguous base type for $0: either $1 (disk) or $2 (builtin).", msg_descr->full_name(),
explicit_base_descr->full_name(), implicit_base_descr->full_name()));
return false;
}
RawMessageGraph[msg_descr] = explicit_base_descr ? explicit_base_descr : implicit_base_descr;
// check if cycle dependency exists.
if (!CheckIfSelfDerived(msg_descr))
return false;
return true;
}
示例15: ReadTo
inline bool ReadTo(Stroka& st, char to) {
Stroka res;
Stroka s_tmp;
bool ret = false;
while (true) {
if (MemInput_.Exhausted()) {
const size_t readed = Slave_->Read(Buf(), BufLen());
if (!readed) {
break;
}
MemInput_.Reset(Buf(), readed);
}
const size_t a_len(MemInput_.Avail());
MemInput_.ReadTo(s_tmp, to);
const size_t s_len = s_tmp.length();
/*
* mega-optimization
*/
if (res.empty()) {
res.swap(s_tmp);
} else {
res += s_tmp;
}
ret = true;
if (s_len != a_len) {
break;
}
}
st.swap(res);
return ret;
}