本文整理汇总了C++中ref函数的典型用法代码示例。如果您正苦于以下问题:C++ ref函数的具体用法?C++ ref怎么用?C++ ref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ref函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
/* V_STRING -> V_LENS */
static struct value *lns_seq(struct info *info, struct value *str) {
assert(str->tag == V_STRING);
return lns_make_prim(L_SEQ, ref(info), NULL, ref(str->string));
}
示例2: setRef
inline void setRef(Instance* instance) const {
ref() = instance;
}
示例3: ref
Transformer::Transformer() {
identity_ = true;
mat00 = mat11 = 1;
mat01 = mat10 = mat20 = mat21 = 0;
ref();
}
示例4: ref
void MediaElementAudioSourceNode::lock()
{
ref();
m_processLock.lock();
}
示例5: HHVM_FUNCTION
Variant HHVM_FUNCTION(eregi, const String& pattern, const String& str,
VRefParam regs /* = null */) {
return HHVM_FN(mb_eregi)(pattern, str, ref(regs));
}
示例6: f_preg_match_all
bool TestExtPreg::test_preg_match_all() {
Variant matches;
f_preg_match_all("/\\(? (\\d{3})? \\)? (?(1) [\\-\\s] ) \\d{3}-\\d{4}/x",
"Call 555-1212 or 1-800-555-1212", ref(matches));
VS(f_print_r(matches, true),
"Array\n"
"(\n"
" [0] => Array\n"
" (\n"
" [0] => 555-1212\n"
" [1] => 800-555-1212\n"
" )\n"
"\n"
" [1] => Array\n"
" (\n"
" [0] => \n"
" [1] => 800\n"
" )\n"
"\n"
")\n");
// The \\2 is an example of backreferencing. This tells pcre that
// it must match the second set of parentheses in the regular expression
// itself, which would be the ([\w]+) in this case. The extra backslash is
// required because the string is in double quotes.
String html = "<b>bold text</b><a href=howdy.html>click me</a>";
f_preg_match_all("/(<([\\w]+)[^>]*>)(.*)(<\\/\\2>)/", html, ref(matches),
k_PREG_SET_ORDER);
VS(f_print_r(matches, true),
"Array\n"
"(\n"
" [0] => Array\n"
" (\n"
" [0] => <b>bold text</b>\n"
" [1] => <b>\n"
" [2] => b\n"
" [3] => bold text\n"
" [4] => </b>\n"
" )\n"
"\n"
" [1] => Array\n"
" (\n"
" [0] => <a href=howdy.html>click me</a>\n"
" [1] => <a href=howdy.html>\n"
" [2] => a\n"
" [3] => click me\n"
" [4] => </a>\n"
" )\n"
"\n"
")\n");
String str = "a: 1\nb: 2\nc: 3\n";
f_preg_match_all("/(?<name>\\w+): (?<digit>\\d+)/", str, ref(matches));
VS(f_print_r(matches, true),
"Array\n"
"(\n"
" [0] => Array\n"
" (\n"
" [0] => a: 1\n"
" [1] => b: 2\n"
" [2] => c: 3\n"
" )\n"
"\n"
" [name] => Array\n"
" (\n"
" [0] => a\n"
" [1] => b\n"
" [2] => c\n"
" )\n"
"\n"
" [1] => Array\n"
" (\n"
" [0] => a\n"
" [1] => b\n"
" [2] => c\n"
" )\n"
"\n"
" [digit] => Array\n"
" (\n"
" [0] => 1\n"
" [1] => 2\n"
" [2] => 3\n"
" )\n"
"\n"
" [2] => Array\n"
" (\n"
" [0] => 1\n"
" [1] => 2\n"
" [2] => 3\n"
" )\n"
"\n"
")\n");
return Count(true);
}
示例7: f_collator_sort
Variant f_collator_sort(CVarRef obj, VRefParam arr,
int64 sort_flag /* = q_Collator$$SORT_REGULAR */) {
CHECK_COLL(obj);
return coll->t_sort(ref(arr), sort_flag);
}
示例8: f_getmxrr
bool f_getmxrr(const String& hostname, VRefParam mxhosts,
VRefParam weight /* = uninit_null() */) {
return f_dns_get_mx(hostname, ref(mxhosts), weight);
}
示例9: sendout
void smthread_scanner_t::scan_i_scan(const stid_t& fid, int num_recs,
ss_m::concurrency_t cc)
{
outstream << "********** Starting scanning file " << fid
<< " expecting " << num_recs << " records"
<< endl;
sendout();
scan_file_i scan(fid, cc);
w_rc_t rc = scan.error_code();
if(rc.is_error()) {
cerr << "Could not create scan_i with fid " << fid
<< " error is " << rc
<< endl;
::exit(1);
}
pin_i *handle;
bool eof = false;
int i = START;
do {
w_rc_t rc;
rc = scan.error_code();
if(rc.is_error()) {
cerr << "Could not create scan_i with fid " << fid
<< " error is " << rc
<< endl;
::exit(1);
}
w_assert1(scan.error_code().is_error() == false);
rc = scan.next(handle, 0, eof);
if(rc.is_error()) {
W_COERCE(rc);
}
if(debug) {
outstream << " scanned i " << i << ": "
<< scan.curr_rid
<< " eof=" << eof
<< endl;
sendout();
}
if(eof) break;
w_assert1(handle->pinned());
const char *hdr =handle->hdr();
smsize_t hdrsize=handle->hdr_size();
/// alignment should be ok:
vec_t ref(hdr, hdrsize);
int refi;
ref.copy_to(&refi, sizeof (refi));
const char *datum =handle->body();
smsize_t datasize=handle->body_size();
outstream << handle->rid();
outstream << " header "
<< refi ;
if(append_only) {
w_assert1(refi == i);
// if we used append-only on the file creation,
// we had better find the order preserved.
outstream << "; data (size "
<< datasize
<< ") " << datum ;
outstream << " A:OK " << endl;
} else {
rid_t r;
memcpy(&r, datum, sizeof(r));
w_assert1(r == handle->rid());
outstream << "; data (size "
<< datasize
<< ") " << r ;
outstream << " rid:OK " << endl;
}
sendout();
/*
const char *body =handle->body();
smsize_t bodysize=handle->body_size();
*/
i++;
} while (1) ;
if(num_recs == i-1) {
if(debug) {
outstream << "scan_i scan complete, OK" << endl;
sendout();
}
} else {
outstream << "ERROR IN COUNT: scan_i scan complete, i=" << i-1
<< " num_rec expected =" << num_recs
<< endl;
sendout();
}
assert(i-START == num_recs);
}
示例10: ref
std::pair<int, int> Puzzle::get(int row, int column) const
{
int value = ref(row, column)-1;
return { value / d_columns, value % d_columns };
}
示例11: main
int
main ()
{
struct ss ss;
struct ss ssa[2];
struct arraystruct arraystruct;
string x = make_string ("this is x");
zzz_type c = make_container ("container");
zzz_type c2 = make_container ("container2");
const struct string_repr cstring = { { "const string" } };
/* Clearing by being `static' could invoke an other GDB C++ bug. */
struct nullstr nullstr;
nostring_type nstype, nstype2;
struct memory_error me;
struct ns ns, ns2;
struct lazystring estring, estring2;
struct hint_error hint_error;
struct children_as_list children_as_list;
nstype.elements = narray;
nstype.len = 0;
me.s = "blah";
init_ss(&ss, 1, 2);
init_ss(ssa+0, 3, 4);
init_ss(ssa+1, 5, 6);
memset (&nullstr, 0, sizeof nullstr);
arraystruct.y = 7;
init_s (&arraystruct.x[0], 23);
init_s (&arraystruct.x[1], 24);
ns.null_str = "embedded\0null\0string";
ns.length = 20;
/* Make a "corrupted" string. */
ns2.null_str = NULL;
ns2.length = 20;
estring.lazy_str = "embedded x\201\202\203\204" ;
/* Incomplete UTF-8, but ok Latin-1. */
estring2.lazy_str = "embedded x\302";
#ifdef __cplusplus
S cps;
cps.zs = 7;
init_s(&cps, 8);
SS cpss;
cpss.zss = 9;
init_s(&cpss.s, 10);
SS cpssa[2];
cpssa[0].zss = 11;
init_s(&cpssa[0].s, 12);
cpssa[1].zss = 13;
init_s(&cpssa[1].s, 14);
SSS sss(15, cps);
SSS& ref (sss);
Derived derived;
Fake fake (42);
#endif
add_item (&c, 23); /* MI breakpoint here */
add_item (&c, 72);
#ifdef MI
add_item (&c, 1011);
c.elements[0] = 1023;
c.elements[0] = 2323;
add_item (&c2, 2222);
add_item (&c2, 3333);
substruct_test ();
do_nothing ();
#endif
nstype.elements[0] = 7;
nstype.elements[1] = 42;
nstype.len = 2;
nstype2 = nstype;
eval_sub ();
bug_14741(); /* break to inspect struct and union */
return 0;
}
示例12: f_stream_select
Variant f_stream_select(VRefParam read, VRefParam write, VRefParam except,
CVarRef vtv_sec, int tv_usec /* = 0 */) {
return f_socket_select(ref(read), ref(write), ref(except), vtv_sec, tv_usec);
}
示例13: updateTargetsOk
Status WriteOp::targetWrites( const NSTargeter& targeter,
std::vector<TargetedWrite*>* targetedWrites ) {
bool isUpdate = _itemRef.getOpType() == BatchedCommandRequest::BatchType_Update;
bool isDelete = _itemRef.getOpType() == BatchedCommandRequest::BatchType_Delete;
// In case of error, don't leak.
OwnedPointerVector<ShardEndpoint> endpointsOwned;
vector<ShardEndpoint*>& endpoints = endpointsOwned.mutableVector();
if ( isUpdate || isDelete ) {
// Updates/deletes targeted by query
BSONObj queryDoc =
isUpdate ? _itemRef.getUpdate()->getQuery() : _itemRef.getDelete()->getQuery();
Status targetStatus = targeter.targetQuery( queryDoc, &endpoints );
if ( targetStatus.isOK() ) {
targetStatus =
isUpdate ?
updateTargetsOk( *this, endpoints ) : deleteTargetsOk( *this, endpoints );
}
if ( !targetStatus.isOK() ) return targetStatus;
}
else {
dassert( _itemRef.getOpType() == BatchedCommandRequest::BatchType_Insert );
// Inserts targeted by doc itself
ShardEndpoint* endpoint = NULL;
Status targetStatus = targeter.targetDoc( _itemRef.getDocument(), &endpoint );
if ( !targetStatus.isOK() ) {
dassert( NULL == endpoint );
return targetStatus;
}
dassert( NULL != endpoint );
endpoints.push_back( endpoint );
}
for ( vector<ShardEndpoint*>::iterator it = endpoints.begin(); it != endpoints.end();
++it ) {
ShardEndpoint* endpoint = *it;
_childOps.push_back( new ChildWriteOp( this ) );
WriteOpRef ref( _itemRef.getItemIndex(), _childOps.size() - 1 );
// For now, multiple endpoints imply no versioning
if ( endpoints.size() == 1u ) {
targetedWrites->push_back( new TargetedWrite( *endpoint, ref ) );
}
else {
ShardEndpoint broadcastEndpoint( endpoint->shardName,
ChunkVersion::IGNORED(),
endpoint->shardHost );
targetedWrites->push_back( new TargetedWrite( broadcastEndpoint, ref ) );
}
_childOps.back()->pendingWrite = targetedWrites->back();
_childOps.back()->state = WriteOpState_Pending;
}
_state = WriteOpState_Pending;
return Status::OK();
}
示例14: VS
bool TestExtPreg::test_preg_replace() {
{
String str = "April 15, 2003";
String pattern = "/(\\w+) (\\d+), (\\d+)/i";
String replacement = "${1}1,$3";
VS(f_preg_replace(pattern, replacement, str), "April1,2003");
}
{
String str = "The quick brown fox jumped over the lazy dog.";
Variant patterns, replacements;
patterns.set(0, "/quick/");
patterns.set(1, "/brown/");
patterns.set(2, "/fox/");
replacements.set(2, "bear");
replacements.set(1, "black");
replacements.set(0, "slow");
VS(f_preg_replace(patterns, replacements, str),
"The bear black slow jumped over the lazy dog.");
f_ksort(ref(patterns));
f_ksort(ref(replacements));
VS(f_preg_replace(patterns, replacements, str),
"The slow black bear jumped over the lazy dog.");
}
{
Array foos;
foos.set(0, "foo");
foos.set(1, "Foo");
foos.set(2, "FOO");
Array expFoo;
expFoo.set(0, "FOO");
expFoo.set(1, "FOO");
expFoo.set(2, "FOO");
VS(f_preg_replace("/some pattern/", "", Array::Create()), Array::Create());
VS(f_preg_replace("/foo/i", "FOO", foos), expFoo);
}
{
Array patterns = CREATE_VECTOR2("/(19|20)(\\d{2})-(\\d{1,2})-(\\d{1,2})/",
"/^\\s*{(\\w+)}\\s*=/");
Array replace = CREATE_VECTOR2("\\3/\\4/\\1\\2", "$\\1 =");
VS(f_preg_replace(patterns, replace, "{startDate} = 1999-5-27"),
"$startDate = 5/27/1999");
}
{
String str = "foo o";
str = f_preg_replace("/\\s\\s+/", " ", str);
VS(str, "foo o");
}
{
Variant count = 0;
f_preg_replace(CREATE_VECTOR2("/\\d/", "/\\s/"), "*", "xp 4 to", -1,
ref(count));
VS(count, 3);
}
{
String html_body = "<html><body></body></html>";
String html_body2 = f_preg_replace("/(<\\/?\\w+[^>]*>)/e",
"strtoupper(\"$1\")",
html_body);
VS(html_body2, "<HTML><BODY></BODY></HTML>");
String css_text = "#AAAA;";
String css_text2 = f_preg_replace("/#([A-Fa-f0-9]{3,6});/e",
"strtolower(\"#\\1;\");", css_text);
VS(css_text2, "#aaaa;");
String rgb_text = "rgb(13, 14, 15)";
String rgb_text2 =
f_preg_replace("/rgb\\(([0-9]{1,3}), ([0-9]{1,3}), ([0-9]{1,3})\\)/e",
"sprintf(\"%02x%02x%02x\", \"\\1\", \"\\2\", \"\\3\")",
rgb_text);
VS(rgb_text2, "0d0e0f");
String res = f_preg_replace("/(a*)(b*)/e",
"test_preg_rep(\"\\1\",\"smu\\\"rf\",\"\\2\")",
"aaabbbblahblahaabbbababab");
VS(res, "BBBBaaalahBlahBBBaaBaBaBa");
try {
f_preg_replace("/(<\\/?)(\\w+)([^>]*>)/e",
"'\\\\1'.strtoupper('\\\\2').'\\\\3'",
html_body);
} catch (const NotSupportedException& e) {
return Count(true);
}
}
return Count(false);
}
示例15: main
main() {
var x = 4;
ref(x);
return x;
}