static Variant HHVM_METHOD(NumberFormatter, format, const Variant& value, int64_t type) { NUMFMT_GET(obj, this_, false); Variant num(value); // De-const int64_t ival = 0; double dval = 0.0; DataType dt = num.toNumeric(ival, dval, true); if (dt == KindOfInt64) { num = ival; } else if (dt == KindOfDouble) { num = dval; } else { num = value.toInt64(); } if (type == UNUM(TYPE_DEFAULT)) { if (value.isInteger()) { type = UNUM(TYPE_INT64); } else if (value.isDouble()) { type = UNUM(TYPE_DOUBLE); } } if (type == UNUM(TYPE_DOUBLE)) { return doFormat(obj, num.toDouble()); } else { return doFormat(obj, num.toInt64()); } }
static void tiff_warn(const char*, const char* fmt, va_list ap) { // values are (const char* module, const char* fmt, va_list list) /* FIXME: notify? */ OSG_NOTICE << "TIFF rader: " << doFormat(fmt, ap) << std::endl; }
static void tiff_error(const char*, const char* fmt, va_list ap) { // values are (const char* module, const char* fmt, va_list list) /* FIXME: store error message ? */ OSG_WARN << "TIFF rader: " << doFormat(fmt, ap) << std::endl; }
list<string>::size_type AbstractDevice::format( const Buffer& buffer, list<string>& lines ) { lines.clear(); doFormat( buffer, lines ); return lines.size(); }
QString RealFormat::format(const Variant& val) { if (usesBase()) { RealFormat* formatter = new RealFormat; formatter->cloneFrom(this); QString result = formatter->format(val); delete formatter; return result; } return doFormat(val); }
static Variant HHVM_METHOD(NumberFormatter, format, const Variant& value, int64_t type) { NUMFMT_GET(obj, this_, false); Variant num(value); // De-const if (!num.isDouble() && !num.isInteger()) { int64_t ival = 0; double dval = 0.0; DataType dt = num.toNumeric(ival, dval, true); if (dt == KindOfInt64) { num = ival; } else if (dt == KindOfDouble) { num = dval; } else { obj->setError(U_ILLEGAL_ARGUMENT_ERROR); return false; } } if (type == UNUM(TYPE_DEFAULT)) { if (value.isInteger()) { type = UNUM(TYPE_INT64); } else if (value.isDouble()) { type = UNUM(TYPE_DOUBLE); } } if ((type == UNUM(TYPE_INT32)) || (type == UNUM(TYPE_INT64))) { return doFormat(obj, num.toInt64()); } else if (type == UNUM(TYPE_DOUBLE)) { return doFormat(obj, num.toDouble()); } else { raise_warning("Unsupported format type %ld", (long)type); return false; } }
// // ::virtual_makeObjects // virtual void virtual_makeObjects(ObjectVector *objects, VariableData *dst) { Super::recurse_makeObjects(objects, dst); VariableType::Reference type = getType(); VariableData::Pointer src = VariableData::create_stack(type->getSize(pos)); std::string string; make_objects_memcpy_prep(objects, dst, src, pos); init(); // Start the print. objects->addToken(OCODE_ACSP_START); for(char const *c = format.c_str(); *c;) { // If not a % (or if it's a %%), just add to output. if(*c != '%' || *++c == '%') { string += *c++; continue; } FormatData data; // Otherwise, handle the current literal and start reading format. doFormatLiteral(objects, string); // Read flags, if any. for(data.flags = 0; *c; ++c) { switch(*c) { case '-': data.flags |= FF_LEFT; continue; case '+': data.flags |= FF_SIGN; continue; case ' ': data.flags |= FF_PADS; continue; case '#': data.flags |= FF_ALTF; continue; case '0': data.flags |= FF_PAD0; continue; } break; } // Read field width, if any. if(*c == '*') data.width = -1, ++c; else for(data.width = 0; std::isdigit(*c);) data.width = (data.width * 10) + (*c++ - '0'); // Read precision, if any. if(*c == '.') { if(*++c == '*') data.prec = -1, ++c; else for(data.prec = 0; std::isdigit(*c);) data.prec = (data.prec * 10) + (*c++ - '0'); } else data.prec = 0; // Read length modifier, if any. switch(*c) { case 'h': data.len = *++c == 'h' ? ++c, FL_HH : FL_H; break; case 'l': data.len = *++c == 'l' ? ++c, FL_LL : FL_L; break; case 'j': ++c; data.len = FL_MAX; break; case 'z': ++c; data.len = FL_SIZE; break; case 't': ++c; data.len = FL_DIFF; break; case 'L': ++c; data.len = FL_L; break; default: data.len = FL_NONE; break; } // Read conversion specifier. data.fmt = *c++; doFormat(objects, data); } doFormatLiteral(objects, string); // Print options. switch (printfType) { case PT_BOLD: case PT_ERROR: case PT_LOG: case PT_PRINT: case PT_STRING: break; case PT_HUD: case PT_HUD_BOLD: { objects->addToken(OCODE_ACSP_START_OPT); ObjectExpression::Pointer msgtypeObj = nextExpr(VariableType::get_bt_int())->makeObject(); bigsint msgtype = msgtypeObj->resolveINT(); objects->addToken(OCODE_GET_IMM, msgtypeObj); // type makeExpr(objects, VariableType::get_bt_int()); // id if(msgtype & 0x40000000) // HUDMSG_COLORSTRING makeExpr(objects, VariableType::get_bt_str()); // color (str) else makeExpr(objects, VariableType::get_bt_int()); // color (int) makeExpr(objects, VariableType::get_bt_fix()); // x makeExpr(objects, VariableType::get_bt_fix()); // y makeExpr(objects, VariableType::get_bt_fix()); // holdTime objects->addToken(OCODE_ACSP_END_OPT); switch(static_cast<int>(msgtype & 0xFFF)) { case 0: // PLAIN break; case 1: // FADEOUT makeExpr(objects, VariableType::get_bt_fix()); // fadeTime break; case 2: // TYPEON makeExpr(objects, VariableType::get_bt_fix()); // typeTime makeExpr(objects, VariableType::get_bt_fix()); // fadeTime break; case 3: // FADEINOUT makeExpr(objects, VariableType::get_bt_fix()); // inTime makeExpr(objects, VariableType::get_bt_fix()); // outTime break; default: Error_NP("unrecognized hud msgtype"); } if(*expr) makeExpr(objects, VariableType::get_bt_fix()); // alpha } break; } // End the print. switch (printfType) { case PT_BOLD: objects->addToken(OCODE_ACSP_END_BOLD); break; case PT_ERROR: objects->addToken(OCODE_ACSP_END_ERROR); break; case PT_HUD: objects->addToken(OCODE_ACSP_END_HUD); break; case PT_HUD_BOLD: objects->addToken(OCODE_ACSP_END_HUD_BOLD); break; case PT_LOG: objects->addToken(OCODE_ACSP_END_LOG); break; case PT_PRINT: objects->addToken(OCODE_ACSP_END); break; case PT_STRING: objects->addToken(OCODE_ACSP_END_STR); break; } // If there are any remaining expressions, evaluate them for side effects. if(*expr) { int i = 0; for(; *expr; ++i) makeExpr(objects, VariableType::get_bt_void()); // And then whine at the user. Warn_NP("%i unused arguments", i); } make_objects_memcpy_post(objects, dst, src, type, context, pos); }
/*this is the main routine*/ void doshell() { char line[80]; /*run forever - the shell shouldn't end*/ while(1==1) { /*read in a line*/ printstring("SHELL>\0"); readstring(line); /*match it against each possible command*/ /*if the user presses return, ignore it*/ if (line[0]==0xd) continue; else if (iscommand(line,"CLS\0")==1) doclear(); else if (iscommand(line,"cls\0")==1) doclear(); else if (iscommand(line,"COPY\0")==1) docopy(); else if (iscommand(line,"copy\0")==1) docopy(); else if (iscommand(line,"CREATE \0")==1) docreate(line); else if (iscommand(line,"create \0")==1) docreate(line); else if (iscommand(line,"DELETE \0")==1) dodelete(line); else if (iscommand(line,"delete \0")==1) dodelete(line); else if (iscommand(line,"DIR\0")==1) dodir(); else if (iscommand(line,"dir\0")==1) dodir(); else if (iscommand(line,"EXEC \0")==1) doexecute(line,1); else if (iscommand(line,"exec \0")==1) doexecute(line,1); else if (iscommand(line,"EXECBACK \0")==1) doexecute(line,0); else if (iscommand(line,"execback \0")==1) doexecute(line,0); else if (iscommand(line,"HELP\0")==1) dohelp(); else if (iscommand(line,"help\0")==1) dohelp(); else if (line[0]=='?') dohelp(); else if (iscommand(line,"TYPE \0")==1) dotype(line); else if (iscommand(line,"type \0")==1) dotype(line); else if (iscommand(line,"KILL \0")==1) dokill(line); else if (iscommand(line,"kill \0")==1) dokill(line); else if (iscommand(line,"mkdir \0")==1) domkdir(line); else if (iscommand(line,"MKDIR\0")==1) domkdir(line); else if (iscommand(line,"FORMAT\0")==1) doFormat(); else if (iscommand(line,"format\0")==1) doFormat(); else if (iscommand(line,"remove\0")==1) doRemove(line); else if (iscommand(line,"REMOVE\0")==1) doRemove(line); else if (iscommand(line,"list\0")==1) doList(); else if (iscommand(line,"LIST\0")==1) doList(); else if (iscommand(line,"count\0")==1) doCount(line); else if (iscommand(line,"WRITE\0")==1) doCreateFile(line); else if (iscommand(line,"write\0")==1) doCreateFile(line); else if (iscommand(line,"READ\0")==1) doEcho(line); else if (iscommand(line,"read\0")==1) doEcho(line); else printstring("Command not found\r\n\0"); printstring("\r\n\0"); } }
bool ListHelper::doit(FILE * fp) { StringBuffer s; // Add the header if(format && format->displayNamesHeader()) { for(unsigned i = 0; i < NUMCOLUMNS; i++) { if(i) s.append(format->getValueSeparator()); s.append(format->getDataDelimiter()) .append(columns[i].get()) .append(format->getDataDelimiter()); } s.append(format->getRecordSeparator()); } // If a WUID was specified go for it, otherwise go for the owner if(globals->hasProp("WUID")) { Owned<IClientWUInfoRequest> req = wuclient->createWUInfoRequest(); req->setWuid(globals->queryProp("WUID")); Owned<IClientWUInfoResponse> resp = wuclient->WUInfo(req); if(!resp) return false; const IMultiException* excep = &resp->getExceptions(); if(excep != NULL && excep->ordinality() > 0) { StringBuffer msg; excep->errorMessage(msg); printf("%s\n", msg.str()); return false; } IConstECLWorkunit* wu = &resp->getWorkunit(); if(wu) { doFormat(s, wu); // Print the results if (fp != NULL) { fprintf(fp, "%s", s.str()); } } else return false; } else { Owned<IClientWUQueryRequest> req = wuclient->createWUQueryRequest(); req->setOwner(globals->queryProp("OWNER")); Owned<IClientWUQueryResponse> resp = wuclient->WUQuery(req); if(!resp) return false; const IMultiException* excep = &resp->getExceptions(); if(excep != NULL && excep->ordinality() > 0) { StringBuffer msg; excep->errorMessage(msg); printf("%s\n", msg.str()); return false; } IArrayOf<IConstECLWorkunit>& wus = resp->getWorkunits(); wus.sort(compareWUs); ForEachItemIn(idx, wus) { doFormat(s, &wus.item(idx)); // Print the results if (fp != NULL) { fprintf(fp, "%s", s.str()); s.clear(); } } }