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


C++ basic_string::c_str方法代码示例

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


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

示例1: ApplyLanguageModelOnTheFly

  /**
   * Constructor. Initializes on-the-fly composition with a language model.
   * \param fst         Machine you want to apply the language to. Pass a delayed machine if you can, as it will expand it in constructor.
   * \param model       A KenLM language model
   * \param epsilons    List of words to work as epsilons
   * \param natlog      Use or not natural logs
   * \param lmscale      Language model scale
   */
  ApplyLanguageModelOnTheFly ( const Fst<Arc>& fst,
                               KenLMModelT& model,
#ifndef USE_GOOGLE_SPARSE_HASH
                               unordered_set<Label>& epsilons,
#else
                               google::dense_hash_set<Label>& epsilons,
#endif
                               bool natlog,
                               float lmscale ,
                               float lmwp,
                               const IdBridgeT& idbridge
                             ) :
    composed_ ( NULL ) ,
    natlog10_ ( natlog ? -lmscale* ::log ( 10.0 ) : -lmscale ),
    fst_ ( fst ),
    lmmodel_ ( model ),
    vocab_ ( model.GetVocabulary() ),
    wp_ ( lmwp ) ,
    epsilons_ ( epsilons ) ,
    history ( model.Order(), 0),
    idbridge_ (idbridge) {
#ifdef USE_GOOGLE_SPARSE_HASH
    stateexistence_.set_empty_key ( numeric_limits<ull>::max() );
    statemap_.set_empty_key ( numeric_limits<uint64_t>::max() );
    basic_string<unsigned> aux (KENLM_MAX_ORDER, numeric_limits<unsigned>::max() );
    seenlmstates_.set_empty_key ( aux );
#endif
    buffersize = ( model.Order() - 1 ) * sizeof ( unsigned int );
    buffer = const_cast<unsigned *> ( history.c_str() );
    if (!fst_.NumStates() )  {
      LWARN ("Empty lattice");
      return;
    }
    composed_ = new VectorFst<Arc>;
    typename KenLMModelT::State bs = model.NullContextState();
    ///Initialize with first state
    pair<StateId, bool> nextp = add ( bs, fst_.Start(),
                                      fst_.Final ( fst_.Start() ) );
    qc_.push ( nextp.first );
    composed_->SetStart ( nextp.first );
  };
开发者ID:Libardo1,项目名称:ucam-smt,代码行数:49,代码来源:fstutils.applylmonthefly.hpp

示例2: Compare

 static 
 int Compare( const _TChar* s1, const basic_string<_TChar>& s2, ECase use_case = eCase)
 {
     return use_case == eCase ? CompareCase(s1,s2.c_str()) : CompareNocase(s1,s2.c_str());
 }
开发者ID:jackgopack4,项目名称:pico-blast,代码行数:5,代码来源:ncbi_xstr.hpp

示例3: CompareNocase

 static 
 int CompareNocase( const basic_string<_TChar>& s1, const basic_string<_TChar>& s2)
 {
     return strcasecmp(s1.c_str(),s2.c_str());
 }
开发者ID:jackgopack4,项目名称:pico-blast,代码行数:5,代码来源:ncbi_xstr.hpp

示例4: EqualsMask

// Check OBIS codes.
bool CGXStandardObisCodeCollection::EqualsMask(basic_string<char> obis, int ic)
{
    bool number = true;
	int value;
	if (obis.find(',') != std::string::npos)
    {
        vector< basic_string<char> > tmp = GXHelpers::Split(obis, ',');
        //for (basic_string<char> it : tmp)
		for(vector< basic_string<char> >::iterator it = tmp.begin(); it != tmp.end(); ++it)
        {
			if ((*it).find('-') != std::string::npos)
            {
                if (EqualsMask(*it, ic))
                {
                    return true;
                }
            }
            else
            {					
#if _MSC_VER > 1000
				sscanf_s((*it).c_str(), "%d", &value);
#else
				sscanf((*it).c_str(), "%d", &value);
#endif							
				if (value == ic)
				{
					return true;
				}
            }
        }
        return false;
    }
    else if (obis.find('-') != std::string::npos)
    {
        number = false;
        vector< basic_string<char> > tmp = GXHelpers::Split(obis, '-');
		int value1, value2;
#if _MSC_VER > 1000
		sscanf_s(tmp[0].c_str(), "%d", &value1);
		sscanf_s(tmp[1].c_str(), "%d", &value2);
#else
		sscanf(tmp[0].c_str(), "%d", &value1);
		sscanf(tmp[1].c_str(), "%d", &value2);
#endif		
        return ic >= value1 && ic <= value2;
    }
    if (number)
    {
        if (obis == "&")
        {
            return ic == 0 || ic == 1 || ic == 7;
        }			
#if _MSC_VER > 1000
		sscanf_s(obis.c_str(), "%d", &value);
#else
		sscanf(obis.c_str(), "%d", &value);
#endif					
        return value == ic;
    }
    return false;
}
开发者ID:AMildner,项目名称:GuruxDLMSLib,代码行数:62,代码来源:GXStandardObisCodeCollection.cpp

示例5:

const char* _STLP_CALL
__get_c_string(const basic_string<_CharT,_Traits,_Alloc>& __str) { 
  return __str.c_str(); 
}
开发者ID:OS2World,项目名称:DEV-CPLUSPLUS-STLport,代码行数:4,代码来源:_string_fwd.c

示例6: hash

inline hash_type hash(const basic_string<char, N>& value)
{
    return hash(value.c_str());
}
开发者ID:icedmaster,项目名称:mhe,代码行数:4,代码来源:hash.hpp

示例7:

void KeyValueString<T>::AddRawKeyValuesString(const basic_string<T> & rawString)
{
	_kvstring += rawString.c_str();
	if(rawString[rawString.length() - 1] != _pairSeparator)
		_kvstring += _pairSeparator;
}
开发者ID:Petrik7,项目名称:Prototypes,代码行数:6,代码来源:KeyValueString.hpp


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