本文整理匯總了C++中string_t::begin方法的典型用法代碼示例。如果您正苦於以下問題:C++ string_t::begin方法的具體用法?C++ string_t::begin怎麽用?C++ string_t::begin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類string_t
的用法示例。
在下文中一共展示了string_t::begin方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: containsKeyword
bool containsKeyword (string_t keyword, value_t& value)
{
typename Entry::childen_t::iterator current;
typename Entry::childen_t::iterator next;
current = mRoot.mChildren.find (std::tolower (*keyword.begin(), mLocale));
if (current == mRoot.mChildren.end())
return false;
else if (current->second.mKeyword.size() && Misc::StringUtils::ciEqual(current->second.mKeyword, keyword))
{
value = current->second.mValue;
return true;
}
for (Point i = ++keyword.begin(); i != keyword.end(); ++i)
{
next = current->second.mChildren.find(std::tolower (*i, mLocale));
if (next == current->second.mChildren.end())
return false;
if (Misc::StringUtils::ciEqual(next->second.mKeyword, keyword))
{
value = next->second.mValue;
return true;
}
current = next;
}
return false;
}
示例2: Peek
void KeywordManager::Peek(const string_t& filename,
const TokenRange& range,
Elements& elements,
std::vector<TokenRange>& preidentified_tokens) const {
typedef std::pair<ElementCategory, std::vector<string_t>> entry_t;
static /*const*/ std::vector<entry_t> entries;
{ ElementCategory c = kElementAudioTerm; const char_t* k[] = {L"Dual Audio"}; entry_t e; e.first = c; e.second.assign(k, k + _countof(k)); entries.push_back(e); }
{ ElementCategory c = kElementVideoTerm; const char_t* k[] = {L"H264", L"H.264", L"h264", L"h.264"}; entry_t e; e.first = c; e.second.assign(k, k + _countof(k)); entries.push_back(e); }
{ ElementCategory c = kElementVideoResolution; const char_t* k[] = {L"480p", L"720p", L"1080p"}; entry_t e; e.first = c; e.second.assign(k, k + _countof(k)); entries.push_back(e); }
{ ElementCategory c = kElementSource; const char_t* k[] = {L"Blu-Ray"}; entry_t e; e.first = c; e.second.assign(k, k + _countof(k)); entries.push_back(e); }
string_t::const_iterator it_begin = filename.begin() + range.offset;
string_t::const_iterator it_end = it_begin + range.size;
for(std::vector<entry_t>::const_iterator entry = entries.begin(); entry != entries.end(); ++entry) {
for(std::vector<string_t>::const_iterator keyword = entry->second.begin(); keyword != entry->second.end(); ++keyword) {
string_t::const_iterator it = std::search(it_begin, it_end, keyword->begin(), keyword->end());
if (it != it_end) {
size_t offset = it - filename.begin();
elements.insert(entry->first, *keyword);
preidentified_tokens.push_back(TokenRange(offset, keyword->size()));
}
}
}
}
示例3: Peek
void KeywordManager::Peek(const string_t& filename,
const TokenRange& range,
Elements& elements,
std::vector<TokenRange>& preidentified_tokens) const {
typedef std::pair<ElementCategory, std::vector<string_t>> entry_t;
static const std::vector<entry_t> entries{
{kElementAudioTerm, {L"Dual Audio"}},
{kElementVideoTerm, {L"H264", L"H.264", L"h264", L"h.264"}},
{kElementVideoResolution, {L"480p", L"720p", L"1080p"}},
{kElementSource, {L"Blu-Ray"}}
};
auto it_begin = filename.begin() + range.offset;
auto it_end = it_begin + range.size;
for (const auto& entry : entries) {
for (const auto& keyword : entry.second) {
auto it = std::search(it_begin, it_end, keyword.begin(), keyword.end());
if (it != it_end) {
auto offset = it - filename.begin();
elements.insert(entry.first, keyword);
preidentified_tokens.push_back(TokenRange(offset, keyword.size()));
}
}
}
}
示例4: GetFileName
string_t CFileSystem::GetFileName( const string_t& fileName ) {
string_t::size_type slash1 = fileName.find_last_of( '/' );
string_t::size_type slash2 = fileName.find_last_of( '\\' );
if ( slash1 == string_t::npos ) {
if ( slash2 == string_t::npos)
return fileName;
return string_t( fileName.begin() + slash2 + 1, fileName.end() );
}
if ( slash2 == string_t::npos)
return string_t( fileName.begin() + slash1 + 1, fileName.end() );
return string_t( fileName.begin() + ( slash1 > slash2 ? slash1 : slash2 ) + 1, fileName.end() );
}
示例5: IsDashCharacter
bool Parser::IsDashCharacter(const string_t& str) {
if (str.size() != 1)
return false;
auto result = std::find(kDashes.begin(), kDashes.end(), str.front());
return result != kDashes.end();
}
示例6: splitComment
bool MusicDecoder::splitComment(
const char* comment,
unsigned int size,
string_t& field,
string_t& value)
{
#ifdef STRING_T_IS_SF_STRING
sf::String str=sf::String::fromUtf8(comment, &(comment[size]));
size_t split=str.find(sf::String("="));
if (split==sf::String::InvalidPos){
return false;
} else {
field=str.substring(0,split);
value=str.substring(split+1);
sf::String::Iterator it;
for (it=field.begin(); it !=field.end(); it++)
{
*it=toupper(*it);
}
//std::cout << "field " << field.toAnsiString() << "=" << value.toAnsiString() << std::endl;
return true;
}
#else
return false;
#endif
}
示例7: TokenizeByDelimiters
void Tokenizer::TokenizeByDelimiters(bool enclosed, const TokenRange& range) {
const string_t delimiters = GetDelimiters(range);
if (delimiters.empty()) {
AddToken(kUnknown, enclosed, range);
return;
}
auto char_begin = filename_.begin() + range.offset;
const auto char_end = char_begin + range.size;
auto current_char = char_begin;
while (current_char != char_end) {
current_char = std::find_first_of(current_char, char_end,
delimiters.begin(), delimiters.end());
const TokenRange subrange(std::distance(filename_.begin(), char_begin),
std::distance(char_begin, current_char));
if (subrange.size > 0) // Found unknown token
AddToken(kUnknown, enclosed, subrange);
if (current_char != char_end) { // Found delimiter
AddToken(kDelimiter, enclosed,
TokenRange(subrange.offset + subrange.size, 1));
char_begin = ++current_char;
}
}
ValidateDelimiterTokens();
}
示例8: GetFileExtension
string_t CFileSystem::GetFileExtension( const string_t& fileName ) {
string_t::size_type dot = fileName.find_last_of( '.' );
if ( dot == std::string::npos)
return string_t( "" );
return string_t( fileName.begin() + dot + 1, fileName.end() );
}
示例9: string_to_real_cast
real_t string_to_real_cast(string_t const& str)
{
typedef boost::spirit::qi::real_parser<real_t, boost::spirit::qi::real_policies<real_t>> real_parser_t;
real_t value(0.);
if (!boost::spirit::qi::parse(str.begin(), str.end(), real_parser_t(), value))
_cast_is_failed(str);
return value;
}
示例10: MatchPartialEpisodePattern
bool Parser::MatchPartialEpisodePattern(const string_t& word, Token& token) {
auto it = std::find_if_not(word.begin(), word.end(), IsNumericChar);
auto suffix_length = std::distance(it, word.end());
auto is_valid_suffix = [](const char_t c) {
return (c >= L'A' && c <= L'C') ||
(c >= L'a' && c <= L'c');
};
if (suffix_length == 1 && is_valid_suffix(*it))
if (SetEpisodeNumber(word, token, true))
return true;
return false;
}
示例11: assemble_sheet
void assemble_sheet(const string_t& sheet_name,
const sheet_assembly_t& assembly,
std::ostream& out)
{
string_t washed_sheet_name;
adam_node_formatter_t formatter;
for (string_t::const_iterator first(sheet_name.begin()), last(sheet_name.end()); first != last; ++first)
washed_sheet_name.push_back(std::isalpha(*first) ? *first : '_');
out << "sheet " << washed_sheet_name.c_str() << "\n{";
for_each(assembly, boost::bind(&adam_node_formatter_t::format_node,
boost::ref(formatter), _1, boost::ref(out)));
out << "}" << std::endl;
}
示例12: IsValidString
bool Square::IsValidString(const string_t & str)
{
if (str == Black)
return true;
#if PUZ_UNICODE
std::wstring::const_iterator begin = str.begin();
std::wstring::const_iterator end = str.end();
#else
std::wstring unicode = to_unicode(str);
std::wstring::const_iterator begin = unicode.begin();
std::wstring::const_iterator end = unicode.end();
#endif // PUZ_UNICODE
std::wstring::const_iterator it;
for (it = begin; it != end; ++it)
if (! IsValidChar(*it))
return false;
return true;
}
示例13: ToGrid
string_t Square::ToGrid(const string_t & str)
{
#ifdef PUZ_CHECK_STRINGS
if (str.length() > REBUS_ENTRY_LENGTH)
throw LongString();
#endif
string_t ret;
string_t::const_iterator it;
for (it = str.begin(); it != str.end(); ++it)
{
char_t ch = ToGrid(*it);
if (ch != 0)
ret.append(1, ch);
#ifdef PUZ_CHECK_STRINGS
else
throw InvalidString();
#endif
}
return ret;
}
示例14: Serialize
void SaveFile::Serialize(string_t &str)
{
string_t::size_type len = str.length();
Serialize(len);
if( len )
{
if( loading() )
{
std::vector<string_t::value_type> buffer(len);
SerializeArray(&*buffer.begin(), len);
str.resize(0);
str.reserve(len);
str.insert(str.begin(), buffer.begin(), buffer.end());
}
else
{
SerializeArray(const_cast<string_t::value_type*>(str.data()), len);
}
}
}
示例15: FindNumberInString
size_t Parser::FindNumberInString(const string_t& str)
{
auto it = std::find_if(str.begin(), str.end(), IsNumericChar);
return it == str.end() ? str.npos : (it - str.begin());
}