本文整理汇总了C++中CSTRING函数的典型用法代码示例。如果您正苦于以下问题:C++ CSTRING函数的具体用法?C++ CSTRING怎么用?C++ CSTRING使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CSTRING函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IO_METHOD
IO_METHOD(IoObject, shellExecute)
{
LPCTSTR operation;
LPCTSTR file;
LPCTSTR parameters;
LPCTSTR directory;
int displayFlag;
int result;
operation = CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 0));
file = CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 1));
parameters = IoMessage_argCount(m) > 2 ? CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 2)) : NULL;
directory = IoMessage_argCount(m) > 3 ? CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 3)) : NULL;
displayFlag = IoMessage_argCount(m) > 4 ? IoMessage_locals_intArgAt_(m, locals, 4) : SW_SHOWNORMAL;
result = (int)ShellExecute(NULL, operation, file, parameters, directory, displayFlag);
if(result > 32)
{
return self;
}
else
{
return (IoObject *)IoError_newWithMessageFormat_(IOSTATE, "ShellExecute Error %i", result);
}
}
示例2: IoSQLite3_justOpen
IoObject *IoSQLite3_execWithCallback(IoSQLite3 *self,
IoObject *locals, IoMessage *m, IoSymbol *s, ResultRowCallback *callback)
{
IoList *results;
if (!DATA(self)->db)
{
IoSQLite3_justOpen(self);
if (!DATA(self)->db)
{
return IONIL(self);
}
}
DATA(self)->results = IOREF(IoList_new(IOSTATE));
if (DATA(self)->debugOn)
{
IoState_print_(IOSTATE, "*** %s ***\n", CSTRING(s));
}
{
char *zErrMsg;
sqlite3_exec(DATA(self)->db, CSTRING(s), callback, self, &zErrMsg);
IoSQLite3_showError(self);
}
results = DATA(self)->results;
DATA(self)->results = NULL;
return results;
}
示例3: add_external_ml_value
static mlval add_external_ml_value(mlval arg)
{ char *str, *name;
mlval item = MLUNIT;
mlval current = external_ml_values;
name = CSTRING(FIELD(arg,0));
declare_root(&item, 0);
declare_root(¤t, 0);
for(;;){
if (MLISNIL(current)) break;
item = MLHEAD(current);
str = CSTRING(FIELD(item,0));
if (strcmp(name,str) == 0)
{ FIELD(item,1) = FIELD(arg,1); /* Updates existing record */
break;
};
item = MLUNIT;
current = MLTAIL(current);
};
if (item == MLUNIT)
{ external_ml_values = cons(arg,external_ml_values); };
retract_root(&item);
retract_root(¤t);
return(MLUNIT);
}
示例4: IoMessage_locals_valueArgAt_
IoObject *IoDBI_with(IoDBI *self, IoObject *locals, IoMessage *m)
{
//doc DBI with(driverName) Get a new connection with the given driver.
IoObject *name = IoMessage_locals_valueArgAt_(m, locals, 0);
if (!ISSYMBOL(name))
{
IoState_error_(IOSTATE, m, "argument 0 to method '%s' must be a Symbol, not a '%s'\n",
CSTRING(IoMessage_name(m)), IoObject_name(name));
return IONIL(self);
}
if (DATA(self)->didInit != 1)
{
IoDBI_init(self, locals, m);
}
dbi_conn c = dbi_conn_new(CSTRING(name));
if (c == NULL)
{
IoState_error_(IOSTATE, m, "libdbi error during dbi_conn_new\n");
return IONIL(self);
}
return IoDBIConn_new(IOSTATE, c);
}
示例5: DynLib_pointerForSymbolName_
IoDynLib *IoDynLib_callPluginInitFunc(IoDynLib *self, IoObject *locals, IoMessage *m)
{
/*doc DynLib callPluginInit(functionName)
Call's the dll function of the specified name.
Returns the result as a Number or raises an exception on error.
*/
intptr_t rc = 0;
intptr_t *params = NULL;
void *f = DynLib_pointerForSymbolName_(DATA(self),
CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 0)));
if (f == NULL)
{
IoState_error_(IOSTATE, m, "Error resolving call '%s'.",
CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 0)));
return IONIL(self);
}
if (IoMessage_argCount(m) < 1)
{
IoState_error_(IOSTATE, m, "Error, you must give an init function name to check for.");
return IONIL(self);
}
params = io_calloc(1, sizeof(intptr_t) * 2);
params[0] = (intptr_t)IOSTATE;
params[1] = (intptr_t)IOSTATE->lobby;
rc = ((intptr_t (*)(intptr_t, intptr_t))f)(params[0], params[1]);
io_free(params);
return IONUMBER(rc);
}
示例6: IoState_print_
IoObject *IoSQLite_open(IoSQLite *self, IoObject *locals, IoMessage *m)
{
/*doc SQLite open(optionalPathString)
Opens the database.Returns self on success or nil upon failure.
If the databse is locked, "yield" will be called until it is
accessable or timeoutSeconds has expired.
*/
char *zErrMsg;
if (DATA(self)->debugOn)
{
IoState_print_(IOSTATE, "IoSQLite opening '%s'\n", CSTRING(DATA(self)->path));
}
DATA(self)->db = sqlite_open(CSTRING(DATA(self)->path), 0, &zErrMsg);
if (!DATA(self)->db)
{
IoSQLite_error_(self, zErrMsg);
}
else
{
IoSQLite_error_(self, "");
}
sqlite_busy_handler(DATA(self)->db, IoSQLite_busyHandler, self);
sqlite_busy_timeout(DATA(self)->db, DATA(self)->timeoutSeconds*1000);
return self;
}
示例7: rb_digest
VALUE rb_digest(int argc, VALUE *argv, VALUE self) {
VALUE string, options, method = Qnil;
rb_scan_args(argc, argv, "11", &string, &options);
if (TYPE(options) == T_HASH)
method = rb_hash_aref(options, sMethod);
int algo = NIL_P(method) ? 0 : FIX2INT(method);
return SIZET2NUM(algo == 1 ? djhash(CSTRING(string)) : sdbm(CSTRING(string)));
}
示例8: IO_METHOD
IO_METHOD(IoDate, asString)
{
/*doc Date asString(optionalFormatString)
Returns a string representation of the receiver using the
receivers format. If the optionalFormatString argument is present, the
receiver's format is set to it first. Formatting is according to ANSI C
date formatting rules.
<p>
<pre>
%a abbreviated weekday name (Sun, Mon, etc.)
%A full weekday name (Sunday, Monday, etc.)
%b abbreviated month name (Jan, Feb, etc.)
%B full month name (January, February, etc.)
%c full date and time string
%d day of the month as two-digit decimal integer (01-31)
%H hour as two-digit 24-hour clock decimal integer (00-23)
%I hour as two-digit 12-hour clock decimal integer (01-12)
%m month as a two-digit decimal integer (01-12)
%M minute as a two-digit decimal integer (00-59)
%p either "AM" or "PM"
%S second as a two-digit decimal integer (00-59)
%U number of week in the year as two-digit decimal integer (00-52)
with Sunday considered as first day of the week
%w weekday as one-digit decimal integer (0-6) with Sunday as 0
%W number of week in the year as two-digit decimal integer (00-52)
with Monday considered as first day of the week
%x full date string (no time); in the C locale, this is equivalent
to "%m/%d/%y".
%y year without century as two-digit decimal number (00-99)
%Y year with century as four-digit decimal number
%Z time zone name (e.g. EST);
null string if no time zone can be obtained
%% stands for '%' character in output string.
</pre>
*/
char *format = "%Y-%m-%d %H:%M:%S %Z";
if (IoMessage_argCount(m) == 1)
{
format = CSTRING(IoMessage_locals_symbolArgAt_(m, locals, 0));
}
else
{
IoObject *f = IoObject_getSlot_(self, IOSYMBOL("format"));
if (ISSEQ(f)) { format = CSTRING(f); }
}
{
UArray *ba = Date_asString(DATA(self), format);
return IoState_symbolWithUArray_copy_(IOSTATE, ba, 0);
}
}
示例9: db_postgres_adapter_initialize
VALUE db_postgres_adapter_initialize(VALUE self, VALUE options) {
char *connection_info;
VALUE db, user, pass, host, port, ssl;
Adapter *a = db_postgres_adapter_handle(self);
if (TYPE(options) != T_HASH)
rb_raise(eSwiftArgumentError, "options needs to be a hash");
db = rb_hash_aref(options, ID2SYM(rb_intern("db")));
user = rb_hash_aref(options, ID2SYM(rb_intern("user")));
pass = rb_hash_aref(options, ID2SYM(rb_intern("password")));
host = rb_hash_aref(options, ID2SYM(rb_intern("host")));
port = rb_hash_aref(options, ID2SYM(rb_intern("port")));
ssl = rb_hash_aref(options, ID2SYM(rb_intern("ssl")));
if (NIL_P(db))
rb_raise(eSwiftConnectionError, "Invalid db name");
if (NIL_P(host))
host = rb_str_new2("127.0.0.1");
if (NIL_P(port))
port = rb_str_new2("5432");
if (NIL_P(user))
user = sUser;
if (!NIL_P(ssl) && TYPE(ssl) != T_HASH)
rb_raise(eSwiftArgumentError, "ssl options needs to be a hash");
connection_info = (char *)malloc(4096);
snprintf(connection_info, 4096, "dbname='%s' user='%s' password='%s' host='%s' port='%s'",
CSTRING(db), CSTRING(user), CSTRING(pass), CSTRING(host), CSTRING(port));
if (!NIL_P(ssl)) {
append_ssl_option(connection_info, 4096, ssl, "sslmode", "allow");
append_ssl_option(connection_info, 4096, ssl, "sslcert", 0);
append_ssl_option(connection_info, 4096, ssl, "sslkey", 0);
append_ssl_option(connection_info, 4096, ssl, "sslrootcert", 0);
append_ssl_option(connection_info, 4096, ssl, "sslcrl", 0);
}
a->connection = PQconnectdb(connection_info);
free(connection_info);
if (!a->connection)
rb_raise(eSwiftRuntimeError, "unable to allocate database handle");
if (PQstatus(a->connection) == CONNECTION_BAD)
rb_raise(eSwiftConnectionError, PQerrorMessage(a->connection));
PQsetNoticeProcessor(a->connection, (PQnoticeProcessor)db_postgres_adapter_notice, (void*)self);
PQsetClientEncoding(a->connection, "utf8");
return self;
}
示例10: IoMessage_locals_valueArgAt_
IoObject *IoCFFIPointer_castTo(IoCFFIPointer *self, IoObject *locals, IoMessage *m)
{
IoObject *toType = IoMessage_locals_valueArgAt_(m, locals, 0);
IoObject *o = IoState_on_doCString_withLabel_(IOSTATE, toType, "?typeString", "IoCFFIPointer_castTo");
if(!ISNIL(o)) {
char *typeStr = CSTRING(o);
switch(typeStr[0]) {
case '^':
toType = IOCLONE(toType);
*(DATA(toType)->valuePointer) = *((void **)IoCFFIDataType_ValuePointerFromObject_(toType, self));
return toType;
case '*':
toType = IOCLONE(toType);
IoCFFIDataType_rawSetValue(toType, self);
return toType;
default:
IoState_error_(IOSTATE, m, "Wrong type to cast to.");
break;
}
}
else {
// Mm... well, if the type to cast to does not have a typeString slot,
// it should be an Io Object, so the address stored here is a pointer to an
// Io Object. Simply cast the pointer and return it... dangerous but...
IoObject *obj = (IoObject *)*(DATA(self)->valuePointer);
if(ISOBJECT(obj))
return (IoObject *)*(DATA(self)->valuePointer);
}
return IONIL(self);
}
示例11: IO_METHOD
IO_METHOD(IoSeq, replaceMap)
{
/*doc Sequence replaceMap(aMap)
In the receiver, the keys of aMap replaced with its values. Returns self.
*/
IoMap *map = IoMessage_locals_mapArgAt_(m, locals, 0);
UArray *ba = DATA(self);
IO_ASSERT_NOT_SYMBOL(self);
PHASH_FOREACH(IoMap_rawHash(map), k, v,
{
IoSymbol *subSeq = k;
IoSymbol *otherSeq = v;
if (ISSEQ(otherSeq))
{
UArray_replace_with_(ba, DATA(subSeq), DATA(otherSeq));
}
else
{
IoState_error_(IOSTATE, m,
"argument 0 to method '%s' must be a Map with Sequence values, not '%s'",
CSTRING(IoMessage_name(m)), IoObject_name(otherSeq));
}
}
);
示例12: IoCoroutine_rawPrintBackTrace
void IoCoroutine_rawPrintBackTrace(IoCoroutine *self)
{
IoObject *e = IoCoroutine_rawException(self);
IoMessage *caughtMessage = IoObject_rawGetSlot_(e, IOSYMBOL("caughtMessage"));
if (IoObject_rawGetSlot_(e, IOSYMBOL("showStack"))) // sanity check
{
IoState_on_doCString_withLabel_(IOSTATE, e, "showStack", "[Coroutine]");
}
else
{
IoSymbol *error = IoObject_rawGetSlot_(e, IOSYMBOL("error"));
if (error)
{
fputs(CSTRING(error), stderr);
fputs("\n", stderr);
}
else
{
fputs("error: [missing error slot in Exception object]\n", stderr);
}
if (caughtMessage)
{
UArray *ba = IoMessage_asMinimalStackEntryDescription(caughtMessage);
fputs(UArray_asCString(ba), stderr);
fputs("\n", stderr);
UArray_free(ba);
}
}
}
示例13: IoMessage_assertArgCount_
IoValue *IoObject_catchException(IoObject *self, IoObject *locals, IoMessage *m)
{
IoValue *result;
IoMessage_assertArgCount_(m, 3);
{
IoString *exceptionName = (IoString *)IoMessage_locals_stringArgAt_(m, locals, 0);
IoExceptionCatch *eCatch = IoState_pushExceptionCatchWithName_((IoState*)self->tag->state,
CSTRING(exceptionName));
TInt r = 0;
TRAP(r, result = (IoValue*)IoMessage_locals_valueArgAt_(m, locals, 1);
IoState_popExceptionCatch_((IoState*)self->tag->state, eCatch););
if(r != 0)
{
IoObject_setSlot_to_((IoObject*)locals, USTRING("exceptionName"), eCatch->caughtName);
if (eCatch->caughtDescription)
{
IoObject_setSlot_to_(locals, USTRING("exceptionDescription"),
eCatch->caughtDescription);
}
else
{
IoObject_setSlot_to_(locals, USTRING("exceptionDescription"),
USTRING("<no description>"));
}
IoState_popExceptionCatch_((IoState*)self->tag->state, eCatch);
result = (IoValue*)IoMessage_locals_valueArgAt_(m, locals, 2);
}
}
示例14: DATA
Uint64Array *IoTagDB_tagArrayForTagNames_(IoTagDB *self, IoMessage *m, IoList *tagNames)
{
TagDB *tdb = DATA(self);
Uint64Array *tags = Uint64Array_new();
int i;
for (i = 0; i < IoList_rawSize(tagNames); i ++)
{
IoSeq *tagName = IoList_rawAt_(tagNames, i);
symbolid_t keyid;
IOASSERT(ISSEQ(tagName), "tag names must be Sequences");
keyid = TagDB_idForSymbol_size_(tdb, CSTRING(tagName), IoSeq_rawSize(tagName));
Uint64Array_append_(tags, keyid);
/*
{
Datum *keyDatum = TagDB_symbolForId_(tdb, keyid);
printf("%s -> %i && ", CSTRING(tagName), (int)keyid);
printf("%i -> %s\n", (int)keyid, (char *)(keyDatum->data));
Datum_free(keyDatum);
}
*/
}
return tags;
}
示例15: IO_METHOD
IO_METHOD(IoSandbox, doSandboxString)
{
/*doc Sandbox doSandboxString(aString)
Evaluate aString inside the Sandbox.
*/
IoState *boxState = IoSandbox_boxState(self);
char *s = IoMessage_locals_cStringArgAt_(m, locals, 0);
IoObject *result = IoState_doSandboxCString_(boxState, s);
if (ISSYMBOL(result))
{
return IOSYMBOL(CSTRING(result));
}
if (ISSEQ(result))
{
return IOSEQ(IOSEQ_BYTES(result), IOSEQ_LENGTH(result));
}
if (ISNUMBER(result))
{
return IONUMBER(CNUMBER(result));
}
return IONIL(self);
}