• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ string_t类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中string_t的典型用法代码示例。如果您正苦于以下问题:C++ string_t类的具体用法?C++ string_t怎么用?C++ string_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了string_t类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: assert

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


示例2: 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();
}
开发者ID:KasaiDot,项目名称:anitomy,代码行数:7,代码来源:parser_helper.cpp


示例3: WBUFB

CServerMessagePacket::CServerMessagePacket(const string_t message, int8 language, int32 timestamp, int32 message_offset)
{
    this->type = 0x4D;
    this->size = 0x0E;

    WBUFB(data, (0x04) ) = message_offset == 0 ? 1 : 2;
    WBUFB(data, (0x05) ) = 1;
    WBUFB(data, (0x06) ) = 1;
    WBUFB(data, (0x07) ) = language;
    WBUFL(data, (0x08) ) = timestamp == 0 ? time(0) : timestamp;
    WBUFL(data, (0x0C) ) = 0; // Message Length.. (Total)
    WBUFL(data, (0x10) ) = 0; // Message Offset..
    WBUFL(data, (0x14) ) = 0; // Message Length..

    // Ensure we have a message and the requested offset is not outside of the bounds..
    if (message.length() > 0 && message.length() > message_offset)
    {
        int32 msgLength = message.length();
        int32 sndLength = (msgLength - message_offset) > 236 ? 236 : (msgLength - message_offset);

        WBUFL(data, (0x0C) ) = message.length(); // Message Length.. (Total)
        WBUFL(data, (0x10) ) = message_offset;   // Message Offset..
        WBUFL(data, (0x14) ) = sndLength;        // Message Length..

        memcpy((data + (0x18)) , message.c_str() + message_offset, sndLength);

        int32 textSize = sndLength + sndLength % 2;
        this->size = ((((0x14 + textSize) + 4) >> 1) & 0xFE);
    }
开发者ID:Anthiam,项目名称:darkstar,代码行数:29,代码来源:server_message.cpp


示例4: CamelCase

// From CamelCase to snake_case
std::string CamelCase(const string_t & name)
{
    // Replace '_' + a lowercase letter with an upper case letter
    string_t str;
    str.reserve(name.size());
    for (size_t i = 0; i < name.size(); ++i)
    {
        if (i == 0 || name[i] == puzT('_'))
        {
            if (i > 0)
                ++i;
            if (i < name.size())
            {
            #if PUZ_UNICODE
                if (::iswlower(name[i]))
                    str.push_back(::towupper(name[i]));
            #else // ! PUZ_UNICODE
                if (::islower(name[i]))
                    str.push_back(::toupper(name[i]));
            #endif // PUZ_UNICODE/! PUZ_UNICODE
                else // Not lower case: so push both the underscore and letter
                {
                    if (i > 0)
                        str.push_back(name[i-1]);
                    str.push_back(name[i]);
                }
            }
            else if (i > 0) // At the end of the string: push the underscore
                str.push_back(name[i-1]);
        }
        else // Not a hypen: push the letter
            str.push_back(name[i]);
    }
    return encode_utf8(str);
}
开发者ID:oeuftete,项目名称:wx-xword,代码行数:36,代码来源:xml.cpp


示例5: MatchTypeAndEpisodePattern

bool Parser::MatchTypeAndEpisodePattern(const string_t& word, Token& token) {
  size_t number_begin = FindNumberInString(word);
  auto prefix = word.substr(0, number_begin);

  ElementCategory category = kElementAnimeType;
  KeywordOptions options;

  if (keyword_manager.Find(keyword_manager.Normalize(prefix),
                           category, options)) {
    elements_.insert(kElementAnimeType, prefix);
    auto number = word.substr(number_begin);
    if (MatchEpisodePatterns(number, token) ||
        SetEpisodeNumber(number, token, true)) {
      auto it = std::find(tokens_.begin(), tokens_.end(), token);
      if (it != tokens_.end()) {
        // Split token (we do this last in order to avoid invalidating our
        // token reference earlier)
        token.content = number;
        tokens_.insert(it, Token(options.identifiable ? kIdentifier : kUnknown,
                                 prefix, token.enclosed));
      }
      return true;
    }
  }

  return false;
}
开发者ID:KasaiDot,项目名称:anitomy,代码行数:27,代码来源:parser_number.cpp


示例6: IsResolution

bool Parser::IsResolution(const string_t& str) {
  // Using a regex such as "\\d{3,4}(p|(x\\d{3,4}))$" would be more elegant,
  // but it's much slower (e.g. 2.4ms -> 24.9ms).

  const size_t min_width_size = 3;
  const size_t min_height_size = 3;

  // *###x###*
  if (str.size() >= min_width_size + 1 + min_height_size) {
    size_t pos = str.find_first_of(L"xX\u00D7");  // multiplication sign
    if (pos != str.npos &&
        pos >= min_width_size &&
        pos <= str.size() - (min_height_size + 1)) {
      for (size_t i = 0; i < str.size(); i++)
        if (i != pos && !IsNumericChar(str.at(i)))
          return false;
      return true;
    }

  // *###p
  } else if (str.size() >= min_height_size + 1) {
    if (str.back() == L'p' || str.back() == L'P') {
      for (size_t i = 0; i < str.size() - 1; i++)
        if (!IsNumericChar(str.at(i)))
          return false;
      return true;
    }
  }

  return false;
}
开发者ID:KasaiDot,项目名称:anitomy,代码行数:31,代码来源:parser_helper.cpp


示例7: GetDelimiters

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


示例8: linking_procedure

// Creates a string of neighboring edge pixels.
inline
void
linking_procedure(string_t &string, unsigned char *binary_image, const size_t image_width, const size_t image_height, const int x_ref, const int y_ref, const double half_width, const double half_height)
{
	/* Leandro A. F. Fernandes, Manuel M. Oliveira
	 * Real-time line detection through an improved Hough transform voting scheme
	 * Pattern Recognition (PR), Elsevier, 41:1, 2008, 299-314.
	 *
	 * Algorithm 5
	 */

	int x, y;

	string.clear();
	
	// Find and add feature pixels to the end of the string.
	x = x_ref;
	y = y_ref;
	do
	{
		pixel_t &p = string.push_back();
		
		p.x_index = x;
		p.y_index = y;

		p.x = x - half_width;
		p.y = y - half_height;

		binary_image[y*image_width+x] = 0;
	}
	while (next( x, y, binary_image, image_width, image_height ));

	pixel_t temp;
	for (size_t i=0, j=string.size()-1; i<j; ++i, --j)
	{
		temp = string[i];
		string[i] = string[j];
		string[j] = temp;
	}

	// Find and add feature pixels to the begin of the string.
	x = x_ref;
	y = y_ref;
	if (next( x, y, binary_image, image_width, image_height ))
	{
		do
		{
			pixel_t &p = string.push_back();

			p.x_index = x;
			p.y_index = y;

			p.x = x - half_width;
			p.y = y - half_height;

			binary_image[y*image_width+x] = 0;
		}
		while (next( x, y, binary_image, image_width, image_height ));
	}
}
开发者ID:project-capo,项目名称:amber-java-drivers,代码行数:61,代码来源:linking.cpp


示例9: defined

    virtual bool open_file
    (io::read::file& file, const string_t& line,
     const string_t& name, bool mode_is_binary = false) {
        size_t length;

        if ((line.has_chars(length))) {
#if defined(__GNUC__)
            char_t chars[length + 3];
#else // defined(__GNUC__)
            nadir::arrayt<char_t> a(length + 3);
            char_t* chars = a.elements();
#endif // defined(__GNUC__)

            if ((file.open(name.chars(), (mode_is_binary)
                ?(file.mode_read_binary()):(file.mode_read())))) {
                if (!((length + 2) != (file.read(chars, length + 2)))) {
                    if (!(line.compare(chars, length))) {
                        if (!((cr_ != chars[length]) || (lf_ != chars[length+1]))) {
                            return true;
                        }
                    }
                }
                file.close();
            }
        }
        return false;
    }
开发者ID:medusade,项目名称:coral,代码行数:27,代码来源:main.hpp


示例10: 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()));
      }
    }
  }
}
开发者ID:tofuness,项目名称:anitomy-js,代码行数:26,代码来源:keyword.cpp


示例11: 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


示例12: exception_sys_t

file_t::file_t(char const *name, string_t const &header) :
	ref_cnt(0), fd(-1), used(false), id() {

	if(config::check)
		return;

	fd = ::open(name, O_WRONLY | O_APPEND | O_CREAT, 0644);
	if(fd < 0)
		throw exception_sys_t(log::error, errno, "open (%s): %m", name);

	fd_guard_t guard(fd);

	id = id_t(fd, used);
	if(!id)
		throw exception_sys_t(log::error, errno, "fstat (%s): %m", name);

	if(::flock(fd, LOCK_SH | LOCK_NB) < 0)
		throw exception_sys_t(log::error, errno, "flock (%s): %m", name);

	if(header) {
		if(::write(fd, header.ptr(), header.size()) < 0)
			throw exception_sys_t(log::error, errno, "write (%s): %m", name);
	}

	guard.relax();
}
开发者ID:MarishaYasko,项目名称:phantom,代码行数:26,代码来源:log_file.C


示例13: 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


示例14: test_1_01

static void test_1_01()
{
    PAN_CHAR_T      hostname[1000];
    const string_t  hid = pan_get_hid_();

    { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(hostname); ++i)
    {
        ::memset(&hostname[0], 0, sizeof(hostname));

        const size_t len = pantheios::getHostName(&hostname[0], i);

        if(len == i)
        {
            // The function did not have enough space to write in, so it
            // will return the length passed to it ...
            XTESTS_TEST_INTEGER_EQUAL(i, len);
            // ... and will not have written anything to the file
            XTESTS_TEST_STRING_EQUAL(PANTHEIOS_LITERAL_STRING(""), hostname);
        }
        else
        {
            // The function had enough space, so it will return the length
            // of the intended hostname ...
            XTESTS_TEST_INTEGER_EQUAL(hid.size(), len);
            // ... and will have written the hostname
            XTESTS_TEST_STRING_EQUAL(hid, hostname);
        }
    }}
}
开发者ID:wqjkdqj,项目名称:Palabos,代码行数:29,代码来源:test.unit.util.gethostname.cpp


示例15: 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;
    }
开发者ID:Adrian-Revk,项目名称:openmw,代码行数:28,代码来源:keywordsearch.hpp


示例16: build_shmem

	bool
	build_shmem( string_t const& name, size_t const size, shmem_t & shmem, shmem_region_t & shmem_region, T*& p ) {
		//
		bool const create = ( size > 0 );
		if ( create ) {
			shmem = shmem_t( 
				new boost::interprocess::windows_shared_memory( 
						boost::interprocess::create_only,
						name.c_str(),
						boost::interprocess::read_write,
						size )
					);
		} else {
			shmem = shmem_t( 
						new boost::interprocess::windows_shared_memory(
						boost::interprocess::open_only,
						name.c_str(),
						boost::interprocess::read_write )
					);
		}
		shmem_region = shmem_region_t(
							new boost::interprocess::mapped_region(
								*(shmem.get()),
								boost::interprocess::read_write )
						);
		//
		p = static_cast< T* >( shmem_region->get_address() );
		if ( create && p ) {
			memset( p, 0, size );
		}
		return true;
	}
开发者ID:VladyslavKurmaz,项目名称:cpp-atom,代码行数:32,代码来源:cons_mpp.hpp


示例17: Replace

//---------------------------------------------------------------------------
void WordMacros::Replace(const string_t& text, const string_t& repl)
{
  // обходим проблему текста длинее 255 символов
  const size_t MAX_REPL_LEN = 200;
  if (repl.size() > MAX_REPL_LEN)
  {
    string_t newText;
    std::vector<string_t> rs;
    for (size_t i = 0; i < repl.size(); i+= MAX_REPL_LEN)
    {
      newText += text + aux::itow(rs.size());
      rs.push_back(repl.subString(i, MAX_REPL_LEN));
    }
    Replace(text, newText);
    for (size_t i = 0; i < rs.size(); ++i)
      Replace(text + aux::itow(i), rs[i]);
    return;
  }

  m_Macros += "With Selection.Find \n";
  m_Macros += "   .ClearFormatting \n";
  m_Macros += "   .Replacement.ClearFormatting \n";
  m_Macros += "   .Text = \"" + text +"\" \n";
  m_Macros += "   .Replacement.Text = \"" + repl +"\" \n";
  m_Macros += "   .Execute Replace:=wdReplaceAll \n";
  m_Macros += "End With \n";
  IsLarge();
}
开发者ID:txe,项目名称:ieml,代码行数:29,代码来源:WordMacro.cpp


示例18: 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
}
开发者ID:lamogui,项目名称:libtools,代码行数:27,代码来源:decoder.cpp


示例19: RemoveExtensionFromFilename

bool Anitomy::RemoveExtensionFromFilename(string_t& filename,
                                          string_t& extension) {
  const size_t position = filename.find_last_of(L'.');

  if (position == string_t::npos)
    return false;

  extension = filename.substr(position + 1);

  const size_t max_length = 4;
  if (extension.length() > max_length)
    return false;

  if (!IsAlphanumericString(extension))
    return false;

  // TODO: Add an option for this
  auto keyword = StringToUpperCopy(extension);
  if (!keyword_manager.Find(kElementFileExtension, keyword))
    return false;

  filename.resize(position);

  return true;
}
开发者ID:vevix,项目名称:anitomy,代码行数:25,代码来源:anitomy.cpp


示例20: addr

void FtpHelper::UploadFile(string_t ftpAddr, string_t fileName)
{
	url addr(ftpAddr);
	HINTERNET hInternet;
	HINTERNET hFtpSession;
	hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
	if (hInternet == NULL)
	{
		return;
	}
	else
	{		
		auto user = addr.user_.empty() ? string_t(L"Anonymous") : addr.user_;
		auto passw = addr.passw_.empty() ? string_t(L"Anonymous") : addr.passw_;

		hFtpSession = InternetConnect(hInternet, addr.host_.c_str(), INTERNET_DEFAULT_FTP_PORT, user.c_str(), passw.c_str(), INTERNET_SERVICE_FTP, 0, 0);
		if (hFtpSession == NULL)
		{
			return;
		}
		else
		{
			auto filepart = string_t(PathFindFileName(fileName.c_str()));
			if (!FtpPutFile(hFtpSession, fileName.c_str(), addr.path_.c_str(), FTP_TRANSFER_TYPE_BINARY, INTERNET_FLAG_PASSIVE))
			{
				return;
			}
		}
	}

}
开发者ID:flcl42,项目名称:remote-console,代码行数:31,代码来源:FtpHelper.cpp



注:本文中的string_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ string_type类代码示例发布时间:2022-05-31
下一篇:
C++ string_ref类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap