本文整理汇总了C++中ejsCreateStringFromAsc函数的典型用法代码示例。如果您正苦于以下问题:C++ ejsCreateStringFromAsc函数的具体用法?C++ ejsCreateStringFromAsc怎么用?C++ ejsCreateStringFromAsc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ejsCreateStringFromAsc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: components
/*
Break a uri into components
function components(): Object
*/
static EjsObj *uri_components(Ejs *ejs, EjsUri *up, int argc, EjsObj **argv)
{
EjsObj *obj;
HttpUri *uri;
uri = up->uri;
obj = ejsCreateEmptyPot(ejs);
if (uri->scheme) {
ejsSetPropertyByName(ejs, obj, EN("scheme"), ejsCreateStringFromAsc(ejs, uri->scheme));
}
if (uri->host) {
ejsSetPropertyByName(ejs, obj, EN("host"), ejsCreateStringFromAsc(ejs, uri->host));
}
if (uri->port > 0) {
ejsSetPropertyByName(ejs, obj, EN("port"), ejsCreateNumber(ejs, uri->port));
}
if (uri->path) {
ejsSetPropertyByName(ejs, obj, EN("path"), ejsCreateStringFromAsc(ejs, uri->path));
}
if (uri->reference) {
ejsSetPropertyByName(ejs, obj, EN("reference"), ejsCreateStringFromAsc(ejs, uri->reference));
}
if (uri->query) {
ejsSetPropertyByName(ejs, obj, EN("query"), ejsCreateStringFromAsc(ejs, uri->query));
}
return obj;
}
示例2: assert
static EjsAny *createException(Ejs *ejs, EjsType *type, cchar* fmt, va_list fmtArgs)
{
EjsError *error;
EjsAny *argv[1];
char *msg;
assert(type);
#if ME_DEBUG
/* Breakpoint opportunity */
if (!ejs->empty) {
mprNop(0);
}
#endif
msg = sfmtv(fmt, fmtArgs);
argv[0] = ejsCreateStringFromAsc(ejs, msg);
if (argv[0] == 0) {
assert(argv[0]);
return 0;
}
if (EST(Error)->constructor.body.proc) {
error = (EjsError*) ejsCreateInstance(ejs, type, 1, argv);
} else {
error = ejsCreatePot(ejs, type, 0);
ejsSetProperty(ejs, error, ES_Error_message, ejsCreateStringFromAsc(ejs, msg));
}
return error;
}
示例3: statusMessage
/*
function get statusMessage(): String
*/
static EjsString *http_statusMessage(Ejs *ejs, EjsHttp *hp, int argc, EjsObj **argv)
{
HttpConn *conn;
if (!waitForResponseHeaders(hp)) {
return 0;
}
conn = hp->conn;
if (conn->errorMsg) {
return ejsCreateStringFromAsc(ejs, conn->errorMsg);
}
return ejsCreateStringFromAsc(ejs, httpGetStatusMessage(hp->conn));
}
示例4: switch
static EjsAny *coerceUriOperands(Ejs *ejs, EjsUri *lhs, int opcode, EjsAny *rhs)
{
HttpUri *uri;
char *ustr;
switch (opcode) {
/*
Binary operators
*/
case EJS_OP_ADD:
uri = lhs->uri;
ustr = httpFormatUri(uri->scheme, uri->host, uri->port, uri->path, uri->reference, uri->query, 0);
return ejsInvokeOperator(ejs, ejsCreateStringFromAsc(ejs, ustr), opcode, rhs);
case EJS_OP_COMPARE_EQ: case EJS_OP_COMPARE_NE:
case EJS_OP_COMPARE_LE: case EJS_OP_COMPARE_LT:
case EJS_OP_COMPARE_GE: case EJS_OP_COMPARE_GT:
if (!ejsIsDefined(ejs, rhs)) {
return ((opcode == EJS_OP_COMPARE_EQ) ? ESV(false): ESV(true));
}
uri = lhs->uri;
ustr = httpFormatUri(uri->scheme, uri->host, uri->port, uri->path, uri->reference, uri->query, 0);
return ejsInvokeOperator(ejs, ejsCreateStringFromAsc(ejs, ustr), opcode, rhs);
case EJS_OP_COMPARE_STRICTLY_NE:
return ESV(true);
case EJS_OP_COMPARE_STRICTLY_EQ:
return ESV(false);
case EJS_OP_COMPARE_NOT_ZERO:
case EJS_OP_COMPARE_TRUE:
return ESV(true);
case EJS_OP_COMPARE_ZERO:
case EJS_OP_COMPARE_FALSE:
return ESV(false);
case EJS_OP_COMPARE_UNDEFINED:
case EJS_OP_COMPARE_NULL:
return ESV(false);
default:
ejsThrowTypeError(ejs, "Opcode %d not valid for type %@", opcode, TYPE(lhs)->qname.name);
return ESV(undefined);
}
return 0;
}
示例5: toString
/*
Convert the array to a single string each member of the array has toString called on it and the resulting strings
are concatenated.
override function toString(): String
*/
static EjsString *arrayToString(Ejs *ejs, EjsArray *ap, int argc, EjsObj **argv)
{
EjsString *result, *comma;
EjsObj *vp;
int i, rc;
result = ESV(empty);
if (result == 0) {
ejsThrowMemoryError(ejs);
return 0;
}
comma = ejsCreateStringFromAsc(ejs, ",");
for (i = 0; i < ap->length; i++) {
vp = ap->data[i];
rc = 0;
if (i > 0) {
result = ejsJoinString(ejs, result, comma);
}
if (ejsIsDefined(ejs, vp)) {
result = ejsJoinString(ejs, result, ejsToString(ejs, vp));
}
if (rc < 0) {
ejsThrowMemoryError(ejs);
return 0;
}
}
return result;
}
示例6: escapeHtml
/*
HTML escape a string
function escapeHtml(str: String): String
*/
static EjsObj *web_escapeHtml(Ejs *ejs, EjsObj *unused, int argc, EjsObj **argv)
{
EjsString *str;
str = (EjsString*) argv[0];
return (EjsObj*) ejsCreateStringFromAsc(ejs, mprEscapeHtml(str->value));
}
示例7: toLocalString
/*
function toLocalString(): String
*/
static EjsString *uri_toLocalString(Ejs *ejs, EjsUri *up, int argc, EjsObj **argv)
{
HttpUri *uri;
uri = up->uri;
return ejsCreateStringFromAsc(ejs, httpFormatUri(NULL, NULL, 0, uri->path, uri->reference, uri->query, 0));
}
示例8: toString
/*
function toString(): String
*/
static EjsString *uri_toString(Ejs *ejs, EjsUri *up, int argc, EjsObj **argv)
{
HttpUri *uri;
uri = up->uri;
return ejsCreateStringFromAsc(ejs, httpUriToString(uri, 0));
}
示例9: query
/*
Get the query portion
static function get query(): String?
*/
static EjsString *uri_query(Ejs *ejs, EjsUri *up, int argc, EjsObj **argv)
{
if (up->uri->query == 0) {
return ESV(null);
}
return ejsCreateStringFromAsc(ejs, up->uri->query);
}
示例10: key
/*
function get key(): String
*/
static EjsAny *http_key(Ejs *ejs, EjsHttp *hp, int argc, EjsObj **argv)
{
if (hp->keyFile) {
return ejsCreateStringFromAsc(ejs, hp->keyFile);
}
return ESV(null);
}
示例11: mimeType
/*
Get the mimeType
function mimeType(): String?
*/
static EjsString *uri_mimeType(Ejs *ejs, EjsUri *up, int argc, EjsObj **argv)
{
if (up->uri->ext == 0) {
return ESV(null);
}
return ejsCreateStringFromAsc(ejs, mprLookupMime(NULL, up->uri->ext));
}
示例12: extension
/*
Get the Uri extension
static function get extension(): String?
*/
static EjsString *uri_extension(Ejs *ejs, EjsUri *up, int argc, EjsObj **argv)
{
if (up->uri->ext == 0) {
return ESV(null);
}
return ejsCreateStringFromAsc(ejs, up->uri->ext);
}
示例13: component
/*
Encode a Uri component (ECMA Standard)
static function encodeComponent(str: String): String
*/
static EjsObj *encodeURIComponent(Ejs *ejs, EjsObj *unused, int argc, EjsObj **argv)
{
char *encoded;
encoded = mprUriEncode(ejsToMulti(ejs, argv[0]), MPR_ENCODE_JS_URI_COMPONENT);
return (EjsObj*) ejsCreateStringFromAsc(ejs, encoded);
}
示例14: ejsCreateArrayType
PUBLIC void ejsCreateArrayType(Ejs *ejs)
{
EjsType *type;
EjsHelpers *helpers;
type = ejsCreateCoreType(ejs, N("ejs", "Array"), sizeof(EjsArray), S_Array, ES_Array_NUM_CLASS_PROP, manageArray,
EJS_TYPE_POT | EJS_TYPE_NUMERIC_INDICIES | EJS_TYPE_VIRTUAL_SLOTS | EJS_TYPE_MUTABLE_INSTANCES |
EJS_TYPE_DYNAMIC_INSTANCES);
helpers = &type->helpers;
helpers->cast = (EjsCastHelper) castArray;
helpers->clone = (EjsCloneHelper) ejsCloneArray;
helpers->create = (EjsCreateHelper) createArray;
helpers->getProperty = (EjsGetPropertyHelper) getArrayProperty;
helpers->getPropertyCount = (EjsGetPropertyCountHelper) getArrayPropertyCount;
helpers->getPropertyByName = (EjsGetPropertyByNameHelper) getArrayPropertyByName;
helpers->deleteProperty = (EjsDeletePropertyHelper) deleteArrayProperty;
helpers->deletePropertyByName = (EjsDeletePropertyByNameHelper) deleteArrayPropertyByName;
helpers->invokeOperator = (EjsInvokeOperatorHelper) invokeArrayOperator;
helpers->lookupProperty = (EjsLookupPropertyHelper) lookupArrayProperty;
helpers->setProperty = (EjsSetPropertyHelper) setArrayProperty;
helpers->setPropertyByName = (EjsSetPropertyByNameHelper) setArrayPropertyByName;
ejsAddImmutable(ejs, S_length, EN("length"), ejsCreateStringFromAsc(ejs, "length"));
}
示例15: name
/*
function get name(): String
*/
static EjsString *hs_name(Ejs *ejs, EjsHttpServer *sp, int argc, EjsObj **argv)
{
if (sp->name) {
return ejsCreateStringFromAsc(ejs, sp->name);
}
return ESV(null);
}