您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ string_type函数代码示例

51自学网 2021-06-03 08:30:41
  C++
这篇教程C++ string_type函数代码示例写得很实用,希望能帮到您。

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

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

示例1: tokenize

			static std::deque<string_type> tokenize(string_type input, string_type br)			{				typename string_type::iterator a,b,c;				std::deque<string_type> tokens;				// std::cerr << "Tokenising string=" << input << " break=" << br << std::endl;				while ( input.length() )				{					a = input.begin();					c = input.end();					typename string_type::size_type e = input.find(br);					if ( e != string_type::npos )					{						b = a+e;						tokens.push_back(string_type(a,b));						input = string_type(b+br.length(),c);					}					else					{						tokens.push_back(input);						input = string_type();					}					// std::cerr << "Pushed token " << tokens.back() << " input now " << input << std::endl;				}				return tokens;			}
开发者ID:gt1,项目名称:libmaus2,代码行数:30,


示例2: to_string

 string_type to_string()              const {     if (_data != nullptr)         return string_type(_data);     else         return string_type(); }
开发者ID:alanwoolley,项目名称:innoextract-android,代码行数:7,


示例3: name

c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2) {#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)/               && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)/               && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)   std::string name(p1, p2);#else   std::string name;   const wchar_t* p0 = p1;   while(p0 != p2)      name.append(1, char(*p0++));#endif   name = ::boost::re_detail::lookup_default_collate_name(name);#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)/               && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)/               && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551)   if(name.size())      return string_type(name.begin(), name.end());#else   if(name.size())   {      string_type result;      typedef std::string::const_iterator iter;      iter b = name.begin();      iter e = name.end();      while(b != e)         result.append(1, wchar_t(*b++));      return result;   }#endif   if(p2 - p1 == 1)      return string_type(1, *p1);   return string_type();}
开发者ID:evgs,项目名称:bombus-ng,代码行数:34,


示例4: ExtractOperatorToken

  /** /brief Check if a string position contains a binary operator.      /param a_Tok  [out] Operator token if one is found. This can either be a binary operator or an infix operator token.      /return true if an operator token has been found.  */  bool ParserTokenReader::IsOprt(token_type &a_Tok)  {    const char_type *const szExpr = m_strFormula.c_str();    string_type strTok;    int iEnd = ExtractOperatorToken(strTok, m_iPos);    if (iEnd==m_iPos)      return false;    // Check if the operator is a built in operator, if so ignore it here    const char_type **const pOprtDef = m_pParser->GetOprtDef();    for (int i=0; m_pParser->HasBuiltInOprt() && pOprtDef[i]; ++i)    {      if (string_type(pOprtDef[i])==strTok)        return false;    }    // Note:    // All tokens in oprt_bin_maptype are have been sorted by their length    // Long operators must come first! Otherwise short names (like: "add") that    // are part of long token names (like: "add123") will be found instead     // of the long ones.    // Length sorting is done with ascending length so we use a reverse iterator here.    funmap_type::const_reverse_iterator it = m_pOprtDef->rbegin();    for ( ; it!=m_pOprtDef->rend(); ++it)    {      const string_type &sID = it->first;      if ( sID == string_type(szExpr + m_iPos, szExpr + m_iPos + sID.length()) )      {        a_Tok.Set(it->second, strTok);        // operator was found        if (m_iSynFlags & noOPT)         {          // An operator was found but is not expected to occur at          // this position of the formula, maybe it is an infix           // operator, not a binary operator. Both operator types          // can share characters in their identifiers.          if ( IsInfixOpTok(a_Tok) )             return true;          else          {            // nope, no infix operator            return false;            //Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString());           }        }        m_iPos += (int)sID.length();        m_iSynFlags  = noBC | noOPT | noARG_SEP | noPOSTOP | noEND | noBC | noASSIGN;        return true;      }    }    return false;  }
开发者ID:00liujj,项目名称:dealii,代码行数:61,


示例5: i

icu_regex_traits_implementation::string_type icu_regex_traits_implementation::do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const{   // TODO make thread safe!!!! :   typedef u32_to_u16_iterator<const char_type*, ::UChar> itt;   itt i(p1), j(p2);#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS   std::vector< ::UChar> t(i, j);#else   std::vector< ::UChar> t;   while(i != j)      t.push_back(*i++);#endif   ::uint8_t result[100];   ::int32_t len;   if(t.size())      len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), result, sizeof(result));   else      len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), result, sizeof(result));   if(std::size_t(len) > sizeof(result))   {      scoped_array< ::uint8_t> presult(new ::uint8_t[len+1]);      if(t.size())         len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), presult.get(), len+1);      else         len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), presult.get(), len+1);      if((0 == presult[len-1]) && (len > 1))         --len;#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS      return string_type(presult.get(), presult.get()+len);#else      string_type sresult;      ::uint8_t const* ia = presult.get();      ::uint8_t const* ib = presult.get()+len;      while(ia != ib)         sresult.push_back(*ia++);      return sresult;#endif   }   if((0 == result[len-1]) && (len > 1))      --len;#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS   return string_type(result, result+len);#else   string_type sresult;   ::uint8_t const* ia = result;   ::uint8_t const* ib = result+len;   while(ia != ib)      sresult.push_back(*ia++);   return sresult;#endif}
开发者ID:Faham,项目名称:bric-n-brac,代码行数:51,


示例6: tokenizePair

			static std::pair<string_type,string_type> tokenizePair(string_type input, string_type br)			{				std::deque<string_type> tokens = tokenize<string_type>(input,br);				if ( tokens.size() == 0 )					return std::pair<string_type,string_type>(						string_type(),						string_type());				else if ( tokens.size() == 1 )					return std::pair<string_type,string_type>(						string_type(tokens[0]),						string_type());				else if ( tokens.size() == 2 )					return std::pair<string_type,string_type>(						string_type(tokens[0]),						string_type(tokens[1]));				else				{					string_type val;					for ( uint64_t i = 1; i < tokens.size(); ++i )					{						val += tokens[i];						if ( i+1 < tokens.size() )							val += br;					}					return std::pair<string_type,string_type>(						string_type(tokens[0]),						string_type(val));				}			}
开发者ID:gt1,项目名称:libmaus2,代码行数:32,


示例7: string_type

void default_filter_factory< CharT >::on_string_argument(    string_type const& name, const char_type* b, const char_type* e, filter_type& filter){    filter = log::filters::attr<        string_type    >(name, std::nothrow).satisfies(log::aux::bind2nd(RelationT(), string_type(b, e)));}
开发者ID:nairboon,项目名称:anarchnet,代码行数:7,


示例8: string_type

//------------------------------------------------------------------------------string_type ParserErrorMsg::GetErrorMsg(EErrorCodes eError) const{    if (!m_pInstance.get())        return string_type();    else        return m_pInstance->GetErrorMsg(eError);}
开发者ID:MirkoFl,项目名称:math-parser-benchmark-project,代码行数:8,


示例9: set_host

void uri_builder::set_host(string_type host) {  host_.reset(string_type());  auto end = network::uri::encode_host(std::begin(host), std::end(host),                                       std::back_inserter(*host_));  std::transform(std::begin(*host_), std::end(*host_), std::begin(*host_),                 [](string_type::value_type c) { return std::tolower(c); });}
开发者ID:QuentinFiard,项目名称:uri,代码行数:7,


示例10: Assign

boolnsTSubstring_CharT::Assign( const substring_tuple_type& tuple, const fallible_t& )  {    if (tuple.IsDependentOn(mData, mData + mLength))      {        // take advantage of sharing here...        return Assign(string_type(tuple), fallible_t());      }    size_type length = tuple.Length();    // don't use ReplacePrep here because it changes the length    char_type* oldData;    uint32_t oldFlags;    if (!MutatePrep(length, &oldData, &oldFlags))      return false;    if (oldData)      ::ReleaseData(oldData, oldFlags);    tuple.WriteTo(mData, length);    mData[length] = 0;    mLength = length;    return true;  }
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:25,


示例11: getURI

    /**     * Look up a prefix and get the currently-mapped Namespace URI.     *     * <p>This method looks up the prefix in the current context.     * Use the empty string ("") for the default Namespace.</p>     *     * @param prefix The prefix to look up.     * @return The associated Namespace URI, or empty string if the prefix     *         is undeclared in this context.     * @see #getPrefix     * @see #getPrefixes     */    string_type getURI(const string_type& prefix) const    {        for(typename contextListT::const_reverse_iterator i = contexts_.rbegin(); i != contexts_.rend(); ++i)        {            typename stringMapT::const_iterator u = i->find(prefix);            if(u != i->end())                return u->second;        } // for ...        return string_type();    } // getURI
开发者ID:draekko,项目名称:arabica,代码行数:23,


示例12: getPrefix

    /**     * Return one of the prefixes mapped to a Namespace URI.     *     * <p>If more than one prefix is currently mapped to the same     * URI, this method will make an arbitrary selection; if you     * want all of the prefixes, use the {@link #getPrefixes}     * method instead.</p>     *     * <p><strong>Note:</strong> this will never return the empty (default) prefix;     * to check for a default prefix, use the {@link #getURI getURI}     * method with an argument of "".</p>     *     * @param uri The Namespace URI.     * @return One of the prefixes currently mapped to the URI supplied,     *         or an empty string if none is mapped or if the URI is assigned to     *         the default Namespace.     * @see #getPrefixes(const string_type&)     * @see #getURI     */    string_type getPrefix(const string_type& uri) const    {        for(typename contextListT::const_reverse_iterator i = contexts_.rbegin(); i != contexts_.rend(); ++i)        {            for(typename stringMapT::const_iterator u = i->begin(); u != i->end(); ++u)                if(u->second == uri)                    return u->first;        } // for ...        return string_type();    } // getPrefix
开发者ID:draekko,项目名称:arabica,代码行数:30,


示例13: make_printable_string

printable_string* make_printable_string(unsigned char* val) {    printable_string* result = ALLOCATE(sizeof(printable_string));    size_t len = strlen(val) + 1;    unsigned char* copy = ALLOCATE(sizeof(unsigned char*) * len);    printable* presult = (printable*)result;    strncpy(copy, val, len - 1);    copy[len - 1] = '/0';    presult->type = string_type();    presult->val = copy;    presult->size = len;    define_method(presult->type, to_string, to_string_string);    return result;}
开发者ID:wvxvw,项目名称:introduction-to-data-structures,代码行数:13,


示例14: encode

void encode(const double latitude, const double longitude, unsigned long precision, string_type & output){    // DecodedBBox for the lat/lon + errors    DecodedBBox bbox;    bbox.maxlat = 90;    bbox.maxlon = 180;    bbox.minlat = -90;    bbox.minlon = -180;    double mid        = 0;    bool   islon      = true;    int    num_bits   = 0;    int    hash_index = 0;    // Pre-Allocate the hash string    output = string_type(precision, ' ');    unsigned int output_length = 0;    while(output_length < precision) {        if (islon) {            mid = (bbox.maxlon + bbox.minlon) / 2;            if(longitude > mid) {                hash_index = (hash_index << 1) + 1;                bbox.minlon=mid;            } else {                hash_index = (hash_index << 1) + 0;                bbox.maxlon=mid;            }        } else {            mid = (bbox.maxlat + bbox.minlat) / 2;            if(latitude > mid ) {                hash_index = (hash_index << 1) + 1;                bbox.minlat = mid;            } else {                hash_index = (hash_index << 1) + 0;                bbox.maxlat = mid;            }        }        islon = !islon;        ++num_bits;        if (5 == num_bits) {            // Append the character to the pre-allocated string            // This gives us roughly a 2x speed boost            output[output_length] = base32_codes[hash_index];            output_length++;            num_bits   = 0;            hash_index = 0;        }    }};
开发者ID:gnagel,项目名称:node-geohash-cpp,代码行数:51,


示例15: to_vector

 std::vector<string_type> to_vector() const {     if (_data == nullptr)         return std::vector<string_type>();     std::vector<string_type> data;     auto str = string_type(_data);     struct splitter     {         bool operator()(wchar_t w) const {return w == api::env_seperator<wchar_t>();}         bool operator()(char c)    const {return c == api::env_seperator<char>   ();}     } s;     boost::split(data, _data, s);     return std::move(data); }
开发者ID:alanwoolley,项目名称:innoextract-android,代码行数:14,


示例16: string_type

collate_byname<char>::string_typecollate_byname<char>::do_transform(const char* low, const char* high) const {  if (low == high)    return string_type();  size_t n = _Locale_strxfrm(_M_collate, NULL, 0, low, high - low);  // NOT PORTABLE.  What we're doing relies on internal details of the  // string implementation.  (Contiguity of string elements and presence  // of trailing zero.)  string_type buf(n, 0);  _Locale_strxfrm(_M_collate, &(*buf.begin()), n + 1, low, high - low);  return buf;}
开发者ID:3runo5ouza,项目名称:rhodes,代码行数:14,


示例17: _Locale_strxfrm

collate_byname<char>::string_typecollate_byname<char>::do_transform(const char* low, const char* high) const {  size_t n = _Locale_strxfrm(_M_collate,                             NULL, 0,                             low, high - low);  __vector__<char, allocator<char> > buf(n);  _Locale_strxfrm(_M_collate, &buf.front(), n,                              low, high - low);   char& __c1 = *(buf.begin());   char& __c2 = (n == (size_t)-1) ? *(buf.begin() + (high-low-1)) : *(buf.begin() + n);   //   char& __c2 = *(buf.begin() + n);   return string_type( &__c1, &__c2 );}
开发者ID:Arkshine,项目名称:NS,代码行数:15,


示例18: string_type

  /** /brief Extract all characters that belong to a certain charset.    /param a_szCharSet [in] Const char array of the characters allowed in the token.     /param a_strTok [out]  The string that consists entirely of characters listed in a_szCharSet.    /param a_iPos [in] Position in the string from where to start reading.    /return The Position of the first character not listed in a_szCharSet.    /throw nothrow  */  int ParserTokenReader::ExtractToken(const char_type *a_szCharSet,                                       string_type &a_sTok,                                       int a_iPos) const  {    int iEnd = (int)m_strFormula.find_first_not_of(a_szCharSet, a_iPos);    if (iEnd==(int)string_type::npos)        iEnd = (int)m_strFormula.length();        // Assign token string if there was something found    if (a_iPos!=iEnd)      a_sTok = string_type( m_strFormula.begin()+a_iPos, m_strFormula.begin()+iEnd);    return iEnd;  }
开发者ID:00liujj,项目名称:dealii,代码行数:23,


示例19: Assign

voidnsTSubstring_CharT::AssignASCII( const char* data, size_type length )  {    // A Unicode string can't depend on an ASCII string buffer,    // so this dependence check only applies to CStrings.#ifdef CharT_is_char    if (IsDependentOn(data, data + length))      {        // take advantage of sharing here...        Assign(string_type(data, length));        return;      }#endif    if (ReplacePrep(0, mLength, length))      char_traits::copyASCII(mData, data, length);  }
开发者ID:mbrubeck,项目名称:mozilla-central,代码行数:17,


示例20: return

	path& path::append(const path& p)	{		if (p.empty()) return *this;		if (empty()) {			return (*this = p); 		}		invalidate();		// check for something stupid like xx.append(xx);		if (&p == this) {			return append_common(string_type(p._path));		}		return append_common(p._path);	}
开发者ID:ksherlock,项目名称:mpw-shell,代码行数:17,


示例21: message_impl_type

BOOST_LOG_API void basic_record_ostream< CharT >::init_stream(){    base_type::imbue(std::locale());    if (m_record)    {        typedef attributes::attribute_value_impl< string_type > message_impl_type;        intrusive_ptr< message_impl_type > p = new message_impl_type(string_type());        attribute_value value(p);        // This may fail if the record already has Message attribute        std::pair< attribute_value_set::const_iterator, bool > res =            m_record->attribute_values().insert(expressions::tag::message::get_name(), value);        if (!res.second)            const_cast< attribute_value& >(res.first->second).swap(value);        base_type::attach(const_cast< string_type& >(p->get()));    }}
开发者ID:ElaraFX,项目名称:boost,代码行数:18,


示例22: stream

/** /brief Check whether the token at a given position is a value token.  Value tokens are either values or constants.  /param a_Tok [out] If a value token is found it will be placed here.  /return true if a value token has been found.  */bool TokenReader::IsValTok(ptr_tok_type &a_Tok){    if (m_vValueReader.size() == 0)        return false;    stringstream_type stream(m_sExpr.c_str() + m_nPos);    string_type sTok;    try    {        // call the value recognition functions provided by the user        // Call user defined value recognition functions        int iSize = (int)m_vValueReader.size();        Value val;        for (int i = 0; i < iSize; ++i)        {            int iStart = m_nPos;            if (m_vValueReader[i]->IsValue(m_sExpr.c_str(), m_nPos, val))            {                sTok.assign(m_sExpr.c_str(), iStart, m_nPos);                if (m_nSynFlags & noVAL)                    throw ecUNEXPECTED_VAL;                m_nSynFlags = noVAL | noVAR | noFUN | noBO | noIFX | noIO;                a_Tok = ptr_tok_type(val.Clone());                a_Tok->SetIdent(string_type(sTok.begin(), sTok.begin() + (m_nPos - iStart)));                return true;            }        }    }    catch (EErrorCodes e)    {        ErrorContext err;        err.Errc = e;        err.Pos = m_nPos;        err.Ident = sTok;        err.Expr = m_sExpr;        err.Pos = m_nPos - (int)sTok.length();        throw ParserError(err);    }    return false;}
开发者ID:MirkoFl,项目名称:math-parser-benchmark-project,代码行数:50,


示例23: string_type

 int module_loader_op::write(shared_ptr<fs_entry> file_ent, char const *buf, size_t size, off_t offset) {     int ret = size;     auto request = string_type(buf, size);     request_parser parser;     if (parser.parse(request)) try {         typedef core_file_system::priority priority;         if (parser.get_command() == "load")             for (auto&& mod_name : parser.get_args())                 fs_root_->install_module(priority::normal, mod_name[0], paths_);         else if (parser.get_command() == "unload")             for (auto&& mod_name : parser.get_args())                 fs_root_->uninstall_module(mod_name[0]);     } catch (no_such_ops_type& e) {             BOOST_LOG_TRIVIAL(error) << "module_loader: " << e.what();             throw_system_error(EINVAL);     } else         ret = -ENOTSUP;     return ret; }
开发者ID:carriercomm,项目名称:fuse_planetfs,代码行数:20,


示例24: BOOST_ASSERT

hdf5_oprimitive::write_hdf5_dataset(    const std::string *t,    std::size_t data_count,    std::size_t object_number){    BOOST_ASSERT(data_count == 1);    char const* c_string = t->c_str();    hdf5_datatype string_type(H5T_STRING);    if(use_variable_length_strings_ || t->empty()) {        string_type.resize(H5T_VARIABLE);        write_dataset_basic(&c_string, data_count, string_type, object_number);    }    else {        string_type.resize(t->size());        write_dataset_basic(c_string, data_count, string_type, object_number);    }    string_type.close();}
开发者ID:bingzhang00,项目名称:serialization,代码行数:22,


示例25: Truncate

boolnsTSubstring_CharT::Assign( const char_type* data, size_type length, const fallible_t& )  {    if (!data)      {        Truncate();        return true;      }    if (length == size_type(-1))      length = char_traits::length(data);    if (IsDependentOn(data, data + length))      {        return Assign(string_type(data, length), fallible_t());      }    if (!ReplacePrep(0, mLength, length))      return false;    char_traits::copy(mData, data, length);    return true;  }
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:23,


示例26: Truncate

voidnsTSubstring_CharT::Assign( const char_type* data, size_type length )  {      // unfortunately, some callers pass null :-(    if (!data)      {        Truncate();        return;      }    if (length == size_type(-1))      length = char_traits::length(data);    if (IsDependentOn(data, data + length))      {        // take advantage of sharing here...        Assign(string_type(data, length));        return;      }    if (ReplacePrep(0, mLength, length))      char_traits::copy(mData, data, length);  }
开发者ID:mbrubeck,项目名称:mozilla-central,代码行数:23,



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


C++ string_vsnprintf函数代码示例
C++ string_to_number函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。