本文整理汇总了C++中RSTRING函数的典型用法代码示例。如果您正苦于以下问题:C++ RSTRING函数的具体用法?C++ RSTRING怎么用?C++ RSTRING使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RSTRING函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:delight,项目名称:Pana,代码行数:64,代码来源:http11.c
示例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;
}
开发者ID:laurynasl,项目名称:webmoney,代码行数:29,代码来源:wmsigner.cpp
示例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;
}
开发者ID:geemus,项目名称:rubyspec,代码行数:7,代码来源:string_spec.c
示例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;
}
开发者ID:nuigroup,项目名称:sketch-up-multitouch,代码行数:31,代码来源:RubyClass.cpp
示例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;
}
开发者ID:brightbox,项目名称:deb-ruby2.3,代码行数:16,代码来源:cstr.c
示例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);
}
开发者ID:greglu,项目名称:zookeeper_client,代码行数:16,代码来源:zookeeper_c.c
示例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);
};
开发者ID:flavorjones,项目名称:nis,代码行数:16,代码来源:yp.c
示例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);
};
开发者ID:flavorjones,项目名称:nis,代码行数:33,代码来源:yp.c
示例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);
}
开发者ID:asimoov,项目名称:emscripted-ruby,代码行数:7,代码来源:error.c
示例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;
}
}
开发者ID:gatgui,项目名称:lwc,代码行数:25,代码来源:registry.cpp
示例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;
}
开发者ID:elektronaut,项目名称:livecode,代码行数:26,代码来源:coremidi.c
示例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;
}
开发者ID:elektronaut,项目名称:livecode,代码行数:26,代码来源:coremidi.c
示例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);
}
开发者ID:ongaeshi,项目名称:ofruby-ios,代码行数:30,代码来源:state.c
示例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 ());
}
开发者ID:noda50,项目名称:RubyItk,代码行数:29,代码来源:object.cpp
示例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;
}
开发者ID:jeremyz,项目名称:rubinius,代码行数:7,代码来源:string_spec.c
示例16: rb_sp_connect
static VALUE rb_sp_connect (VALUE self, VALUE eid, VALUE sockaddr)
{
int _eid = FIX2INT (eid);
const char *_sockaddr = RSTRING (sockaddr)->ptr;
return INT2FIX (sp_connect (_eid, _sockaddr) );
}
开发者ID:tniuli,项目名称:xio,代码行数:7,代码来源:ruby_xio.c
示例17: rCORBA_Request_add_out_arg
VALUE rCORBA_Request_add_out_arg(int _argc, VALUE *_argv, VALUE self)
{
VALUE arg_name = Qnil;
VALUE arg_rtc = Qnil;
// extract and check arguments
rb_scan_args(_argc, _argv, "11", &arg_rtc, &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 OUT arg
if (arg_name!=Qnil)
_req->add_out_arg (_arg_name);
else
_req->add_out_arg ();
}
R2TAO_CATCH;
return ULONG2NUM (_req->arguments ()->count ());
}
开发者ID:noda50,项目名称:RubyItk,代码行数:27,代码来源:object.cpp
示例18: erlix_atom_init
VALUE erlix_atom_init(VALUE self,VALUE string){
ErlixTerm* atom;
VALUE str=StringValue(string);
Data_Get_Struct(self,ErlixTerm,atom);
atom->term=erl_mk_atom(RSTRING(str)->ptr);
return self;
}
开发者ID:jasonjackson,项目名称:erlix,代码行数:7,代码来源:erlix_atom.c
示例19: rb_load_file
static VALUE rb_load_file(VALUE self, VALUE rbfstr)
{
char buf[65535] = { '\0'; }
FILE *f;
VALUE listary, rmobj;
Check_Type(rbfstr, T_STRING);
listary = rb_iv_get(c_map, "list");
f = fopen(RSTRING(rbfstr)->ptr, "r");
if (!f)
rb_raise(rb_eStdError, "file not found: %s", RSTRING(rbfstr)->ptr);
while (fgets(buf, sizeof(buf), f))
load_string(buf, listary);
}
开发者ID:mtmiron,项目名称:lich,代码行数:16,代码来源:textmap.c
示例20: rb_thrift_memory_buffer_read
VALUE rb_thrift_memory_buffer_read(VALUE self, VALUE length_value) {
int length = FIX2INT(length_value);
VALUE index_value = rb_ivar_get(self, index_ivar_id);
int index = FIX2INT(index_value);
VALUE buf = GET_BUF(self);
VALUE data = rb_funcall(buf, slice_method_id, 2, index_value, length_value);
index += length;
if (index > RSTRING_LEN(buf)) {
index = RSTRING_LEN(buf);
}
if (index >= GARBAGE_BUFFER_SIZE) {
rb_ivar_set(self, buf_ivar_id, rb_funcall(buf, slice_method_id, 2, INT2FIX(index), INT2FIX(RSTRING_LEN(buf) - 1)));
index = 0;
}
if (RSTRING(data)->len < length) {
rb_raise(rb_eEOFError, "Not enough bytes remain in memory buffer");
}
rb_ivar_set(self, index_ivar_id, INT2FIX(index));
return data;
}
开发者ID:dbrown,项目名称:poolparty,代码行数:25,代码来源:memory_buffer.c
注:本文中的RSTRING函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论