本文整理汇总了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 );
};
示例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());
}
示例3: CompareNocase
static
int CompareNocase( const basic_string<_TChar>& s1, const basic_string<_TChar>& s2)
{
return strcasecmp(s1.c_str(),s2.c_str());
}
示例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;
}
示例5:
const char* _STLP_CALL
__get_c_string(const basic_string<_CharT,_Traits,_Alloc>& __str) {
return __str.c_str();
}
示例6: hash
inline hash_type hash(const basic_string<char, N>& value)
{
return hash(value.c_str());
}
示例7:
void KeyValueString<T>::AddRawKeyValuesString(const basic_string<T> & rawString)
{
_kvstring += rawString.c_str();
if(rawString[rawString.length() - 1] != _pairSeparator)
_kvstring += _pairSeparator;
}