當前位置: 首頁>>代碼示例>>C++>>正文


C++ string_t::empty方法代碼示例

本文整理匯總了C++中string_t::empty方法的典型用法代碼示例。如果您正苦於以下問題:C++ string_t::empty方法的具體用法?C++ string_t::empty怎麽用?C++ string_t::empty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在string_t的用法示例。


在下文中一共展示了string_t::empty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: split_string

void split_string(string_t& source, const string_t& delim, std::list<string_t>& ret)
{
	ret.clear();

	if (delim.empty() || source.empty())
	{
		ret.push_back(source);
		return ;
	}

	size_t last = 0;
	size_t index = source.find(delim, last);

    while (index!=std::string::npos)
    {
		ret.push_back(source.substr(last, index - last));
		last = index + delim.size();
		index = source.find(delim, last);
	}

    if(index - last > 0)
	{
		ret.push_back(source.substr(last, index - last));
	}
}
開發者ID:OData,項目名稱:odatacpp-server,代碼行數:25,代碼來源:utility.cpp

示例2: _OnTextContentReceived

    void cUpdateChecker::_OnTextContentReceived(const std::string& sContent)
    {
      LOG<<"cUpdateChecker::_OnTextContentReceived"<<std::endl;

      // Read the xml document
      spitfire::xml::reader reader;
      spitfire::document::cDocument document;

      spitfire::util::cProcessInterfaceVoid interface;
      spitfire::util::PROCESS_RESULT result = reader.ReadFromString(interface, document, sContent);
      if (result != spitfire::util::PROCESS_RESULT::COMPLETE) {
        LOG<<"cUpdateChecker::_OnTextContentReceived ReadFromString failed for string \""<<sContent<<"\", returning"<<std::endl;
        return;
      }

      //<latest>
      //  <linux>
      //    <version>0.8</version>
      //    <download>http://chris.iluo.net/projects/medusa/medusa.tar.gz</download>
      //    <page>http://chris.iluo.net/projects/medusa/</page>
      //  </linux>
      //</latest>

      spitfire::document::cNode::const_iterator iterLatest(document);
      if (!iterLatest.IsValid()) return;

      iterLatest.FindChild("latest");
      if (!iterLatest.IsValid()) return;

      spitfire::document::cNode::const_iterator iterPlatform(iterLatest);
      if (!iterPlatform.IsValid()) return;

      iterPlatform.FindChild("linux");
      if (!iterPlatform.IsValid()) return;

      // Get the version
      const string_t sVersion = GetContentOfChildNode(iterPlatform, "version");
      if (sVersion.empty()) {
        LOG<<"cUpdateChecker::_OnTextContentReceived Could not find version node or content, returning"<<std::endl;
        return;
      }

      spitfire::string::cStringParser sp(sVersion);
      string_t sMajorVersion;
      sp.GetToStringAndSkip(".", sMajorVersion);
      const string_t sMinorVersion = sp.GetToEnd();
      const int iMajorVersion = spitfire::string::ToUnsignedInt(sMajorVersion);
      const int iMinorVersion = spitfire::string::ToUnsignedInt(sMinorVersion);


      // Get the page
      const string_t sDownloadPage = GetContentOfChildNode(iterPlatform, "page");
      if (sDownloadPage.empty()) {
        LOG<<"cUpdateChecker::_OnTextContentReceived Could not find page node or content, returning"<<std::endl;
        return;
      }

      // Notify the handler
      handler.OnNewVersionFound(iMajorVersion, iMinorVersion, sDownloadPage);
    }
開發者ID:pilkch,項目名稱:library,代碼行數:60,代碼來源:updatechecker.cpp

示例3: add

void cmdline_t::add(
        const string_t& short_name, const string_t& name, const string_t& description,
        const string_t& default_value) const
{
        if (    name.empty() ||
                nano::starts_with(name, "-") ||
                nano::starts_with(name, "--"))
        {
                log_critical("cmdline: invalid option name [" + name + "]");
        }

        if (    !short_name.empty() &&
                (short_name.size() != 1 || short_name[0] == '-'))
        {
                log_critical("cmdline: invalid short option name [" + short_name + "]");
        }

        if (    m_impl->find(name) != m_impl->m_options.end())
        {
                log_critical("cmdline: duplicated option [" + name + "]");
        }

        if (    !short_name.empty() &&
                m_impl->find(short_name) != m_impl->m_options.end())
        {
                log_critical("cmdline: duplicated option [" + short_name + "]");
        }

        m_impl->m_options.emplace_back(short_name, name, description, default_value);
}
開發者ID:accosmin,項目名稱:nano,代碼行數:30,代碼來源:cmdline.cpp

示例4: write_start_element_with_prefix

    void xml_writer::write_start_element_with_prefix(const string_t& elementPrefix, const string_t& elementName, const string_t& namespaceName)
    {
#ifdef WIN32
        HRESULT hr;
        if (FAILED(hr = m_writer->WriteStartElement(elementPrefix.c_str(), elementName.c_str(), namespaceName.empty() ? NULL : namespaceName.c_str())))
        {
            auto error = GetLastError();
            string msg("XML writer WriteStartElement with prefix failed");
            log_error_message(msg, error);
            throw std::runtime_error(msg);
        }
#else 
        xmlChar* valueXmlName = (xmlChar*) ::odata::utility::conversions::to_utf8string(elementName).c_str();
        if (elementPrefix.empty() && namespaceName.empty())
        {
            xmlTextWriterStartElement(m_writer, valueXmlName);
        }
        else
        {
            xmlChar* valueXmlPrefix = elementPrefix.empty() ? NULL : (xmlChar*) ::odata::utility::conversions::to_utf8string(elementPrefix).c_str();
            xmlChar* valueXmlNamespace = namespaceName.empty() ? NULL : (xmlChar*) ::odata::utility::conversions::to_utf8string(namespaceName).c_str();
            xmlTextWriterStartElementNS(m_writer, valueXmlPrefix, valueXmlName, valueXmlNamespace);
        }
#endif
    }
開發者ID:OData,項目名稱:odatacpp-server,代碼行數:25,代碼來源:xmlhelpers.cpp

示例5: U

pplx::task<std::shared_ptr<UserExists>>
GigaApi::UsersApi::userExists (const string_t& login, const string_t& email /* = U("")*/) const
{
    auto uri = api._client.uri (U("userexists"));
    if (!login.empty()) {
        uri.append_query (U("login"), login);
    }
    if (!email.empty()) {
        uri.append_query (U("email"), email);
    }
    return api._client.request<UserExists> (methods::GET, uri);
}
開發者ID:Robien,項目名稱:GiGaSdk,代碼行數:12,代碼來源:UsersApi.cpp

示例6: process

void cmdline_t::process(const int argc, const char* argv[]) const
{
        string_t current_name_or_short_name;

        for (int i = 1; i < argc; ++ i)
        {
                const string_t token = argv[i];
                assert(!token.empty());

                if (nano::starts_with(token, "--"))
                {
                        const string_t name = token.substr(2);

                        if (name.empty())
                        {
                                log_critical(strcat("cmdline: invalid option name [", name, "/", token, "]"));
                        }

                        m_impl->store(name);
                        current_name_or_short_name = name;
                }
                else if (nano::starts_with(token, "-"))
                {
                        const string_t short_name = token.substr(1);

                        if (short_name.size() != 1)
                        {
                                log_critical(strcat("cmdline: invalid short option name [", short_name, "/", token, "]"));
                        }

                        m_impl->store(short_name);
                        current_name_or_short_name = short_name;
                }
                else
                {
                        const string_t& value = token;

                        if (current_name_or_short_name.empty())
                        {
                                log_critical(strcat("cmdline: missing option before value [", value, "]"));
                        }

                        m_impl->store(current_name_or_short_name, value);
                        current_name_or_short_name.clear();
                }
        }

        if (has("help"))
        {
                usage();
        }
}
開發者ID:accosmin,項目名稱:nano,代碼行數:52,代碼來源:cmdline.cpp

示例7: write_attribute_string

    void xml_writer::write_attribute_string(const string_t& prefix, const string_t& name, const string_t& namespaceUri, const string_t& value)
    {
#ifdef WIN32
        HRESULT hr;

        if (FAILED(hr = m_writer->WriteAttributeString(prefix.empty() ? NULL : prefix.c_str(),
            name.empty() ? NULL : name.c_str(),
            namespaceUri.empty() ? NULL : namespaceUri.c_str(),
            value.empty() ? NULL : value.c_str())))
        {
            auto error = GetLastError();
            string msg("XML writer WriteAttributeString failed");
            log_error_message(msg, error);
            throw std::runtime_error(msg);
        }
#else
        xmlChar* nameXml = (xmlChar*) ::odata::utility::conversions::to_utf8string(name).c_str();
        xmlChar* valueXml = (xmlChar*) ::odata::utility::conversions::to_utf8string(value).c_str();
        if (prefix.empty() && namespaceUri.empty())
        {
            xmlTextWriterWriteAttribute(m_writer, nameXml, valueXml);
        }
        else
        {
            xmlChar* valueXmlPrefix = prefix.empty() ? NULL : (xmlChar*) ::odata::utility::conversions::to_utf8string(prefix).c_str();
            xmlChar* valueXmlNamespace = namespaceUri.empty() ? NULL : (xmlChar*) ::odata::utility::conversions::to_utf8string(namespaceUri).c_str();
            xmlTextWriterWriteAttributeNS(m_writer, valueXmlPrefix, nameXml, valueXmlNamespace, valueXml);
        }
#endif
    }
開發者ID:OData,項目名稱:odatacpp-server,代碼行數:30,代碼來源:xmlhelpers.cpp

示例8: OnCompleteCommand

bool Desktop::OnCompleteCommand(const string_t &cmd, int &pos, string_t &result)
{
    assert(pos >= 0);
    lua_getglobal(g_env.L, "autocomplete");
    if( lua_isnil(g_env.L, -1) )
    {
        lua_pop(g_env.L, 1);
        GetConsole().WriteLine(1, "There was no autocomplete module loaded");
        return false;
    }
    lua_pushlstring(g_env.L, cmd.substr(0, pos).c_str(), pos);
    HRESULT hr = S_OK;
    if( lua_pcall(g_env.L, 1, 1, 0) )
    {
        GetConsole().WriteLine(1, lua_tostring(g_env.L, -1));
    }
    else
    {
        const char *str = lua_tostring(g_env.L, -1);
        string_t insert = str ? str : "";

        result = cmd.substr(0, pos) + insert + cmd.substr(pos);
        pos += insert.length();

        if( g_client && !g_client->IsLocal() && !result.empty() && result[0] != '/' )
        {
            result = string_t("/") + result;
            ++pos;
        }
    }
    lua_pop(g_env.L, 1); // pop result or error message
    return true;
}
開發者ID:ACefalu,項目名稱:tzod,代碼行數:33,代碼來源:gui_desktop.cpp

示例9: use_value

void statement::use_value(int pos, string_t const& value, bool make_copy)
{
	s_.check_error( aux::select(::sqlite3_bind_text, ::sqlite3_bind_text16)
		(impl_, pos, value.empty()? 0 : value.c_str(), 
		static_cast<int>(value.size() * sizeof(char_t)), make_copy? SQLITE_TRANSIENT : SQLITE_STATIC)
	);
}
開發者ID:XyzalZhang,項目名稱:SPlayer,代碼行數:7,代碼來源:statement.cpp

示例10: 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();
}
開發者ID:arkenthera,項目名稱:anitomy,代碼行數:31,代碼來源:tokenizer.cpp

示例11: Parse

bool Anitomy::Parse(string_t filename) {
  elements_.clear();
  tokens_.clear();

  if (options_.parse_file_extension) {
    string_t extension;
    if (RemoveExtensionFromFilename(filename, extension))
      elements_.insert(kElementFileExtension, extension);
  }

  if (!options_.ignored_strings.empty())
    RemoveIgnoredStrings(filename);

  if (filename.empty())
    return false;
  elements_.insert(kElementFileName, filename);

  Tokenizer tokenizer(filename, elements_, options_, tokens_);
  if (!tokenizer.Tokenize())
    return false;

  Parser parser(elements_, options_, tokens_);
  if (!parser.Parse())
    return false;

  return true;
}
開發者ID:KasaiDot,項目名稱:anitomy,代碼行數:27,代碼來源:anitomy.cpp

示例12:

logger_t::logger_t(
    string_t const &    name,
    bool                verbose
) :
    _prefix( name.empty() ? "" : name + ": " ),
    _verbose( verbose )
{
}; // ctor
開發者ID:rucoder,項目名稱:ritex,代碼行數:8,代碼來源:logger.cpp

示例13: add_pair

void WordForm::add_pair(const string_t &k_word, string_t trans_part)
{
	if (k_word.empty() || trans_part.empty())
		return;
	//printf("pair %s %s\n", k_word.c_str(), trans_part.c_str());
	char *saveptr;
	const char *delim = " \t\n\v";
	char *token = strtok_r(&trans_part[0], delim, &saveptr);
	base_forms.add(k_word);
	while (token) {
		for (int i = 0; token[i]; ++i) {
			token[i] = tolower(token[i]);
		}
		add(k_word, token);
		//printf("added %s %s\n", k_word.c_str(),  p);
		token = strtok_r(NULL, delim, &saveptr);
	}
}
開發者ID:aababilov,項目名稱:dictutils,代碼行數:18,代碼來源:wordform.cpp

示例14: ToPlain

char Square::ToPlain(const string_t & str)
{
    if (str.empty())
        return ToPlain(Blank);
    char ch = ToPlain(to_unicode(str).at(0));
    if (ch == 0)
        return ToPlain(Blank);
    return ch;
}
開發者ID:mattprintz,項目名稱:wx-xword,代碼行數:9,代碼來源:Square.cpp

示例15: GetTrackTitle

    string_t cPlayListWriter::GetTrackTitle(const cTrack& track) const
    {
      std::cout<<"cPlayListWriter::GetTrackTitle"<<std::endl;

      string_t sFullTitle;

      const string_t sTagArtist = track.sArtist;
      const string_t sTagTitle = track.sTitle;
      if (!sTagArtist.empty() && !sTagTitle.empty()) {
        // Use the artist and title
        sFullTitle = sTagArtist + TEXT(" - ") + sTagTitle;
      } else {
        // Either "title" or "artist" is missing, use the file name
        sFullTitle = filesystem::GetFileNoExtension(track.sFullPath);
      }

      return sFullTitle;
    }
開發者ID:pilkch,項目名稱:library,代碼行數:18,代碼來源:playlist.cpp


注:本文中的string_t::empty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。