本文整理汇总了C++中std::string::mb_str方法的典型用法代码示例。如果您正苦于以下问题:C++ string::mb_str方法的具体用法?C++ string::mb_str怎么用?C++ string::mb_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::string
的用法示例。
在下文中一共展示了string::mb_str方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RegExMatches
bool cppPCRE::RegExMatches( const std::string& text, int options, int startOffset, std::string* error )
{
// output useful debug info
CHECK_MSG( IsValid(), false, _(COMPILE_REGEX_ERROR) );
// store the options
mExecOptions = options;
/*
- implement later
// returned value may be used to speed up match
pcre_extra *regexExtra = pcre_study(mRegex,
options, // options
&error);
*/
/*
// get full info
int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
int what, void *where);
int rc;
size_t len;
rc = pcre_fullinfo(mRegex, regexExtra, PCRE_INFO_CAPTURECOUNT, &len);
*/
// convert the std::string to a std::string (for use with PCRE)
const char* subject = (char*)NULL;
#if wxUSE_UNICODE
subject = string(text.mb_str(wxConvUTF8)).c_str();
#else
subject = (const char*)text.c_str();
#endif
/*
int pcre_exec(const pcre *code, const pcre_extra *extra,
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize);
*/
// execute the pattern matching mechanism (obtain match vector, etc)
mMatchCount = pcre_exec(
mRegex, /* result of pcre_compile() */
0, /* we didn't study the pattern */
subject, /* the subject string */
(int)text.length(), /* the length of the subject string */
startOffset, /* start at offset ? in the subject */
mExecOptions, /* options */
mVector, /* vector of integers for substring information */
mVectorCount); /* number of elements (NOT size in bytes) */
return (mVector[0] >= 0);
}