本文整理汇总了C++中RSTRING函数的典型用法代码示例。如果您正苦于以下问题:C++ RSTRING函数的具体用法?C++ RSTRING怎么用?C++ RSTRING使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RSTRING函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: URIClassifier_resolve
/**
* call-seq:
* uc.resolve("/someuri") -> "/someuri", "", handler
* uc.resolve("/someuri/pathinfo") -> "/someuri", "/pathinfo", handler
* uc.resolve("/notfound/orhere") -> nil, nil, nil
* uc.resolve("/") -> "/", "/", handler # if uc.register("/", handler)
* uc.resolve("/path/from/root") -> "/", "/path/from/root", handler # if uc.register("/", handler)
*
* Attempts to resolve either the whole URI or at the longest prefix, returning
* the prefix (as script_info), path (as path_info), and registered handler
* (usually an HttpHandler). If it doesn't find a handler registered at the longest
* match then it returns nil,nil,nil.
*
* Because the resolver uses a trie you are able to register a handler at *any* character
* in the URI and it will be handled as long as it's the longest prefix. So, if you
* registered handler #1 at "/something/lik", and #2 at "/something/like/that", then a
* a search for "/something/like" would give you #1. A search for "/something/like/that/too"
* would give you #2.
*
* This is very powerful since it means you can also attach handlers to parts of the ;
* (semi-colon) separated path params, any part of the path, use off chars, anything really.
* It also means that it's very efficient to do this only taking as long as the URI has
* characters.
*
* A slight modification to the CGI 1.2 standard is given for handlers registered to "/".
* CGI expects all CGI scripts to be at some script path, so it doesn't really say anything
* about a script that handles the root. To make this work, the resolver will detect that
* the requested handler is at "/", and return that for script_name, and then simply return
* the full URI back as path_info.
*
* It expects strings with no embedded '\0' characters. Don't try other string-like stuff yet.
*/
VALUE URIClassifier_resolve(VALUE self, VALUE uri)
{
void *handler = NULL;
int pref_len = 0;
struct tst *tst = NULL;
VALUE result;
unsigned char *uri_str = NULL;
DATA_GET(self, struct tst, tst);
uri_str = (unsigned char *)StringValueCStr(uri);
handler = tst_search(uri_str, tst, &pref_len);
result = rb_ary_new();
if(handler) {
rb_ary_push(result, rb_str_substr (uri, 0, pref_len));
if(pref_len == 1 && uri_str[0] == '/') {
rb_ary_push(result, uri);
} else {
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING(uri)->len));
}
rb_ary_push(result, (VALUE)handler);
} else {
rb_ary_push(result, Qnil);
rb_ary_push(result, Qnil);
rb_ary_push(result, Qnil);
}
return result;
}
示例2: signer_sign
extern "C" VALUE signer_sign(VALUE self, VALUE szIn)
{
VALUE ret;
ret = rb_str_new2("");
Signer *pSign;
Data_Get_Struct(self, Signer, pSign);
if(NIL_P(szIn)) rb_raise(rb_eArgError, "nil for sign");
if (pSign)
{
szptr szSign;
if (pSign->Sign(RSTRING(szIn)->ptr, szSign))
{
ret = rb_str_new2((char *)(const char *)szSign);
}
}
int err_no = pSign->ErrorCode();
if (err_no){
char err[20];
sprintf(err, "Signer error: %d", err_no);
rb_raise(rb_eStandardError, err);
}
return ret;
}
示例3: string_spec_RSTRING_ptr_assign_call
VALUE string_spec_RSTRING_ptr_assign_call(VALUE self, VALUE str) {
char *ptr = RSTRING(str)->ptr;
ptr[1] = 'x';
rb_str_concat(str, rb_str_new2("d"));
return str;
}
示例4: StringValue
// ----------------------------------------------------------------------------
VALUE RubyClassHandler::SendKeyMacro(VALUE self, VALUE rMacroString)
// ----------------------------------------------------------------------------
{//static called from Ruby
// send a Ruby macro string to our macro processor
// eg., "SendKeyMacro("{LSHIFT DOWN}{MBUTTON DOWN}"
This->m_macroProcessIsBusy = true;
VALUE str = StringValue(rMacroString);
char* p = RSTRING(str)->ptr;
wxString macroKeys(p);
#if defined(LOGGING)
//LOGIT( _T("RubyClassHandler:SendKeyMacro[%s]"), macroKeys.c_str());
#endif
// Make sure keys go to main window (not Ruby console or other foreground)
HWND hRubyConsole = ::FindWindow(_T("#32770"), _T("Ruby Console"));
if (hRubyConsole) {;}
::EnableWindow(g_hWndSketchUp,TRUE);
::SetFocus(g_hWndSketchUp);
::SetForegroundWindow(g_hWndSketchUp);
This->m_pMacroRunner->SendMacroString( macroKeys, wxTheApp->GetTopWindow() );
::SetFocus(g_hWndSketchUp);
This->m_macroProcessIsBusy = false;
return true;
}
示例5: bug_str_s_cstr_noembed
static VALUE
bug_str_s_cstr_noembed(VALUE self, VALUE str)
{
VALUE str2 = rb_str_new(NULL, 0);
long capacity = RSTRING_LEN(str) + TERM_LEN(str);
char *buf = ALLOC_N(char, capacity);
Check_Type(str, T_STRING);
FL_SET((str2), STR_NOEMBED);
memcpy(buf, RSTRING_PTR(str), capacity);
RBASIC(str2)->flags &= ~RSTRING_EMBED_LEN_MASK;
RSTRING(str2)->as.heap.aux.capa = capacity;
RSTRING(str2)->as.heap.ptr = buf;
RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
TERM_FILL(RSTRING_END(str2), TERM_LEN(str));
return str2;
}
示例6: method_create
static VALUE method_create(VALUE self, VALUE path, VALUE value, VALUE flags) {
char realpath[10240];
Check_Type(path, T_STRING);
Check_Type(value, T_STRING);
Check_Type(flags, T_FIXNUM);
FETCH_DATA_PTR(self, zk);
check_errors(zoo_create(zk->zh, RSTRING(path)->ptr,
RSTRING(value)->ptr, RSTRING(value)->len,
&ZOO_OPEN_ACL_UNSAFE, FIX2INT(flags),
realpath, sizeof(realpath)));
return rb_str_new2(realpath);
}
示例7: rb_yp_update
VALUE
rb_yp_update(VALUE self, VALUE domain, VALUE map, VALUE ypop, VALUE inkey, VALUE inval)
{
int res;
if( domain == Qnil ) {
domain = rb_yp_get_default_domain(self);
};
res = yp_update(STR2CSTR(domain), STR2CSTR(map), FIX2INT(ypop),
STR2CSTR(inkey), RSTRING(inkey)->len,
STR2CSTR(inval), RSTRING(inval)->len);
rb_yp_check_yperr(res);
return INT2NUM(res);
};
示例8: rb_yp_next
VALUE
rb_yp_next(VALUE self, VALUE domain, VALUE map, VALUE inkey)
{
char *key, *val;
int keylen, vallen;
int res;
VALUE vkey, vval;
if( domain == Qnil ) {
domain = rb_yp_get_default_domain(self);
};
res = yp_next(STR2CSTR(domain), STR2CSTR(map),
STR2CSTR(inkey), RSTRING(inkey)->len,
&key, &keylen, &val, &vallen);
rb_yp_check_yperr(res);
if( keylen > 0 ) {
vkey = rb_tainted_str_new(key, keylen);
}
else {
vkey = Qnil;
};
if( vallen > 0 ) {
vval = rb_tainted_str_new(val, vallen);
}
else {
vval = Qnil;
};
return rb_assoc_new(vkey, vval);
};
示例9: rb_invalid_str
void
rb_invalid_str(const char *str, const char *type)
{
VALUE s = rb_str_inspect(rb_str_new2(str));
rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING(s)->ptr);
}
示例10: rbreg_get
static VALUE rbreg_get(VALUE, VALUE rname) {
lwc::Registry *reg = lwc::Registry::Instance();
if (!reg) {
rb_raise(rb_eRuntimeError, "lwc::Registry has not yet been initialized");
}
VALUE sname = rb_check_string_type(rname);
if (NIL_P(sname)) {
rb_raise(rb_eTypeError, "RLWC::Registry.get expects a string as argument");
}
char *name = RSTRING(sname)->ptr;
lwc::Object *obj = reg->get(name);
if (!obj) {
return Qnil;
} else {
VALUE rv = Qnil;
//if (!strcmp(obj->getLoaderName(), "rbloader")) {
// rv = ((Object*)obj)->self();
//
//} else {
rv = rb_funcall2(cLWCObject, rb_intern("new"), 0, NULL);
SetObjectPointer(rv, obj);
//}
return rv;
}
}
示例11: t_create_destination
// Create a new destination endpoint
static VALUE t_create_destination(VALUE self, VALUE client_instance, VALUE destination_name)
{
MIDIEndpointRef destination;
RbMIDIClient* client;
Data_Get_Struct(client_instance, RbMIDIClient, client);
CFStringRef destination_str = CFStringCreateWithCString(kCFAllocatorDefault, RSTRING(destination_name)->ptr, kCFStringEncodingASCII);
MIDIDestinationCreate(client->client, destination_str, RbMIDIReadProc, NULL, &destination);
VALUE destination_instance = rb_class_new_instance(0, 0, cEndpoint);
if( destination_instance == Qnil )
{
free_objects();
rb_fatal("Couldn't create an instance of Endpoint!");
}
RbEndpoint* endpoint_struct;
Data_Get_Struct(destination_instance, RbEndpoint, endpoint_struct);
endpoint_struct->endpoint = destination;
return destination_instance;
}
示例12: t_create_source
// Create a new source endpoint
static VALUE t_create_source(VALUE self, VALUE client_instance, VALUE source_name)
{
MIDIEndpointRef source;
RbMIDIClient* client;
Data_Get_Struct(client_instance, RbMIDIClient, client);
CFStringRef source_str = CFStringCreateWithCString(kCFAllocatorDefault, RSTRING(source_name)->ptr, kCFStringEncodingASCII);
MIDISourceCreate(client->client, source_str, &source);
VALUE source_instance = rb_class_new_instance(0, 0, cEndpoint);
if( source_instance == Qnil )
{
free_objects();
rb_fatal("Couldn't create an instance of Endpoint!");
}
RbEndpoint* endpoint_struct;
Data_Get_Struct(source_instance, RbEndpoint, endpoint_struct);
endpoint_struct->endpoint = source;
return source_instance;
}
示例13: mrb_irep_free
void
mrb_irep_free(mrb_state *mrb, mrb_irep *irep)
{
size_t i;
if (!(irep->flags & MRB_ISEQ_NO_FREE))
mrb_free(mrb, irep->iseq);
for (i=0; i<irep->plen; i++) {
if (mrb_type(irep->pool[i]) == MRB_TT_STRING) {
mrb_gc_free_str(mrb, RSTRING(irep->pool[i]));
mrb_free(mrb, mrb_obj_ptr(irep->pool[i]));
}
#ifdef MRB_WORD_BOXING
else if (mrb_type(irep->pool[i]) == MRB_TT_FLOAT) {
mrb_free(mrb, mrb_obj_ptr(irep->pool[i]));
}
#endif
}
mrb_free(mrb, irep->pool);
mrb_free(mrb, irep->syms);
for (i=0; i<irep->rlen; i++) {
mrb_irep_decref(mrb, irep->reps[i]);
}
mrb_free(mrb, irep->reps);
mrb_free(mrb, irep->lv);
mrb_free(mrb, (void *)irep->filename);
mrb_free(mrb, irep->lines);
mrb_debug_info_free(mrb, irep->debug_info);
mrb_free(mrb, irep);
}
示例14: rCORBA_Request_add_inout_arg
VALUE rCORBA_Request_add_inout_arg(int _argc, VALUE *_argv, VALUE self)
{
VALUE arg_name = Qnil;
VALUE arg_rtc = Qnil;
VALUE arg_rval = Qnil;
// extract and check arguments
rb_scan_args(_argc, _argv, "21", &arg_rtc, &arg_rval, &arg_name);
r2tao_check_type(arg_rtc, r2tao_cTypecode);
if (arg_name!=Qnil)
Check_Type(arg_name, T_STRING);
CORBA::Request_ptr _req = r2tao_Request_r2t(self);
R2TAO_TRY
{
CORBA::ORB_var _orb = _req->target ()->_get_orb ();
CORBA::TypeCode_var _arg_tc = r2tao_Typecode_r2t (arg_rtc, _orb. in());
char *_arg_name = (arg_name!=Qnil) ? RSTRING (arg_name)->ptr : 0;
// add INOUT arg
CORBA::Any& _arg = (arg_name!=Qnil) ?
_req->add_inout_arg (_arg_name) : _req->add_inout_arg ();
// assign value to Any
if (arg_rval!=Qnil)
r2tao_Typecode_Ruby2Any(_arg, _arg_tc.in (), arg_rval, _orb.in ());
}
R2TAO_CATCH;
return ULONG2NUM (_req->arguments ()->count ());
}
示例15: string_spec_RSTRING_ptr_assign_funcall
VALUE string_spec_RSTRING_ptr_assign_funcall(VALUE self, VALUE str) {
char *ptr = RSTRING(str)->ptr;
ptr[1] = 'x';
rb_funcall(str, rb_intern("<<"), 1, rb_str_new2("e"));
return str;
}