本文整理汇总了C++中IS_STRING函数的典型用法代码示例。如果您正苦于以下问题:C++ IS_STRING函数的具体用法?C++ IS_STRING怎么用?C++ IS_STRING使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IS_STRING函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MPIrecv
Obj MPIrecv( Obj self, Obj args )
{ volatile Obj buf, source, tag; /* volatile to satisfy gcc compiler */
MPIARGCHK( 1, 3, MPI_Recv( <string buf>, <opt int source = MPI_ANY_SOURCE>[, <opt int tag = MPI_ANY_TAG> ] ) );
buf = ELM_LIST( args, 1 );
source = ( LEN_LIST(args) > 1 ? ELM_LIST( args, 2 ) :
INTOBJ_INT(MPI_ANY_SOURCE) );
tag = ( LEN_LIST(args) > 2 ? ELM_LIST( args, 3 ) :
INTOBJ_INT(MPI_ANY_TAG) );
if ( ! IS_STRING( buf ) )
ErrorQuit("MPI_Recv(): received a buffer that is not a string", 0L, 0L);
ConvString( buf );
/* Note GET_LEN_STRING() returns GAP string length
and strlen(CSTR_STRING()) returns C string length (up to '\0') */
if ( ! MPI_READ_ERROR() )
MPI_Recv( CSTR_STRING(buf), GET_LEN_STRING(buf),
last_datatype=MPIdatatype_infer(buf),
INT_INTOBJ(source), INT_INTOBJ(tag), MPI_COMM_WORLD, &last_status);
MPI_READ_DONE();
if ( ! IS_STRING( buf ) )
{ /* CLEAN THIS UP LATER */
ErrorQuit("ParGAP: panic: MPI_Recv(): result buffer is not a string", 0L, 0L);
exit(1);
}
/* if (last_datatype != MPI_CHAR) {
MPI_Get_count(&last_status, last_datatype, &count); etc. } */
return buf;
}
开发者ID:ChristopherRussell,项目名称:gap,代码行数:27,代码来源:gapmpi.c
示例2: nl_compare_internal
int nl_compare_internal(ImmT left, ImmT right) {
if (_global_const_begin_ != NULL && left >= _global_const_begin_ && left < _global_const_end_
&& right >= _global_const_begin_ && right < _global_const_end_) {
return left == right;
}
if (((NlData *)left)->type != ((NlData *)right)->type) {
if(IS_INT(left) && IS_STRING(right))
return eq_int_string((NlInt *)left, (NlString *)right);
if(IS_INT(right) && IS_STRING(left))
return eq_int_string((NlInt *)right, (NlString *)left);
if(IS_INT(right) && IS_FLOAT(left))
return ((NlInt *)right)->i == ((NlFloat *)left)->f;
if(IS_INT(left) && IS_FLOAT(right))
return ((NlInt *)left)->i == ((NlFloat *)right)->f;
if(IS_FLOAT(left) && IS_STRING(right))
return eq_float_string((NlFloat *)left, (NlString *)right);
if(IS_FLOAT(right) && IS_STRING(left))
return eq_float_string((NlFloat *)right, (NlString *)left);
return 0;
}
if (((NlData *)left)->type == ___TYPE_STRING) {
return compare_strings((NlString *)left, (NlString *)right) == 0;
} else if (((NlData *)left)->type == ___TYPE_INT) {
return (((NlInt *)left)->i == ((NlInt *)right)->i);
} else if (((NlData *)left)->type == ___TYPE_FLOAT) {
return (((NlFloat *)left)->f == ((NlFloat *)right)->f);
} else {
return left == right;
}
}
开发者ID:nianiolang,项目名称:nl,代码行数:32,代码来源:c_rt_lib.c
示例3: PN_ASSERT
static pn_object *PnStdio_PrintLine(pn_world *world, pn_object *object, pn_object *params[], int length)
{
PN_ASSERT(world != NULL);
PN_ASSERT(object != NULL);
PN_ASSERT(length == 1);
pn_object *a_param = NULL;
if (IS_STRING(params[0]))
a_param = params[0];
else
a_param = PnFunction_ExecuteByObject("to_str", world, params[0], NULL, 0);
PN_ASSERT(IS_STRING(a_param));
__print(a_param->val.str_val);
__print("\n");
size_t len = strlen(a_param->val.str_val);
char *s = (char *)malloc(sizeof(char) * (len + 2));
strcpy(s, a_param->val.str_val);
s[len] = '\n';
s[len+1] = 0;
pn_object *ret = PnString_Create(world, s);
PN_ASSERT(ret != NULL);
PN_ASSERT(IS_STRING(ret));
free(s);
return ret;
}
开发者ID:jongyeol,项目名称:peanut,代码行数:32,代码来源:pnstdio.c
示例4: EQ
bool disque_job::init(const redis_result& rr)
{
size_t n;
const redis_result** children = rr.get_children(&n);
if (n == 0)
return false;
if (n % 2 != 0)
return false;
string name;
for (size_t i = 0; i < n;)
{
const redis_result* r1 = children[i];
i++;
const redis_result* r2 = children[i];
i++;
if (r1->get_type() != REDIS_RESULT_STRING)
continue;
name.clear();
r1->argv_to_string(name);
if (name.empty())
continue;
redis_result_t type = r2->get_type();
#define EQ(x, y) !strcasecmp((x).c_str(), (y))
#define IS_NUMBER(x) (x) == REDIS_RESULT_INTEGER
#define IS_STRING(x) (x) == REDIS_RESULT_STRING
#define IS_ARRAY(x) (x) == REDIS_RESULT_ARRAY
if (EQ(name, "id") && IS_STRING(type))
r2->argv_to_string(id_);
else if (EQ(name, "queue") && IS_STRING(type))
r2->argv_to_string(queue_);
else if (EQ(name, "state") && IS_STRING(type))
r2->argv_to_string(state_);
else if (EQ(name, "repl") && IS_NUMBER(type))
repl_ = r2->get_integer();
else if (EQ(name, "ttl") && IS_NUMBER(type))
ttl_ = r2->get_integer();
else if (EQ(name, "ctime") && IS_NUMBER(type))
ctime_ = r2->get_integer64();
else if (EQ(name, "delay") && IS_NUMBER(type))
delay_ = r2->get_integer();
else if (EQ(name, "retry") && IS_NUMBER(type))
retry_ = r2->get_integer();
else if (EQ(name, "nodes-delivered") && IS_ARRAY(type))
set_nodes_delivered(*r2);
else if (EQ(name, "nodes-confirmed") && IS_ARRAY(type))
set_nodes_confirmed(*r2);
else if (EQ(name, "next-requeue-within") && IS_NUMBER(type))
next_requeue_within_ = r2->get_integer();
else if (EQ(name, "next-awake-within") && IS_NUMBER(type))
next_awake_within_ = r2->get_integer();
else if (EQ(name, "body") && IS_STRING(type))
r2->argv_to_string(body_);
}
return true;
}
开发者ID:AALEKH,项目名称:acl,代码行数:60,代码来源:disque_job.cpp
示例5: print_exception
void print_exception(VM *vm, VALUE result) {
// TODO: fprintf to stderr and teach dump_titled to optionally fprintf to stderr too
printf("====== Exception of type '%s' ======\n", obj_to_cstring(NGS_TYPE_NAME(NORMAL_TYPE_INSTANCE_TYPE(result))));
// TODO: maybe macro to iterate attributes
VALUE fields = NGS_TYPE_FIELDS(NORMAL_TYPE_INSTANCE_TYPE(result));
HASH_OBJECT_ENTRY *e;
for(e=HASH_HEAD(fields); e; e=e->insertion_order_next) {
if(obj_is_of_type(ARRAY_ITEMS(NORMAL_TYPE_INSTANCE_FIELDS(result))[GET_INT(e->val)], vm->Backtrace)) {
printf("=== [ backtrace ] ===\n");
// Backtrace.frames = [{"closure": ..., "ip": ...}, ...]
VALUE backtrace = ARRAY_ITEMS(NORMAL_TYPE_INSTANCE_FIELDS(result))[GET_INT(e->val)];
VALUE frames;
assert(get_normal_type_instace_attribute(backtrace, make_string("frames"), &frames) == METHOD_OK);
unsigned int i;
for(i = 0; i < OBJ_LEN(frames); i++) {
VALUE frame, resolved_ip, ip;
frame = ARRAY_ITEMS(frames)[i];
H(ip, frame, "ip");
resolved_ip = resolve_ip(vm, (IP)(GET_INT(ip) - 1));
if(IS_HASH(resolved_ip)) {
VALUE file, first_line, first_column, last_line, last_column;
HASH_OBJECT_ENTRY *closure_entry;
char *closure_name = "<anonymous>";
H(file, resolved_ip, "file");
H(first_line, resolved_ip, "first_line");
H(first_column, resolved_ip, "first_column");
H(last_line, resolved_ip, "last_line");
H(last_column, resolved_ip, "last_column");
closure_entry = get_hash_key(frame, make_string("closure"));
if(closure_entry && IS_CLOSURE(closure_entry->val) && (IS_HASH(CLOSURE_OBJ_ATTRS(closure_entry->val)))) {
HASH_OBJECT_ENTRY *name_entry;
name_entry = get_hash_key(CLOSURE_OBJ_ATTRS(closure_entry->val), make_string("name"));
if(name_entry) {
closure_name = obj_to_cstring(name_entry->val);
}
}
// TODO: fix types
printf("[Frame #%u] %s:%d:%d - %d:%d [in %s]\n", i, obj_to_cstring(file), (int) GET_INT(first_line), (int) GET_INT(first_column), (int) GET_INT(last_line), (int) GET_INT(last_column), closure_name);
} else {
printf("[Frame #%u] (no source location)\n", i);
}
}
continue;
}
if(obj_is_of_type(ARRAY_ITEMS(NORMAL_TYPE_INSTANCE_FIELDS(result))[GET_INT(e->val)], vm->Exception)) {
assert(IS_STRING(e->key));
printf("---8<--- %s - start ---8<---\n", obj_to_cstring(e->key));
print_exception(vm, ARRAY_ITEMS(NORMAL_TYPE_INSTANCE_FIELDS(result))[GET_INT(e->val)]);
printf("---8<--- %s - end ---8<---\n", obj_to_cstring(e->key));
continue;
}
if(IS_STRING(e->key)) {
dump_titled(obj_to_cstring(e->key), ARRAY_ITEMS(NORMAL_TYPE_INSTANCE_FIELDS(result))[GET_INT(e->val)]);
} else {
// Should not happen
dump_titled("attribute key", e->key);
dump_titled("attribute value", ARRAY_ITEMS(NORMAL_TYPE_INSTANCE_FIELDS(result))[GET_INT(e->val)]);
}
}
}
开发者ID:Wingie,项目名称:ngs,代码行数:60,代码来源:ngs.c
示例6: string_eq
static int string_eq(vm_thread_t *thread, obj_t *a, obj_t *b)
{
SAFE_ASSERT(IS_STRING(*a));
SAFE_ASSERT(IS_STRING(*b));
string_t *sa = PTR(*a);
string_t *sb = PTR(*b);
RETURN_BOOL(strcmp(sa->str, sb->str) == 0);
}
开发者ID:szastupov,项目名称:lgears,代码行数:9,代码来源:strings.c
示例7: f_uconf
static int f_uconf(int uart, int speed) {
if (_argc != 2) {
return -1;
}
if (IS_STRING(uart) || IS_STRING(speed) || uart < 0 || uart >= CONFIG_UART_CNT) {
return -1;
}
UART_config(_UART(uart), speed,
UART_DATABITS_8, UART_STOPBITS_1, UART_PARITY_NONE, UART_FLOWCONTROL_NONE, TRUE);
return 0;
}
开发者ID:godzivan,项目名称:arcadehid,代码行数:12,代码来源:cli.c
示例8: lessThanNonNum
static bool lessThanNonNum(Value a, Value b) {
if (IS_STRING(a) && IS_STRING(b)) {
char *p1 = GET_CSTR(a);
char *p2 = GET_CSTR(b);
unsigned len1 = len(a);
unsigned len2 = len(b);
int cmp = strncmp(p1, p2, min(len1, len2));
return cmp < 0 || (cmp == 0 && len1 < len2);
}
if (IS_ARRAY(a) && IS_ARRAY(b)) {
return ARRAY(a)->lessThan(ARRAY(b));
}
return false;
}
开发者ID:preda,项目名称:pepper,代码行数:14,代码来源:VM.cpp
示例9: validateString
bool validateString(WrenVM* vm, Value* args, int index, const char* argName)
{
if (IS_STRING(args[index])) return true;
args[0] = wrenStringFormat(vm, "$ must be a string.", argName);
return false;
}
开发者ID:AlexGreg,项目名称:wren-sys,代码行数:7,代码来源:wren_primitive.c
示例10: ReplaceDebugAlloc
void _stdcall ReplaceDebugAlloc(void* pOrig, void* pNew, int nSize)
{
LPDBGALLOCINFO pDbg = gpDbgInfo;
VALUE(vProgInfo);
char* pProgInfo = 0;
if (!pNew || !gbTrackAlloc)
return;
while (pDbg && pDbg->pPointer != pOrig)
pDbg = pDbg->next;
if (pDbg)
{
EVALUATE(vProgInfo,"ALLTRIM(STR(LINENO())) + ':' + PROGRAM() + CHR(0)");
if (IS_STRING(vProgInfo))
{
pProgInfo = strdup(HANDTOPTR(vProgInfo));
FREEHAND(vProgInfo);
}
if (pDbg->pProgInfo)
free(pDbg->pProgInfo);
pDbg->pPointer = pNew;
pDbg->pProgInfo = pProgInfo;
pDbg->nSize = nSize;
}
}
开发者ID:akrisiun,项目名称:VfpProj,代码行数:29,代码来源:vfp2cmarshal.c
示例11: AddDebugAlloc
void _stdcall AddDebugAlloc(void* pPointer, int nSize)
{
VALUE(vProgInfo);
LPDBGALLOCINFO pDbg;
char *pProgInfo = 0;
if (pPointer && gbTrackAlloc)
{
pDbg = malloc(sizeof(DBGALLOCINFO));
if (!pDbg)
return;
EVALUATE(vProgInfo,"ALLTRIM(STR(LINENO())) + ':' + PROGRAM() + CHR(0)");
if (IS_STRING(vProgInfo))
{
pProgInfo = strdup(HANDTOPTR(vProgInfo));
FREEHAND(vProgInfo);
}
pDbg->pPointer = pPointer;
pDbg->pProgInfo = pProgInfo;
pDbg->nSize = nSize;
pDbg->next = gpDbgInfo;
gpDbgInfo = pDbg;
}
}
开发者ID:akrisiun,项目名称:VfpProj,代码行数:26,代码来源:vfp2cmarshal.c
示例12: string_length
static int string_length(vm_thread_t *thread, obj_t *ostr)
{
SAFE_ASSERT(IS_STRING(*ostr));
string_t *str = PTR(*ostr);
RETURN_FIXNUM(str->size-1);
}
开发者ID:szastupov,项目名称:lgears,代码行数:7,代码来源:strings.c
示例13: wrenDebugPrintStackTrace
void wrenDebugPrintStackTrace(ObjFiber* fiber)
{
if (IS_STRING(fiber->error))
{
fprintf(stderr, "%s\n", AS_CSTRING(fiber->error));
}
else
{
// TODO: Print something a little useful here. Maybe the name of the error's
// class?
fprintf(stderr, "[error object]\n");
}
for (int i = fiber->numFrames - 1; i >= 0; i--)
{
CallFrame* frame = &fiber->frames[i];
ObjFn* fn = wrenGetFrameFunction(frame);
// Built-in libraries and method call stubs have no source path and are
// explicitly omitted from stack traces since we don't want to highlight to
// a user the implementation detail of what part of a core library is
// implemented in C and what is in Wren.
if (fn->debug->sourcePath == NULL ||
fn->debug->sourcePath->length == 0)
{
continue;
}
// -1 because IP has advanced past the instruction that it just executed.
int line = fn->debug->sourceLines[frame->ip - fn->bytecode - 1];
fprintf(stderr, "[%s line %d] in %s\n",
fn->debug->sourcePath->value, line, fn->debug->name);
}
}
开发者ID:hbarve1,项目名称:wren,代码行数:34,代码来源:wren_debug.c
示例14: CLEARS
*/ static void Write_File_Port(REBREQ *file, REBVAL *data, REBCNT len, REBCNT args)
/*
***********************************************************************/
{
REBSER *ser;
if (IS_BLOCK(data)) {
// Form the values of the block
// !! Could be made more efficient if we broke the FORM
// into 32K chunks for writing.
REB_MOLD mo;
CLEARS(&mo);
Reset_Mold(&mo);
if (args & AM_WRITE_LINES) {
mo.opts = 1 << MOPT_LINES;
}
Mold_Value(&mo, data, 0);
Set_String(data, mo.series); // fall into next section
len = SERIES_TAIL(mo.series);
}
// Auto convert string to UTF-8
if (IS_STRING(data)) {
ser = Encode_UTF8_Value(data, len, ENCF_OS_CRLF);
file->common.data = ser? BIN_HEAD(ser) : VAL_BIN_DATA(data); // No encoding may be needed
len = SERIES_TAIL(ser);
}
else {
file->common.data = VAL_BIN_DATA(data);
}
file->length = len;
OS_DO_DEVICE(file, RDC_WRITE);
}
开发者ID:mbk,项目名称:ren-c,代码行数:33,代码来源:p-file.c
示例15: if
const char *typeStr(Value v) {
const char *s = "?";
if (IS_NIL(v)) {
s = "nil";
} else if (IS_NUM(v)) {
s = "number";
} else if (IS_STRING(v)) {
s = "string";
} else if (IS_ARRAY(v)) {
s = "array";
} else if (IS_MAP(v)) {
s = "map";
} else if (IS_FUNC(v)) {
s = "func";
} else if (IS_CFUNC(v)) {
s = "cfunc";
} else if (IS_CF(v)) {
s = "cf";
} else if (IS_CP(v)) {
s = "cp";
} else if (IS_PROTO(v)) {
s = "proto";
} else if (IS_REG(v)) {
s = "reg";
}
return s;
}
开发者ID:preda,项目名称:pepper,代码行数:27,代码来源:StringBuilder.cpp
示例16: validateString
bool validateString(WrenVM* vm, Value arg, const char* argName)
{
if (IS_STRING(arg)) return true;
vm->fiber->error = wrenStringFormat(vm, "$ must be a string.", argName);
return false;
}
开发者ID:Rohansi,项目名称:wren,代码行数:7,代码来源:wren_primitive.c
示例17: pretty_print
void pretty_print(env_t *env, VALUE v, int i) {
if (VALUE_IS_ERROR(v)) {
printf("<error>\n");
} else if (IS_LIST(v)) {
printf("(\n");
int j;
for (j = 0; j < list_len(v); j++) {
indent(i + 1); pretty_print(env, list_get(v, j), i + 1);
}
indent(i); printf(")\n");
} else {
if (VALUE_IS_INT(v)) {
printf("%lld\n", INTVAL(v));
} else if (VALUE_IS_BOOL(v)) {
printf("#%c\n", BOOLVAL(v) ? 't' : 'f');
} else if (VALUE_IS_NIL(v)) {
printf("#nil\n");
} else if (VALUE_IS_IDENT(v)) {
printf("%s\n", intern_table_get_str(&env->intern, IDENT(v)));
} else if (VALUE_IS_ATOM(v)) {
printf(":%s\n", intern_table_get_str(&env->intern, ATOM(v)));
} else if (IS_STRING(v)) {
printf("\"%s\"\n", string_chars(v));
} else {
printf("<unknown %p>\n", v);
}
}
}
开发者ID:jaz303,项目名称:lispy,代码行数:28,代码来源:io.c
示例18: f_help
static int f_help(char *s) {
if (IS_STRING(s)) {
int i = 0;
while (c_tbl[i].name != NULL ) {
if (strcmp(s, c_tbl[i].name) == 0) {
print("%s\t%s", c_tbl[i].name, c_tbl[i].help);
return 0;
}
i++;
}
print("%s\tno such command\n", s);
} else {
print (" ");
cli_print_app_name();
print("\n");
int i = 0;
while (c_tbl[i].name != NULL ) {
if ((c_tbl[i].dbg && __dbg_level < 1) || (!c_tbl[i].dbg)) {
int len = strpbrk(c_tbl[i].help, "\n") - c_tbl[i].help;
char tmp[64];
strncpy(tmp, c_tbl[i].help, len + 1);
tmp[len + 1] = 0;
char fill[24];
int fill_len = sizeof(fill) - strlen(c_tbl[i].name);
memset(fill, ' ', sizeof(fill));
fill[fill_len] = 0;
print(" %s%s%s", c_tbl[i].name, fill, tmp);
}
i++;
}
}
return 0;
}
开发者ID:godzivan,项目名称:arcadehid,代码行数:33,代码来源:cli.c
示例19: WritePCString
void _fastcall WritePCString(ParamBlk *parm)
{
char *pNewAddress = 0;
char **pOldAddress = (char**)p1.ev_long;
if (IS_STRING(p2) && pOldAddress)
{
__try
{
if ((*pOldAddress))
{
pNewAddress = HeapReAlloc(ghHeap,HEAP_E_FLAG,(*pOldAddress),p2.ev_length+1);
REPLACEDEBUGALLOC(*pOldAddress,pNewAddress,p2.ev_length);
}
else
{
pNewAddress = HeapAlloc(ghHeap,HEAP_E_FLAG,p2.ev_length+1);
ADDDEBUGALLOC(pNewAddress,p2.ev_length);
}
}
__except(SAVEHEAPEXCEPTION()) { }
if (pNewAddress)
{
*pOldAddress = pNewAddress;
LOCKHAND(p2);
memcpy(pNewAddress,HANDTOPTR(p2),p2.ev_length);
pNewAddress[p2.ev_length] = '\0';
UNLOCKHAND(p2);
RET_POINTER(pNewAddress);
return;
}
else
RAISEERROREX(0);
}
开发者ID:akrisiun,项目名称:VfpProj,代码行数:35,代码来源:vfp2cmarshal.c
示例20: genTypeName
int genTypeName(const DCL_NOM_STR* dcl, char* buf)
{
char buf2[80];
char *addr = NULL;
int i;
switch(dcl->type->type) {
case CHAR:
sprintf(buf2, "c_char");
break;
case INT:
if (dcl->type->flags & SHORT_INT) {
if (dcl->type->flags & UNSIGNED_TYPE)
sprintf(buf2, "c_ushort");
else
sprintf(buf2, "c_short");
} else if (dcl->type->flags & LONG_INT) {
if (dcl->type->flags & UNSIGNED_TYPE)
sprintf(buf2, "c_ulong");
else
sprintf(buf2, "c_long");
} else if (dcl->type->flags & LONG_LONG_INT) {
if (dcl->type->flags & UNSIGNED_TYPE)
sprintf(buf2, "c_ulonglong");
else
sprintf(buf2, "c_longlong");
} else {
if (dcl->type->flags & UNSIGNED_TYPE)
sprintf(buf2, "c_uint");
else
sprintf(buf2, "c_int");
}
break;
case FLOAT:
sprintf(buf2, "c_float");
break;
case DOUBLE:
sprintf(buf2, "c_double");
break;
case ENUM:
sprintf(buf2, "c_uint");
break;
default:
sprintf(buf2, "%s", dcl->type->name);
}
if (IS_ARRAY(dcl) || IS_STRING(dcl)) {
for (i = 0; i < dcl->ndimensions; i++) {
bufcat(&addr, " * %d", dcl->dimensions[i]);
}
sprintf(buf, "%s %s", buf2, addr);
free(addr);
} else {
sprintf(buf, "%s", buf2);
}
return 0;
}
开发者ID:openrobots,项目名称:genom,代码行数:59,代码来源:pythonInterfaceGen.c
注:本文中的IS_STRING函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论