本文整理汇总了C++中TO_STR函数的典型用法代码示例。如果您正苦于以下问题:C++ TO_STR函数的具体用法?C++ TO_STR怎么用?C++ TO_STR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TO_STR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: func_new
// new Function([arg1[, arg2[, ...]],] functionBody)
js_val *
func_new(js_val *instance, js_args *args, eval_state *state)
{
unsigned arglen = ARGLEN(args);
unsigned i = 0;
char *arg_lst = NULL;
char *tmp;
for (i = 0; arglen > 0 && i < (arglen - 1); i++) {
if (!arg_lst) {
arg_lst = TO_STR(ARG(args, i))->string.ptr;
}
else {
tmp = arg_lst;
arg_lst = fh_str_concat(arg_lst, ", ");
free(tmp);
tmp = arg_lst;
arg_lst = fh_str_concat(arg_lst, TO_STR(ARG(args, i))->string.ptr);
free(tmp);
}
}
if (arglen <= 1)
arg_lst = "";
char *body = arglen > 0 ? TO_STR(ARG(args, i))->string.ptr : "";
char *fmt = "(function(%s) { %s });";
int size = snprintf(NULL, 0, fmt, arg_lst, body) + 1;
char *func_def = malloc(size);
snprintf(func_def, size, fmt, arg_lst, body);
return fh_eval_string(func_def, state->ctx);
}
示例2: hdfsSingleNameNodeConnect
static int hdfsSingleNameNodeConnect(struct NativeMiniDfsCluster *cl, hdfsFS *fs,
const char *username)
{
int ret;
tPort port;
hdfsFS hdfs;
struct hdfsBuilder *bld;
port = (tPort)nmdGetNameNodePort(cl);
if (port < 0) {
fprintf(stderr, "hdfsSingleNameNodeConnect: nmdGetNameNodePort "
"returned error %d\n", port);
return port;
}
bld = hdfsNewBuilder();
if (!bld)
return -ENOMEM;
hdfsBuilderSetForceNewInstance(bld);
hdfsBuilderSetNameNode(bld, "localhost");
hdfsBuilderSetNameNodePort(bld, port);
hdfsBuilderConfSetStr(bld, "dfs.block.size",
TO_STR(TLH_DEFAULT_BLOCK_SIZE));
hdfsBuilderConfSetStr(bld, "dfs.blocksize",
TO_STR(TLH_DEFAULT_BLOCK_SIZE));
if (username) {
hdfsBuilderSetUserName(bld, username);
}
hdfs = hdfsBuilderConnect(bld);
if (!hdfs) {
ret = -errno;
return ret;
}
*fs = hdfs;
return 0;
}
示例3: free_input
void free_input()
{
int i;
if( input_strs_args )
{
for( i = 0; i < size_input_prm; ++i )
{
if( input_strs_args[i] )
{
free( input_strs_args[i] );
}
}
free( input_strs_args );
}
if( input_strs_file )
{
for( i = 0; i < size_input_prm; ++i )
{
if( input_strs_file[i] )
{
free( input_strs_file[i] );
}
}
free( input_strs_file );
}
for( i = 0; i < size_input_prm; ++i )
{
if( input_prm[i]->ptr )
{
if( strcmp( input_prm[i]->type, TO_STR(PTR_DOUBLE9) ) == 0 )
{
free(*(PTR_DOUBLE9*)input_prm[i]->ptr);
}
else if( strcmp( input_prm[i]->type, TO_STR(PTR_INT) ) == 0 )
{
free(*(PTR_INT*)input_prm[i]->ptr);
}
else if( strcmp( input_prm[i]->type, TO_STR(PTR_DOUBLE) ) == 0 )
{
free(*(PTR_DOUBLE*)input_prm[i]->ptr);
}
else if( strcmp( input_prm[i]->type, TO_STR(PTR_STR) ) == 0 )
{
free(*(PTR_STR*)input_prm[i]->ptr);
}
else if( strcmp( input_prm[i]->type, TO_STR(STR) ) == 0 && input_prm[i]->size == -1 )
{
free(*(STR*)input_prm[i]->ptr);
}
}
}
free_rand();
}
示例4: error_proto_to_string
// Error.prototype.toString()
js_val *
error_proto_to_string(js_val *instance, js_args *args, eval_state *state)
{
if (!IS_OBJ(instance))
fh_error(state, E_TYPE, "Error.prototype.toString called on a non-object");
js_val *name_prop = fh_get_proto(instance, "name");
js_val *msg_prop = fh_get_proto(instance, "message");
js_val *name = IS_UNDEF(name_prop) ? JSSTR("Error") : TO_STR(name_prop);
js_val *msg = IS_UNDEF(msg_prop) ? JSSTR("") : TO_STR(msg_prop);
if (strlen(name->string.ptr) == 0) return msg;
if (strlen(msg->string.ptr) == 0) return name;
return JSSTR(fh_str_concat(fh_str_concat(name->string.ptr, ": "), msg->string.ptr));
}
示例5: FillVersion
void FillVersion()
{
#define TO_STR(x) #x
std::string ver_str;
std::string md5_str;
std::stringstream ss;
ss << "svn version " << _SVN_VERSION_ << ", "
<< "compiled by " << TO_STR(_BUILDER_) << ", "
<< __DATE__ << __TIME__;
ss >> ver_str;
time_t now = time();
char str_tm[256];
memset(str_tm, 0, sizeof(str_tm));
ctime_r(&now, &str_tm);
char exe_file[256];
sprintf(exe_file, "/proc/%d/exe", getpid());
uint8_t md5[16];
CalcFileMD5(exe_file, md5);
const char *hex = "0123456789abcdef";
for (int i = 0; i < 16; ++i)
{
md5_str[i*2+0] = hex[ (md5[i]&0xF0)>>4 ];
md5_str[i*2+0] = hex[ (md5[i]&0x0F) ];
}
#undef TO_STR
}
示例6: VALIDATE_NOT_NULL
ECode CameraInfo::ToString(
/* [out] */ String* str)
{
VALIDATE_NOT_NULL(str)
*str = TO_STR(mInfo);
return NOERROR;
}
示例7: usage
static void usage(const char *progname)
{
fprintf(stderr, "SHA performance testing tool for OP-TEE (%s)\n\n",
TO_STR(VERSION));
fprintf(stderr, "Usage:\n");
fprintf(stderr, " %s -h\n", progname);
fprintf(stderr, " %s [-v] [-a algo] ", progname);
fprintf(stderr, "[-s bufsize] [-r] [-n loops] [-l iloops] ");
fprintf(stderr, "[-w warmup_time]\n");
fprintf(stderr, "Options:\n");
fprintf(stderr, " -h Print this help and exit\n");
fprintf(stderr, " -l Inner loop iterations (TA hashes ");
fprintf(stderr, "the buffer <x> times) [%u]\n", l);
fprintf(stderr, " -a Algorithm (SHA1, SHA224, SHA256, SHA384, ");
fprintf(stderr, "SHA512) [%s]\n", algo_str(algo));
fprintf(stderr, " -n Outer loop iterations [%u]\n", n);
fprintf(stderr, " -r Get input data from /dev/urandom ");
fprintf(stderr, "(otherwise use zero-filled buffer)\n");
fprintf(stderr, " -s Buffer size (process <x> bytes at a time) ");
fprintf(stderr, "[%zu]\n", size);
fprintf(stderr, " -u Use unaligned buffer (odd address)\n");
fprintf(stderr, " -v Be verbose (use twice for greater effect)\n");
fprintf(stderr, " -w Warm-up time in seconds: execute a busy ");
fprintf(stderr, "loop before the test\n");
fprintf(stderr, " to mitigate the effects of cpufreq etc. ");
fprintf(stderr, "[%u]\n", warmup);
}
示例8: versaloon_get_target_voltage
RESULT versaloon_get_target_voltage(uint16_t *voltage)
{
uint16_t inlen;
#if PARAM_CHECK
if (NULL == versaloon_buf) {
LOG_BUG(ERRMSG_INVALID_BUFFER, TO_STR(versaloon_buf));
return ERRCODE_INVALID_BUFFER;
}
if (NULL == voltage) {
LOG_BUG(ERRMSG_INVALID_PARAMETER, __func__);
return ERRCODE_INVALID_PARAMETER;
}
#endif
versaloon_buf[0] = VERSALOON_GET_TVCC;
if ((ERROR_OK != versaloon_send_command(1, &inlen)) || (inlen != 2)) {
LOG_ERROR(ERRMSG_FAILURE_OPERATION, "communicate with versaloon");
return ERRCODE_FAILURE_OPERATION;
} else {
*voltage = versaloon_buf[0] + (versaloon_buf[1] << 8);
return ERROR_OK;
}
}
示例9: read_record
int
read_record(FILE *fp, struct log_entry *entry)
{
char buffer[REFERER_MAXLEN];
int ret;
int seconds;
ret = fscanf(fp,
"%d.%d | %d | "
"%" TO_STR(IP_MAXLEN) "s | "
"%" TO_STR(HEAD_ST_MAXLEN) "s | "
"%d | "
"%" TO_STR(METHOD_MAXLEN) "s | "
"%" TO_STR(URI_MAXLEN) "s | "
"%" TO_STR(USERNAME_MAXLEN) "s | "
"%" TO_STR(HSTATUS_MAXLEN) "s | "
"%" TO_STR(MIMETYPE_MAXLEN) "s | "
"%d | ",
&entry->time, &seconds, &entry->elaps,
entry->ipaddr,
entry->head_st,
&entry->len,
entry->method,
entry->uri,
entry->username,
entry->h_status,
entry->mime_type,
&entry->port);
if (get_user_agent(fp, buffer, USERAGENT_MAXLEN, entry->user_agent) == -1 || get_referer(fp, buffer, REFERER_MAXLEN, entry->referer) == -1)
return -1;
if (ret < 2)
return 1;
return 0;
}
示例10: parse_doubles
void parse_doubles( DOUBLE* tab ,INT count )
{
INT i;
STR str_temp;
for( i = 0; i < count; ++i )
{
str_temp = strtok( NULL, " \t" );
if( str_temp == NULL || !check_type( TO_STR(DOUBLE), str_temp ) ) UNERR("Wrong line in sub");
tab[ i ] = (DOUBLE)atof( str_temp );
}
}
示例11: parse_ints
void parse_ints( INT* tab ,INT count )
{
INT i;
STR str_temp;
for( i = 0; i < count; ++i )
{
str_temp = strtok( NULL, " \t" );
if( str_temp == NULL || !check_type( TO_STR(INT), str_temp ) ) UNERR("Wrong line in sub");
tab[ i ] = atoi( str_temp );
}
}
示例12: TO_STR
String DATA_ValueProvider::GetValue(
/* in */ IComponentName* resolvedComponent,
/* in */ IIntent* intent,
/* in */ const String& resolvedType)
{
AutoPtr<IUri> data;
intent->GetData((IUri**)&data);
if (data != NULL) {
return TO_STR(data);
}
return String(NULL);
}
示例13: error_new
// [new] Error(message)
js_val *
error_new(js_val *instance, js_args *args, eval_state *state)
{
js_val *err = JSOBJ();
js_val *msg = ARG(args, 0);
fh_set_class(err, "Error");
if (!IS_UNDEF(msg))
fh_set(err, "message", TO_STR(msg));
err->proto = fh_try_get_proto("Error");
return err;
}
示例14: ir_raw_event_store
/**
* ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
* @dev: the struct rc_dev device descriptor
* @ev: the struct ir_raw_event descriptor of the pulse/space
*
* This routine (which may be called from an interrupt context) stores a
* pulse/space duration for the raw ir decoding state machines. Pulses are
* signalled as positive values and spaces as negative values. A zero value
* will reset the decoding state machines.
*/
int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev)
{
if (!dev->raw)
return -EINVAL;
IR_dprintk(2, "sample: (%05dus %s)\n",
TO_US(ev->duration), TO_STR(ev->pulse));
if (kfifo_in(&dev->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev))
return -ENOMEM;
return 0;
}
示例15: ir_raw_event_store
/**
* ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
* @input_dev: the struct input_dev device descriptor
* @ev: the struct ir_raw_event descriptor of the pulse/space
*
* This routine (which may be called from an interrupt context) stores a
* pulse/space duration for the raw ir decoding state machines. Pulses are
* signalled as positive values and spaces as negative values. A zero value
* will reset the decoding state machines.
*/
int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev)
{
struct ir_input_dev *ir = input_get_drvdata(input_dev);
if (!ir->raw)
return -EINVAL;
IR_dprintk(2, "sample: (05%dus %s)\n",
TO_US(ev->duration), TO_STR(ev->pulse));
if (kfifo_in(&ir->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev))
return -ENOMEM;
return 0;
}