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


C++ string_type类代码示例

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


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

示例1: append

 static void append(string_type& str, const char* f, const char* l) {
     str.append(f, l);
 }
开发者ID:pstuifzand,项目名称:adobe_source_libraries,代码行数:3,代码来源:json_helper.hpp

示例2: set_string

 void set_string(const string_type & str) {
     m_str.resize(str.size() + m_reserve_prepend + m_reserve_append);
     std::copy( str.begin(), str.end(), m_str.begin() + static_cast<typename string_type::difference_type>(m_reserve_prepend));
     m_full_msg_computed = false;
 }
开发者ID:NOMORECOFFEE,项目名称:hpx,代码行数:5,代码来源:optimize.hpp

示例3: write

 inline void write(const string_type & src, string_type & dest) {
     dest.insert( dest.begin(), src.begin(), src.end() );
 }
开发者ID:41i,项目名称:hpx,代码行数:3,代码来源:convert_format.hpp

示例4: parse_date

  date_type
  parse_date(std::istreambuf_iterator<charT>& sitr, 
             std::istreambuf_iterator<charT>& stream_end,
             string_type format) const
  {
    bool use_current_char = false;
    charT current_char = *sitr;

    unsigned short year(0), month(0), day(0), day_of_year(0);
    
    const_itr itr(format.begin());
    while (itr != format.end() && (sitr != stream_end)) {
      if (*itr == '%') {
        itr++;
        if (*itr != '%') { //ignore '%%'
          unsigned short i = 0;
          switch(*itr) {
          case 'a': 
            {
              //this value is just throw away.  It could be used for
              //error checking potentially, but it isn't helpful in 
              //actually constructing the date - we just need to get it
              //out of the stream
              match_results mr = m_weekday_short_names.match(sitr, stream_end);
              unsigned int wkday = mr.current_match;
              if (mr.has_remaining()) {
                current_char = mr.last_char();
                use_current_char = true;
              }
              break;
            }
          case 'A': 
            {
              //this value is just throw away.  It could be used for
              //error checking potentially, but it isn't helpful in 
              //actually constructing the date - we just need to get it
              //out of the stream
              match_results mr = m_weekday_long_names.match(sitr, stream_end);
              unsigned int wkday = mr.current_match;
              if (mr.has_remaining()) {
                current_char = mr.last_char();
                use_current_char = true;
              }
              break;
            }
          case 'b': 
            {
              match_results mr = m_month_short_names.match(sitr, stream_end);
              month = mr.current_match;
              if (mr.has_remaining()) {
                current_char = mr.last_char();
                use_current_char = true;
              }
              break;
            }
          case 'B': 
            {
              match_results mr = m_month_long_names.match(sitr, stream_end);
              month = mr.current_match;
              if (mr.has_remaining()) {
                current_char = mr.last_char();
                use_current_char = true;
              }
              break;
            }
          case 'd': 
            {
              day = var_string_to_int<unsigned short, charT>(sitr, 2);
              break;
            }
          case 'j': 
            {
              day_of_year = fixed_string_to_int<unsigned short, charT>(sitr, 3);
              break;
            }
          case 'm': 
            {
              month = var_string_to_int<unsigned short, charT>(sitr, 2);
              break;
            }
          case 'Y': 
            {
              year = fixed_string_to_int<unsigned short, charT>(sitr, 4);
              break;
            }
          case 'y': 
            {
              year = fixed_string_to_int<unsigned short, charT>(sitr, 2);
              year += 2000; //make 2 digit years in this century
              break;
            }
          default:
            {} //ignore those we don't understand
            
          }//switch
          
        }
        
        itr++; //advance past format specifier
      }
//.........这里部分代码省略.........
开发者ID:dmm,项目名称:cegis,代码行数:101,代码来源:format_date_parser.hpp

示例5: put

 response const put (request request_, string_type const & content_type, string_type const & body_) {
     request_ << ::boost::network::body(body_)
         << header("Content-Type", content_type)
         << header("Content-Length", boost::lexical_cast<string_type>(body_.size()));
     return put(request_);
 }
开发者ID:LittleForker,项目名称:cpp-netlib,代码行数:6,代码来源:facade.hpp

示例6: set_string

 void set_string(const string_type & str) {
     m_str.resize( str.size() + m_reserve_prepend + m_reserve_append);
     std::copy( str.begin(), str.end(), m_str.begin() + m_reserve_prepend);
     m_full_msg_computed = false;
 }
开发者ID:cargabsj175,项目名称:bombono-dvd,代码行数:5,代码来源:optimize.hpp

示例7: write

 // Write to a wstring
 void write(string_type& s, const char_type* from, const char_type* to) {
     assert(from <= to);
     s.append(from, to);
 }
开发者ID:semenovf,项目名称:jq,代码行数:5,代码来源:safeformat.cpp

示例8: fd_type

//Based on the example at https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx.
Process::id_type Process::open(const string_type &command, const string_type &path) {
  if(open_stdin)
    stdin_fd=std::unique_ptr<fd_type>(new fd_type(NULL));
  if(read_stdout)
    stdout_fd=std::unique_ptr<fd_type>(new fd_type(NULL));
  if(read_stderr)
    stderr_fd=std::unique_ptr<fd_type>(new fd_type(NULL));

  Handle stdin_rd_p;
  Handle stdin_wr_p;
  Handle stdout_rd_p;
  Handle stdout_wr_p;
  Handle stderr_rd_p;
  Handle stderr_wr_p;

  SECURITY_ATTRIBUTES security_attributes;

  security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
  security_attributes.bInheritHandle = TRUE;
  security_attributes.lpSecurityDescriptor = nullptr;

  std::lock_guard<std::mutex> lock(create_process_mutex);
  if(stdin_fd) {
    if (!CreatePipe(&stdin_rd_p, &stdin_wr_p, &security_attributes, 0) ||
        !SetHandleInformation(stdin_wr_p, HANDLE_FLAG_INHERIT, 0))
      return 0;
  }
  if(stdout_fd) {
    if (!CreatePipe(&stdout_rd_p, &stdout_wr_p, &security_attributes, 0) ||
        !SetHandleInformation(stdout_rd_p, HANDLE_FLAG_INHERIT, 0)) {
      return 0;
    }
  }
  if(stderr_fd) {
    if (!CreatePipe(&stderr_rd_p, &stderr_wr_p, &security_attributes, 0) ||
        !SetHandleInformation(stderr_rd_p, HANDLE_FLAG_INHERIT, 0)) {
      return 0;
    }
  }

  PROCESS_INFORMATION process_info;
  STARTUPINFO startup_info;

  ZeroMemory(&process_info, sizeof(PROCESS_INFORMATION));

  ZeroMemory(&startup_info, sizeof(STARTUPINFO));
  startup_info.cb = sizeof(STARTUPINFO);
  startup_info.hStdInput = stdin_rd_p;
  startup_info.hStdOutput = stdout_wr_p;
  startup_info.hStdError = stderr_wr_p;
  if(stdin_fd || stdout_fd || stderr_fd)
    startup_info.dwFlags |= STARTF_USESTDHANDLES;

  string_type process_command=command;
#ifdef MSYS_PROCESS_USE_SH
  size_t pos=0;
  while((pos=process_command.find('\\', pos))!=string_type::npos) {
    process_command.replace(pos, 1, "\\\\\\\\");
    pos+=4;
  }
  pos=0;
  while((pos=process_command.find('\"', pos))!=string_type::npos) {
    process_command.replace(pos, 1, "\\\"");
    pos+=2;
  }
  process_command.insert(0, "sh -c \"");
  process_command+="\"";
#endif

  BOOL bSuccess = CreateProcess(nullptr, process_command.empty()?nullptr:&process_command[0], nullptr, nullptr, TRUE, 0,
                                nullptr, path.empty()?nullptr:path.c_str(), &startup_info, &process_info);

  if(!bSuccess) {
    CloseHandle(process_info.hProcess);
    CloseHandle(process_info.hThread);
    return 0;
  }
  else {
    CloseHandle(process_info.hThread);
  }

  if(stdin_fd) *stdin_fd=stdin_wr_p.detach();
  if(stdout_fd) *stdout_fd=stdout_rd_p.detach();
  if(stderr_fd) *stderr_fd=stderr_rd_p.detach();

  closed=false;
  data.id=process_info.dwProcessId;
  data.handle=process_info.hProcess;
  return process_info.dwProcessId;
}
开发者ID:variar,项目名称:kluster,代码行数:91,代码来源:process_win.cpp

示例9: parse_string

    /*! Take a line from the csv, turn it into a time_zone_type,
     * and add it to the map. Zone_specs in csv file are expected to
     * have eleven fields that describe the time zone. Returns true if
     * zone_spec successfully added to database */
    bool parse_string(string_type& s)
    {

        std::vector<string_type> result;
        typedef boost::token_iterator_generator<boost::escaped_list_separator<charT>, string_type::const_iterator, string_type >::type token_iter_type;

        token_iter_type i = boost::make_token_iterator<string_type>(s.begin(), s.end(),boost::escaped_list_separator<charT>());

        token_iter_type end;
        while (i != end) {
            result.push_back(*i);
            i++;
        }

        enum db_fields { ID, STDABBR, STDNAME, DSTABBR, DSTNAME, GMTOFFSET,
                         DSTADJUST, START_DATE_RULE, START_TIME, END_DATE_RULE,
                         END_TIME, FIELD_COUNT
                       };

        //take a shot at fixing gcc 4.x error
        const unsigned int expected_fields = static_cast<unsigned int>(FIELD_COUNT);
        if (result.size() != expected_fields) {
            std::stringstream msg;
            msg << "Expecting " << FIELD_COUNT << " fields, got "
                << result.size() << " fields in line: " << s;
            throw bad_field_count(msg.str());
        }

        // initializations
        bool has_dst = true;
        if(result[DSTABBR] == std::string()) {
            has_dst = false;
        }


        // start building components of a time_zone
        time_zone_names names(result[STDNAME], result[STDABBR],
                              result[DSTNAME], result[DSTABBR]);

        time_duration_type utc_offset =
            posix_time::duration_from_string(result[GMTOFFSET]);

        dst_adjustment_offsets adjust(time_duration_type(0,0,0),
                                      time_duration_type(0,0,0),
                                      time_duration_type(0,0,0));

        boost::shared_ptr<rule_type> rules;

        if(has_dst) {
            adjust = dst_adjustment_offsets(
                         posix_time::duration_from_string(result[DSTADJUST]),
                         posix_time::duration_from_string(result[START_TIME]),
                         posix_time::duration_from_string(result[END_TIME])
                     );

            rules =
                boost::shared_ptr<rule_type>(parse_rules(result[START_DATE_RULE],
                                             result[END_DATE_RULE]));
        }
        string_type id(result[ID]);
        boost::shared_ptr<time_zone_base_type> zone(new time_zone_type(names, utc_offset, adjust, rules));
        return (add_record(id, zone));

    }
开发者ID:chengxingyu123,项目名称:ecc814,代码行数:68,代码来源:tz_db_base.hpp

示例10: lazy_substring

 lazy_substring(const string_type& str)
   : m_string(&str)
   , m_start(0)
   , m_end(str.size())
   { }
开发者ID:dreamsxin,项目名称:bones,代码行数:5,代码来源:lazy_substring.hpp

示例11: Calc


//.........这里部分代码省略.........
  parser.DefineVar(_T("m1"), Variable(&m1));
  parser.DefineVar(_T("m2"), Variable(&m2));

  parser.DefineVar(_T("a"),  Variable(&fVal[0]));
  parser.DefineVar(_T("b"),  Variable(&fVal[1]));
  parser.DefineVar(_T("c"),  Variable(&fVal[2]));

  parser.DefineVar(_T("ia"), Variable(&iVal[0]));
  parser.DefineVar(_T("ib"), Variable(&iVal[1]));
  parser.DefineVar(_T("ic"), Variable(&iVal[2]));

  parser.DefineVar(_T("ca"), Variable(&cVal[0]));
  parser.DefineVar(_T("cb"), Variable(&cVal[1]));
  parser.DefineVar(_T("cc"), Variable(&cVal[2]));

  parser.DefineVar(_T("sa"), Variable(&sVal[0]));
  parser.DefineVar(_T("sb"), Variable(&sVal[1]));

  // Add functions for inspecting the parser properties
  parser.DefineFun(new FunListVar);
  parser.DefineFun(new FunListFunctions);
  parser.DefineFun(new FunListConst);
  parser.DefineFun(new FunBenchmark);
  parser.DefineFun(new FunEnableOptimizer);
  parser.DefineFun(new FunSelfTest);
  parser.DefineFun(new FunEnableDebugDump);
  parser.DefineFun(new FunTest0);
  parser.DefineFun(new FunPrint);
 
  parser.EnableAutoCreateVar(true);

//#ifdef _DEBUG
//  ParserXBase::EnableDebugDump(1, 0);
//#endif

  for(;;)
  {
    try
    {
      console() << sPrompt;

      string_type sLine;
      std::getline(mup::console_in(), sLine);
      if (sLine.length()==0)
        continue;

      if (sLine==_T("dbg"))
      {
        sLine  = _T("sum(3)/sum(3,4,5)");
        mup::console() << sLine << endl;
      }

      switch(CheckKeywords(sLine.c_str(), parser)) 
      {
      case  0: break;
      case  1: continue;
      case -1: return;
      }
    
      parser.SetExpr(sLine);

      // The returned result is of type Value, value is a Variant like
      // type that can be either a boolean an integer or a floating point value
      ans = parser.Eval();
//      ans = parser.Eval();

      // Value supports C++ streaming like this:
      //console() << _T("Result (type: '" << ans.GetType() <<  "'):\n");
      console() << _T("ans = ") << ans << _T("\n");

      // Or if you need the specific type use this:
      //switch (result.GetType())
      //{
      //case 's': cout << result.GetString() << " (string)" << "\n"; break;
      //case 'i': cout << result.GetInt() << " (int)" << "\n"; break;
      //case 'f': cout << result.GetFloat() << " (float)" << "\n"; break;
      //case 'c': cout << result.GetFloat() << "+" << result.GetImag() << "i (complex)" << "\n"; break;
      //case 'b': break;
      //}
    }
    catch(ParserError &e)
    {
      if (e.GetPos()!=-1)
      {
        string_type sMarker;
        sMarker.insert(0, sPrompt.size() + e.GetPos(), ' ');
        sMarker += _T("^\n");
        console() << sMarker;
      }

      console() << e.GetMsg() << _T(" (Errc: ") << e.GetCode() << _T(")") << _T("\n\n");

      //if (e.GetContext().Ident.length()) 
      //  console() << _T("Ident.: ") << e.GetContext().Ident << _T("\n");

      //if (e.GetToken().length()) 
      //  console() << _T("Token: \"") << e.GetToken() << _T("\"\n");
    } // try / catch
  } // for (;;)
}
开发者ID:QAndot,项目名称:muparser,代码行数:101,代码来源:example.cpp

示例12: SetWindowTitle

void ThinConsole::SetWindowTitle(string_type const& title) {
	ExceptionCheck(SetConsoleTitle(title.c_str()), __FUNCTION__, __LINE__);
}
开发者ID:Slipetz,项目名称:File_Browser-TUI,代码行数:3,代码来源:ThinConsole.cpp

示例13:

stringProxy::stringProxy(const string_type& s, const size_type start, const size_type end)
	: m_buffer(s), m_start(start),
	  m_end(end == std::numeric_limits <size_type>::max() ? s.length() : end)
{
}
开发者ID:dezelin,项目名称:maily,代码行数:5,代码来源:stringProxy.cpp

示例14: expand_escapes

void expand_escapes(string_type& s)
{
   for(unsigned int i = 0; i < s.size(); ++i)
   {
      if(s[i] == BOOST_RE_STR('\\'))
      {
         switch(s[i+1])
         {
         case BOOST_RE_STR('a'):
            s.erase(s.begin() + i);
            s[i] = BOOST_RE_STR('\a');
            break;
         case BOOST_RE_STR('b'):
            s.erase(s.begin() + i);
            s[i] = BOOST_RE_STR('\b');
            break;
         case BOOST_RE_STR('f'):
            s.erase(s.begin() + i);
            s[i] = BOOST_RE_STR('\f');
            break;
         case BOOST_RE_STR('n'):
            s.erase(s.begin() + i);
            s[i] = BOOST_RE_STR('\n');
            break;
         case BOOST_RE_STR('r'):
            s.erase(s.begin() + i);
            s[i] = BOOST_RE_STR('\r');
            break;
         case BOOST_RE_STR('t'):
            s.erase(s.begin() + i);
            s[i] = BOOST_RE_STR('\t');
            break;
         case BOOST_RE_STR('v'):
            s.erase(s.begin() + i);
            s[i] = BOOST_RE_STR('\v');
            break;
         default:
            if( (s[i + 1] >= BOOST_RE_STR('0')) && (s[i + 1] <= BOOST_RE_STR('9')) )
            {
               int val = 0;
               unsigned int pos = i;
               ++i;
               while((i < s.size()) && (s[i] >= BOOST_RE_STR('0')) && (s[i] <= BOOST_RE_STR('9')))
               {
                  val *= 10;
                  val += s[i] - BOOST_RE_STR('0');
                  ++i;
               }
               s.erase(s.begin() + pos, s.begin() + i);
               if(0 == val)
               {
                  s.insert(s.begin()+pos, ' ');
                  s[pos] = 0;
               }
               else
                  s.insert(s.begin() + pos, (string_type::value_type)val);
               i = pos;
            }
            else
            {
               s.erase(s.begin() + i);
            }
         }
      }
   }
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:66,代码来源:parse.cpp

示例15: while

//! Converts escape sequences to the corresponding characters
void char_constants< wchar_t >::translate_escape_sequences(string_type& str)
{
    using namespace std; // to make sure we can use C functions unqualified

    string_type::iterator it = str.begin();
    while (it != str.end())
    {
        it = std::find(it, str.end(), L'\\');
        if (std::distance(it, str.end()) >= 2)
        {
            it = str.erase(it);
            switch (*it)
            {
            case L'n':
                *it = L'\n'; break;
            case L'r':
                *it = L'\r'; break;
            case L'a':
                *it = L'\a'; break;
            case L'\\':
                ++it; break;
            case L't':
                *it = L'\t'; break;
            case L'b':
                *it = L'\b'; break;
            case L'x':
                {
                    string_type::iterator b = it;
                    if (std::distance(++b, str.end()) >= 2)
                    {
                        char_type c1 = *b++, c2 = *b++;
                        if (iswxdigit(c1) && iswxdigit(c2))
                        {
                            *it++ = char_type((to_number(c1) << 4) | to_number(c2));
                            it = str.erase(it, b);
                        }
                    }
                    break;
                }
            case L'u':
                {
                    string_type::iterator b = it;
                    if (std::distance(++b, str.end()) >= 4)
                    {
                        char_type c1 = *b++, c2 = *b++, c3 = *b++, c4 = *b++;
                        if (iswxdigit(c1) && iswxdigit(c2) && iswxdigit(c3) && iswxdigit(c4))
                        {
                            *it++ = char_type(
                                (to_number(c1) << 12) |
                                (to_number(c2) << 8) |
                                (to_number(c3) << 4) |
                                to_number(c4));
                            it = str.erase(it, b);
                        }
                    }
                    break;
                }
            case L'U':
                {
                    string_type::iterator b = it;
                    if (std::distance(++b, str.end()) >= 8)
                    {
                        char_type c1 = *b++, c2 = *b++, c3 = *b++, c4 = *b++;
                        char_type c5 = *b++, c6 = *b++, c7 = *b++, c8 = *b++;
                        if (iswxdigit(c1) && iswxdigit(c2) && iswxdigit(c3) && iswxdigit(c4) &&
                            iswxdigit(c5) && iswxdigit(c6) && iswxdigit(c7) && iswxdigit(c8))
                        {
                            *it++ = char_type(
                                (to_number(c1) << 28) |
                                (to_number(c2) << 24) |
                                (to_number(c3) << 20) |
                                (to_number(c4) << 16) |
                                (to_number(c5) << 12) |
                                (to_number(c6) << 8) |
                                (to_number(c7) << 4) |
                                to_number(c8));
                            it = str.erase(it, b);
                        }
                    }
                    break;
                }
            default:
                {
                    if (*it >= L'0' && *it <= L'7')
                    {
                        string_type::iterator b = it;
                        int c = (*b++) - L'0';
                        if (*b >= L'0' && *b <= L'7')
                            c = c * 8 + (*b++) - L'0';
                        if (*b >= L'0' && *b <= L'7')
                            c = c * 8 + (*b++) - L'0';

                        *it++ = char_type(c);
                        it = str.erase(it, b);
                    }
                    break;
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:AlexMioMio,项目名称:boost,代码行数:101,代码来源:parser_utils.cpp


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