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


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

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


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

示例1: insertRateIntoMap

void DepositFileSource::insertRateIntoMap(std::string tenorStr, double liborRate, Market market, map<long, double>* depositRateMap, map<long, double>* overnightRateMap){
	date startDate = dateUtil::dayRollAdjust(dateUtil::getToday(),enums::Following,market.getMarketEnum());	
	char tenorUnit = *tenorStr.rbegin();
	int tenorNum = std::stoi(tenorStr.substr(0,tenorStr.size()-1)); // 2
	if (tenorUnit != 'D')
		startDate = dateUtil::getBizDateOffSet(startDate,market.getBusinessDaysAfterSpot(enums::SWAP),market.getMarketEnum()); // day after spot adjust

	long JDN = dateUtil::getEndDate(startDate,tenorNum, market.getDayRollCashConvention(), market.getMarketEnum(), dateUtil::getDateUnit(tenorUnit)).getJudianDayNumber();
	if (tenorUnit == 'D'){
		overnightRateMap->insert(pair<long, double>(tenorNum, liborRate));
		cout << market.getNameString()<< " -> tenor[" << tenorStr <<"], accrual start["<<startDate.toString()<<"], duration ["
			<<tenorNum <<"], deposit rate["<< liborRate << "]"<<endl;
	}else{
		date accrualEndDate(JDN);
		depositRateMap->insert(pair<long, double>(JDN, liborRate));
		cout << market.getNameString()<< " -> tenor[" << tenorStr<<"], accrual start["<<startDate.toString()<<"], accrual end["
			<<accrualEndDate.toString() <<"], deposit rate["<< liborRate << "]"<<endl;
	}
}
开发者ID:wbzhang2007,项目名称:DymonRepo-1,代码行数:19,代码来源:DepositFileSource.cpp

示例2: ChopTrailingChars

 //-----------------------------------------------------------------------
 void ChopTrailingChars( std::string& str, s8 inbyChar)
 {
     u32 udwNumCharsToRemove = 0;
     for(std::string::reverse_iterator it = str.rbegin(); it != str.rend(); ++it)
     {
         if((*it) == inbyChar)
         {
             ++udwNumCharsToRemove;
         }
         else
         {
             break;
         }
     }
     
     if(udwNumCharsToRemove > 0)
     {
         Chop(str, udwNumCharsToRemove);
     }
 }
开发者ID:DNSMorgan,项目名称:ChilliSource,代码行数:21,代码来源:StringUtils.cpp

示例3: Get_Directory_Of_File

std::string Builder::Get_Directory_Of_File(std::string const& path){

	std::string return_value = "/";

	bool slash_found = false;

	for (auto it = path.rbegin(); it != path.rend(); ++it){
		if (!slash_found){
			if (*it == '/'){
				slash_found = true;
			}
		}else{
			return_value = *it + return_value;
		}
	}



	return return_value;
}
开发者ID:Jstd,项目名称:Jstd,代码行数:20,代码来源:builder.cpp

示例4: removePseudoAsterisks

        size_t removePseudoAsterisks(std::string & phrase)
        {
            size_t pseudoAsterisksCount = 0;

            if( !phrase.empty() )
            {
                std::string::reverse_iterator rit = phrase.rbegin();

                const char specialPseudoAsteriskCharacter = 127;
                while( rit != phrase.rend() && *rit == specialPseudoAsteriskCharacter )
                {
                    pseudoAsterisksCount++;
                    ++rit;
                }
            }

            phrase = phrase.substr(0, phrase.length() - pseudoAsterisksCount);

            return pseudoAsterisksCount;
        }
开发者ID:A1-Triard,项目名称:openmw,代码行数:20,代码来源:hypertextparser.cpp

示例5: split

/**
 * Remove ':' at the end of the path, split and remove empty elements.
 */
std::vector<std::string> prep_path(std::string path) {

    // If path ends with colon, remove it.
    if (*path.rbegin() == ':') {
        path = path.substr(0, path.size() - 1);
    }

    // split path
    std::vector<std::string> path_splited = split(path, '/');

    // remove empty elements
    for (int i = 0; i < path_splited.size(); i++) {
        if (path_splited[i] == "") {
            path_splited.erase(path_splited.begin() + i);
            i = 0;
        }
    }

    return path_splited;
}
开发者ID:matheussampaio,项目名称:IT279,代码行数:23,代码来源:dir.cpp

示例6: get_file_extension

std::string get_file_extension(const std::string& filename)
{
  std::string::const_reverse_iterator rit;
  std::string result;

  // search for the first dot from the end of the string
  for (rit=filename.rbegin(); rit!=filename.rend(); ++rit) {
    if (is_path_separator(*rit))
      return result;
    else if (*rit == '.')
      break;
  }

  if (rit != filename.rend()) {
    std::copy(std::string::const_iterator(rit.base()), filename.end(),
              std::back_inserter(result));
  }

  return result;
}
开发者ID:BlueHeisenberg,项目名称:aseprite,代码行数:20,代码来源:path.cpp

示例7: write_channels

std::string Relais::write_channels(std::string channels)
{
//     int input_int=0; 
//     std::string::iterator i;
//     int counter=0;
//     for (i=channels.begin(); i!=channels.end(); i++)
//     {
//       counter++;
//        if (*i!= '0'&&*i!= '1') return "Input error";
//        else if (*i= '1') input_int+= std::pow(2,counter-1);
// //        std::cout<<std::pow(2,counter-1)<<" "<< std::hex<<input_int<<std::endl;
//     }
    std::string tmp(channels.rbegin(),channels.rend()); //Reverse to keep the endian straight!
    channels = tmp;
    this->channel_bench = std::bitset<8>(channels);

    std::string s;
    s.clear();
    s = "\xf0";
    s += static_cast<char>(this->channel_bench.to_ulong());
    std::string  answer=this->inputOutput(s);
    std::bitset<8> answerBS;
    answerBS = (long unsigned int) answer[0];
    if(!answer.c_str()==static_cast<char>(this->channel_bench.to_ulong()))  std::cout << "Relais: SET ERROR: Relais answered"  << answer << " (" << answerBS << ")" << std::endl;

    
    std::bitset<8> helper;
    helper.reset();
    std::string debugString;
    debugString.clear();
    for (int i = 0; i < s.size(); i++)
    {
      helper = static_cast<long unsigned int>(s[i]);
      debugString += helper.to_string();
    }
    
    
 std::cout << "Relais: SET COMMAND: " << s << " = " << debugString << " (" << channels << " = "  << channel_bench.to_string() << " = " << static_cast<char>(this->channel_bench.to_ulong()) << ")" << std::endl;
 //return  read_channels();
 return channel_bench.to_string();
}
开发者ID:jmankiewicz,项目名称:lughos,代码行数:41,代码来源:Relais.cpp

示例8: fast_getline

 inline bool fast_getline(std::string& line, FILE* input = stdin)
 {
     line.clear();
     static const size_t max_buffer = 65536;
     char buffer[max_buffer];
     bool done = false;
     while (!done) {
         if (!fgets(buffer, max_buffer, input)) {
             if (!line.size()) {
                 return false;
             } else {
                 done = true;
             }
         }
         line += buffer;
         if (*line.rbegin() == '\n') {
             done = true;
         }
     }
     return true;
 }
开发者ID:AndryLeon,项目名称:zsearch,代码行数:21,代码来源:engine_simple_main.cpp

示例9: lock

    void
    TeaSafe::addFile(std::string const &path)
    {
        StateLock lock(m_stateMutex);
        std::string thePath(path);
        char ch = *path.rbegin();
        // file entries with trailing slash should throw
        if (ch == '/') {
            throw TeaSafeException(TeaSafeError::IllegalFilename);
        }

        SharedTeaSafeFolder parentEntry = doGetParentTeaSafeFolder(thePath);
        if (!parentEntry) {
            throw TeaSafeException(TeaSafeError::NotFound);
        }

        // throw if already exists
        throwIfAlreadyExists(path);

        parentEntry->addTeaSafeFile(boost::filesystem::path(thePath).filename().string());
    }
开发者ID:iwpiv,项目名称:teasafe,代码行数:21,代码来源:TeaSafe.cpp

示例10:

static void
DumpStringToStreamWithNewline (Stream &strm, const std::string &s, bool add_newline_if_empty)
{
    bool add_newline = false;
    if (s.empty())
    {
        add_newline = add_newline_if_empty;
    }
    else
    {
        // We already checked for empty above, now make sure there is a newline
        // in the error, and if there isn't one, add one.
        strm.Write(s.c_str(), s.size());

        const char last_char = *s.rbegin();
        add_newline = last_char != '\n' && last_char != '\r';

    }
    if (add_newline)
        strm.EOL();
}
开发者ID:filcab,项目名称:lldb,代码行数:21,代码来源:CommandReturnObject.cpp

示例11: generate_permutations

static void generate_permutations(const std::string& i_str, StringSet& permutations)
{
    permutations.insert(i_str);
    bool starts_with_wildcard(char_to_modifier(*i_str.begin()) != InvalidModifier), 
         ends_with_wildcard(char_to_modifier(*i_str.rbegin()) != InvalidModifier);
    if (!starts_with_wildcard && !ends_with_wildcard)
    {
        return;
    }
    else
    {
        if (starts_with_wildcard)
        {
            generate_permutations(i_str.substr(1), permutations); // _xxxx -> xxxx
        }
        if (ends_with_wildcard)
        {
            generate_permutations(i_str.substr(0, i_str.size()-1), permutations); // xxxx_ -> xxxx
        }
    }
}
开发者ID:dcastroviejo,项目名称:peterbourgon.wordsmith,代码行数:21,代码来源:Expression.cpp

示例12: get_next

  void get_next(){

    bool comment; 
    do{
      
      if(!std::getline(input, next_line)){
        has_next = false;
      }
      else{

        comment = false;
        next_line_idx++;

        // strip trailing carriage return, if any
        if(next_line.length() > 0 && *(next_line.rbegin()) == '\r')
          next_line.resize(next_line.size()-1);
        
        // convert to lowercase
        strlower(next_line);

        // Append a space, to catch blank comment lines (e.g. "c\n") that would otherwise not meet
        // the MCNP comment card spec ("a C anywhere in columns 1-5 followed by at least one blank.")
        // I have seen lines like "c\n" or " c\n" as complete comment cards in practice, so MCNP must 
        // accept them.
        next_line.append(" ");

        // We want to find "c " within the first five
        // columns, but not if the c has anything other than a space before it.
        size_t idx = next_line.find("c ");
        if( idx < 5 ){
          if( idx == 0 || next_line.at(idx-1) == ' '){
            comment = true;
          }
        }
      }
    }
    while( has_next && comment );
    // iterate until next_line is not a comment line.

  }
开发者ID:Pshriwise,项目名称:mcnp2cad,代码行数:40,代码来源:MCNPInput.cpp

示例13: parseName

    HostAndPort parseName(std::string const& str)
    {
        // Attempt to find the first and last non-whitespace
        auto const find_whitespace = std::bind (
            &std::isspace <std::string::value_type>,
            std::placeholders::_1,
            std::locale ());

        auto host_first = std::find_if_not (
            str.begin (), str.end (), find_whitespace);

        auto port_last = std::find_if_not (
            str.rbegin (), str.rend(), find_whitespace).base();

        // This should only happen for all-whitespace strings
        if (host_first >= port_last)
            return std::make_pair(std::string (), std::string ());

        // Attempt to find the first and last valid port separators
        auto const find_port_separator = [](char const c) -> bool
        {
            if (std::isspace (c))
                return true;

            if (c == ':')
                return true;

            return false;
        };

        auto host_last = std::find_if (
            host_first, port_last, find_port_separator);

        auto port_first = std::find_if_not (
            host_last, port_last, find_port_separator);

        return make_pair (
            std::string (host_first, host_last),
            std::string (port_first, port_last));
    }
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:40,代码来源:ResolverAsio.cpp

示例14:

bool
SyntaxTree::wildCardMatch(std::string name, std::string search_string)
{
  // Assume that an empty string matches anything
  if (search_string == "")
    return true;

  // transform to lower for case insenstive matching
  std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))std::toupper);
  std::transform(search_string.begin(), search_string.end(), search_string.begin(), (int(*)(int))std::toupper);

  // exact match!
  if (search_string.find("*") == std::string::npos)
    return search_string == name;

  // wildcard
  std::vector<std::string> tokens;
  MooseUtils::tokenize(search_string, tokens, 1, "*");

  size_t pos = 0;
  for (unsigned int i=0; i<tokens.size() && pos != std::string::npos; ++i)
  {
    pos = name.find(tokens[i], pos);
    // See if we have a leading wildcard
    if (search_string[0] != '*' && i == 0 && pos != 0)
      return false;
  }

  if (pos != std::string::npos && tokens.size() > 0)
  {
    // Now see if we have a trailing wildcard
    size_t last_token_length = tokens.back().length();
    if (*search_string.rbegin() == '*' || pos == name.size() - last_token_length)
      return true;
    else
      return false;
  }
  else
    return false;
}
开发者ID:JasonTurner56,项目名称:ARL,代码行数:40,代码来源:SyntaxTree.C

示例15: FindSubChunkOffset

int32 Chunk::FindSubChunkOffset(std::string name)
{
    // Reverse the name
    name = std::string(name.rbegin(), name.rend());
    if (name.size() != 4)
        return -1;

    FILE* stream = GetStream();
    uint32 matched = 0;
    while (uint32(ftell(stream)) < Utils::Size(stream))
    {
        char b = 0;
        if (fread(&b, sizeof(char), 1, stream) != 1 || b != name[matched])
            matched = 0;
        else
            ++matched;

        if (matched == 4)
            return ftell(stream) - 4;
    }
    return -1;
}
开发者ID:Ayik0,项目名称:DeathCore_5.4.8,代码行数:22,代码来源:Chunk.cpp


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