当前位置: 首页>>代码示例>>C++>>正文


C++ string::cend方法代码示例

本文整理汇总了C++中std::string::cend方法的典型用法代码示例。如果您正苦于以下问题:C++ string::cend方法的具体用法?C++ string::cend怎么用?C++ string::cend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::string的用法示例。


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

示例1: getMetaData

void Parser::getMetaData(const std::string &data, MetaData &metadatas)
{
    const char comma = ',';
    auto find_str = std::find(data.cbegin(), data.cend(), comma );
    if ( find_str == data.cend() ) {
        return;
    } else {
        auto container = splitStringBy( data, comma );
        for( const auto &i: container ){
            if( i.find( "input" ) != std::string::npos ) {
                metadatas.input = getValue( i );
            } else if ( i.find( "lang" ) != std::string::npos ) {
                metadatas.lang = Tokens::getLanguage( getValue( i ) );
            } else if ( i.find( "run" ) != std::string::npos ) {
                metadatas.run_code = ( getValue( i ) == std::string { "true" } ? true :
                                getValue( i ) == std::string { "1" } ? true : false );
            } else if ( i.find( "private" ) != std::string::npos ) {
                metadatas.privacy = ( getValue( i ) == std::string { "true" } ? true :
                                getValue( i ) == std::string { "1" } ? true : false );
            }
        }
    }
    printf("MetaData: input => %s -- n_code => %s -- lang = %d -- run_code => %d -- privacy => %d\n",
            metadatas.input.c_str(), metadatas.n_code.c_str(), (int)metadatas.lang, (int)metadatas.run_code,
            metadatas.privacy );
}
开发者ID:iamOgunyinka,项目名称:QuincePad,代码行数:26,代码来源:parser.cpp

示例2: getCodeTagAttributes

inline void Parser::getCodeTagAttributes( const std::string &text, std::string &data )
{
    auto find_iter = std::find( text.cbegin(), text.cend(), ']' );
    if( find_iter != text.cend() && find_iter != text.crend().base() ) {
        data = std::string( text.cbegin(), find_iter + 1 );
    }
}
开发者ID:iamOgunyinka,项目名称:QuincePad,代码行数:7,代码来源:parser.cpp

示例3: Tokenize

std::vector<std::string> Tokenize(const std::string& source, const std::string& delimiters, bool removeDelim /*= true*/)
{
	auto head = source.cbegin();
	std::vector<std::string> tokens;
	for (auto tail = source.cbegin(); tail != source.cend(); ++tail)
	{
		for (auto it = delimiters.cbegin(); it != delimiters.cend(); ++it)
		{
			const auto& delimiter = *it;

			if ((*tail == delimiter))
			{
				if (head != tail)
					tokens.push_back(std::string(head, tail));

				if (removeDelim)
					head = tail + 1;
				else
					head = tail;
			}
		}
	}

	if (head != source.cend())
		tokens.push_back(std::string(head, source.cend()));
	return tokens;
}
开发者ID:Luckymee,项目名称:INB381,代码行数:27,代码来源:objloader.cpp

示例4: run

	void run(const size_t messageCount){
		const size_t stringSize = 25;
		assert(stringSize <= TestClient::bufferSize);

		for(size_t i = 0; i < messageCount; ++i){
			const std::string currentString = TestClient::randomString(stringSize);
			std::copy(currentString.cbegin(), currentString.cend(), this->buffer.get());

			const ssize_t sendRes = send(this->serverSocketDescriptor, this->buffer.get(), stringSize, 0);
			if(sendRes == -1){
				throw std::runtime_error(std::string("send error: ") + strerror(errno));
			}

			std::cout << "Sent string:     '" << currentString << "'" << std::endl;

			const ssize_t recvRes = recv(this->serverSocketDescriptor, this->buffer.get(), TestClient::bufferSize, 0);
			if(recvRes == -1){
				throw std::runtime_error(std::string("recv error: ") + strerror(errno));
			}

			std::cout << "Recieved string: '";
			for(ssize_t pos = 0; pos < recvRes; ++pos){
				std::cout << this->buffer[pos];
			}

			std::cout << "'" << std::endl;

			const bool isEqual = std::equal(currentString.cbegin(), currentString.cend(), this->buffer.get());
			if(isEqual == false){
				throw std::runtime_error("reply is not equal");
			}

		}
	}
开发者ID:LibertyPaul,项目名称:TCPEchoServer,代码行数:34,代码来源:TestClient.hpp

示例5:

	/**! ctor from a line **/
	Sam (const std::string& line)
	{
		std::string::const_iterator iter1 {line.cbegin ()}, iter2 {line.cbegin ()};
		while (*++iter2 != '\t');
		QNAME = std::string {iter1, iter2};
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		FLAG = std::bitset<SAM_FLAG::FLAG_SIZE> {std::stoul (std::string {iter1, iter2})};
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		RNAME = std::string {iter1, iter2};
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		POS = std::stoul (std::string {iter1, iter2});
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		MAPQ = std::stoi (std::string {iter1, iter2});
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		CIGAR = std::string {iter1, iter2};
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		RNEXT = std::string {iter1, iter2};
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		PNEXT = std::stoul (std::string {iter1, iter2});
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		TLEN = std::stol (std::string {iter1, iter2});
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		SEQ = std::string {iter1, iter2};
		iter1 = ++iter2;

		while (*++iter2 != '\t');
		QUAL = std::string {iter1, iter2};
		std::string Tag, Value;
		while (iter2 != line.cend ())
		{
			iter1 = ++iter2;
			iter2 += 2;
			Tag = std::string {iter1, iter2};
			iter1 += 5;
			while ( (*iter2 != '\t') && (iter2 != line.cend()))
				++iter2;
			Value = std::string {iter1, iter2};
			OPTIONAL_FIELDS.insert (std::make_pair (Tag, Value));
		}
	}
开发者ID:BioinformaticsArchive,项目名称:piPipes,代码行数:59,代码来源:piPipes_sam.hpp

示例6: Add

void OCLProgramBuilder::Add(const std::string& programString)
{
    if (find(programString.cbegin(), programString.cend(), '$') != programString.cend())
    {
        auto prg = CreateNumberedVersions(programString);
        programBuilder << prg;
    }
    else
    {
        programBuilder << programString;
    }	
}
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:12,代码来源:OCLProgramBuilder.cpp

示例7: AddCode

void OCLProgramUnit::AddCode(const std::string code)
{
    if (find(code.cbegin(), code.cend(), '$') != code.cend())
    {
        auto prg = CreateNumberedVersions(code);
        codeBuilder << endl << prg << endl;
    }
    else
    {
        codeBuilder << endl << code << endl;
    }
}
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:12,代码来源:OCLProgramUnit.cpp

示例8: add_code

void ocl_program_unit::add_code(const std::string code)
{
    if (find(code.cbegin(), code.cend(), '$') != code.cend())
    {
        auto prg = create_numbered_versions(code);
        codeBuilder << endl << prg << endl;
    }
    else
    {
        codeBuilder << endl << code << endl;
    }
}
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:12,代码来源:ocl_program_unit.cpp

示例9: decodeList

    void decodeList(const std::string& encodedString, std::vector<sf::String>& list)
    {
        std::string item;

        for (auto it = encodedString.cbegin(); it != encodedString.cend(); ++it)
        {
            // Check if the character is an escape character
            if (*it == '\\')
            {
                auto next = it + 1;

                if (next == encodedString.cend())
                {
                    TGUI_OUTPUT("TGUI warning: Escape character at the end of the string. Ignoring character.");
                    continue;
                }
                else if ((*next == '\\') || (*next == '\"') || (*next == ','))
                {
                    item += *next;
                    ++it;
                }
                else if (*next == 'n')
                {
                    item += '\n';
                    ++it;
                }
                else if (*next == 't')
                {
                    item += '\t';
                    ++it;
                }
                else
                {
                    TGUI_OUTPUT(std::string("TGUI warning: Escape character in front of '") + *next + "'. Ignoring escape character.");
                    continue;
                }
            }
            else // No escape character
            {
                // Check if the next item starts here
                if (*it == ',')
                {
                    list.push_back(item);
                    item = "";
                }
                else // Just a normal character to be added to the string
                    item += *it;
            }
        }

        if (!item.empty())
            list.push_back(item);
    }
开发者ID:DalikarFT,项目名称:dndgame,代码行数:53,代码来源:TGUI.cpp

示例10: isCodeValid

bool Board::isCodeValid(const std::string &code)
{
    //check length
    if (code.length() != m_codeLength)
        return false;

    //check for invalid color code
    auto it = std::find_if(code.cbegin(), code.cend(),
                           [this](char c) {
        return (m_pegsColor.find(tolower(c)) == std::string::npos);
    });

    return it == code.cend();
}
开发者ID:cckwes,项目名称:consoleMastermind,代码行数:14,代码来源:board.cpp

示例11: matchre

  boost::optional<std::string> matchre(std::string pattern)
  {
    boost::optional<std::string> maybe_token;

    /* FIXME: Not thread-safe.  */
    static std::unordered_map<std::string, std::regex *>_lookup;
    std::regex *rep;
    if (_lookup.count(pattern) == 0)
      {
	rep = new std::regex(pattern);
	_lookup[pattern] = rep;
      }
    else
      rep = _lookup[pattern];
    std::regex& re = *rep;

    /* Multiline is the default.  */
    std::regex_constants::match_flag_type flags = std::regex_constants::match_continuous;
    if (_pos > 0)
      flags |= std::regex_constants::match_prev_avail;
#ifdef BOOST_REGEX
    flags |= std::regex_constants::match_not_dot_newline;
#endif

    std::smatch match;
    int cnt = std::regex_search(_text.cbegin() + _pos, _text.cend(), match, re, flags);
    if (cnt > 0)
      {
	maybe_token = match[0];
	_pos += match[0].length();
      }

    return maybe_token;
  }
开发者ID:lambdafu,项目名称:grakopp,代码行数:34,代码来源:buffer.hpp

示例12: main

int main(int argc, char* argv[])
{
    // コマンドラインパース
    auto const command_line = process_command_line(argc, argv);

    // グラフファイルを開いてgraph_dataに導入
    std::ifstream ifs_graph(command_line.network);
    std::string const graph_data{std::istreambuf_iterator<char>(ifs_graph), std::istreambuf_iterator<char>()};
    ifs_graph.close();
    std::cout << "Loaded Graph: Length = " << graph_data.size() << std::endl;

    // graph_dataよりグラフパース
	bn::graph_t graph;
    bn::database_t data;
    std::tie(graph, data) = bn::serializer::bif().parse(graph_data.cbegin(), graph_data.cend());
    std::cout << "Parsed Graph: Num of Node = " << graph.vertex_list().size() << std::endl;

    // リンクファイルがあるなら,そのリンク状態にする
    if(command_line.link_info)
    {
        // 全てのリンクを削除
        graph.erase_all_edge();

        // リンクファイル読み込み
        std::ifstream ifs(command_line.link_info.get());
        bn::serializer::csv().load(ifs, graph);
        ifs.close();
    }

    // 書出
    std::ofstream ofs(command_line.output);
    bn::serializer::dot().write(ofs, graph, data);
    ofs.close();
}
开发者ID:godai0519,项目名称:NITTC-GraduationResearch,代码行数:34,代码来源:main.cpp

示例13: check_contains_non_digit

bool check_contains_non_digit(std::string w)
{
  for(auto i=w.cbegin();i != w.cend();++i)
    if(!isdigit(*i))
      return true;
  return false;
}
开发者ID:denismatveev,项目名称:st-online,代码行数:7,代码来源:myphonebook.cpp

示例14: ParsePartitionDirectoryName

static std::optional<PartitionType> ParsePartitionDirectoryName(const std::string& name)
{
  if (name.size() < 2)
    return {};

  if (!strcasecmp(name.c_str(), "DATA"))
    return PartitionType::Game;
  if (!strcasecmp(name.c_str(), "UPDATE"))
    return PartitionType::Update;
  if (!strcasecmp(name.c_str(), "CHANNEL"))
    return PartitionType::Channel;

  if (name[0] == 'P' || name[0] == 'p')
  {
    // e.g. "P-HA8E" (normally only used for Super Smash Bros. Brawl's VC partitions)
    if (name[1] == '-' && name.size() == 6)
    {
      const u32 result = Common::swap32(reinterpret_cast<const u8*>(name.data() + 2));
      return static_cast<PartitionType>(result);
    }

    // e.g. "P0"
    if (std::all_of(name.cbegin() + 1, name.cend(), [](char c) { return c >= '0' && c <= '9'; }))
    {
      u32 result;
      if (TryParse(name.substr(1), &result))
        return static_cast<PartitionType>(result);
    }
  }

  return {};
}
开发者ID:AdmiralCurtiss,项目名称:dolphin,代码行数:32,代码来源:DirectoryBlob.cpp

示例15: _fillDigits

void HugeInteger::_fillDigits(const std::string &a_digits)
{
    size_t digit = {0};

    for (auto cit = a_digits.cbegin(); cit != a_digits.cend(); ++cit, ++digit)
        m_integers.at(digit) = *cit - '0';
}
开发者ID:Grayninja,项目名称:General,代码行数:7,代码来源:HugeInteger.cpp


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