本文整理汇总了C++中CStrRef类的典型用法代码示例。如果您正苦于以下问题:C++ CStrRef类的具体用法?C++ CStrRef怎么用?C++ CStrRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CStrRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SqlDecode
String StringUtil::SqlDecode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_stripslashes(input, len);
return String(ret, len, AttachString);
}
示例2: ini_on_update_long
bool ini_on_update_long(CStrRef value, void *p) {
if (p) {
*((int64_t*)p) = value.toInt64();
}
return true;
}
示例3: pack
Variant ZendPack::pack(CStrRef fmt, CArrRef argv) {
/* Preprocess format into formatcodes and formatargs */
vector<char> formatcodes;
vector<int> formatargs;
int argc = argv.size();
const char *format = fmt.c_str();
int formatlen = fmt.size();
int currentarg = 0;
for (int i = 0; i < formatlen; ) {
char code = format[i++];
int arg = 1;
/* Handle format arguments if any */
if (i < formatlen) {
char c = format[i];
if (c == '*') {
arg = -1;
i++;
}
else if (c >= '0' && c <= '9') {
arg = atoi(&format[i]);
while (format[i] >= '0' && format[i] <= '9' && i < formatlen) {
i++;
}
}
}
/* Handle special arg '*' for all codes and check argv overflows */
switch ((int) code) {
/* Never uses any args */
case 'x':
case 'X':
case '@':
if (arg < 0) {
throw_invalid_argument("Type %c: '*' ignored", code);
arg = 1;
}
break;
/* Always uses one arg */
case 'a':
case 'A':
case 'h':
case 'H':
if (currentarg >= argc) {
throw_invalid_argument("Type %c: not enough arguments", code);
return false;
}
if (arg < 0) {
arg = argv[currentarg].toString().size();
}
currentarg++;
break;
/* Use as many args as specified */
case 'c':
case 'C':
case 's':
case 'S':
case 'i':
case 'I':
case 'l':
case 'L':
case 'n':
case 'N':
case 'v':
case 'V':
case 'f':
case 'd':
if (arg < 0) {
arg = argc - currentarg;
}
currentarg += arg;
if (currentarg > argc) {
throw_invalid_argument("Type %c: too few arguments", code);
return false;
}
break;
default:
throw_invalid_argument("Type %c: unknown format code", code);
return false;
}
formatcodes.push_back(code);
formatargs.push_back(arg);
}
if (currentarg < argc) {
throw_invalid_argument("%d arguments unused", (argc - currentarg));
}
int outputpos = 0, outputsize = 0;
//.........这里部分代码省略.........
示例4: getNotFound
CVarRef ArrayData::getNotFound(CStrRef k) {
raise_notice("Undefined index: %s", k.data());
return null_variant;
}
示例5: assert
bool BZ2File::open(CStrRef filename, CStrRef mode) {
assert(m_bzFile == nullptr);
return m_innerFile->open(filename, mode) &&
(m_bzFile = BZ2_bzdopen(dup(m_innerFile->fd()), mode.data()));
}
示例6: f_furchash_hphp_ext
int64_t f_furchash_hphp_ext(CStrRef key, int len, int nPart) {
len = std::max(std::min(len, key.size()), 0);
return furc_hash(key.data(), len, nPart);
}
示例7: String
String StringUtil::Base64Decode(CStrRef input, bool strict /* = false */) {
int len = input.size();
char *ret = string_base64_decode(input.data(), len, strict);
return String(ret, len, AttachString);
}
示例8: UnregisterSandbox
void Debugger::UnregisterSandbox(CStrRef id) {
s_debugger.unregisterSandbox(id.get());
}
示例9: HexDecode
String StringUtil::HexDecode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_hex2bin(input, len);
return String(ret, len, AttachString);
}
示例10: QuotedPrintableDecode
String StringUtil::QuotedPrintableDecode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_quoted_printable_decode(input, len, false);
return String(ret, len, AttachString);
}
示例11: HtmlEncodeExtra
String StringUtil::HtmlEncodeExtra(CStrRef input, QuoteStyle quoteStyle,
const char *charset, bool nbsp,
Array extra) {
if (input.empty()) return input;
assert(charset);
int flags = STRING_HTML_ENCODE_UTF8;
if (nbsp) {
flags |= STRING_HTML_ENCODE_NBSP;
}
if (RuntimeOption::Utf8izeReplace) {
flags |= STRING_HTML_ENCODE_UTF8IZE_REPLACE;
}
if (!*charset || strcasecmp(charset, "UTF-8") == 0) {
} else if (strcasecmp(charset, "ISO-8859-1") == 0) {
flags &= ~STRING_HTML_ENCODE_UTF8;
} else {
throw NotImplementedException(charset);
}
const AsciiMap *am;
AsciiMap tmp;
switch (quoteStyle) {
case FBUtf8Only:
am = &mapNothing;
flags |= STRING_HTML_ENCODE_HIGH;
break;
case FBUtf8:
am = &mapBothQuotes;
flags |= STRING_HTML_ENCODE_HIGH;
break;
case BothQuotes:
am = &mapBothQuotes;
break;
case DoubleQuotes:
am = &mapDoubleQuotes;
break;
case NoQuotes:
am = &mapNoQuotes;
break;
default:
am = &mapNothing;
raise_error("Unknown quote style: %d", (int)quoteStyle);
}
if (quoteStyle != FBUtf8Only && extra.toBoolean()) {
tmp = *am;
am = &tmp;
for (ArrayIter iter(extra); iter; ++iter) {
String item = iter.second().toString();
char c = item.data()[0];
tmp.map[c & 64 ? 1 : 0] |= 1uLL << (c & 63);
}
}
int len = input.size();
char *ret = string_html_encode_extra(input, len,
(StringHtmlEncoding)flags, am);
if (!ret) {
raise_error("HtmlEncode called on too large input (%d)", len);
}
return String(ret, len, AttachString);
}
示例12: RegExEncode
String StringUtil::RegExEncode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_quotemeta(input, len);
return String(ret, len, AttachString);
}
示例13: ini_on_update_real
bool ini_on_update_real(CStrRef value, void *p) {
if (p) {
*((double*)p) = value.toDouble();
}
return true;
}
示例14: ini_on_update_string
bool ini_on_update_string(CStrRef value, void *p) {
if (p) {
*((std::string*)p) = std::string(value.data(), value.size());
}
return true;
}
示例15:
int64 StringUtil::CRC32(CStrRef input) {
return string_crc32(input, input.size());
}