MCPcopy Create free account
hub / github.com/CytopiaTeam/Cytopia / formatUInt

Function formatUInt

external/as_add_on/scriptstdstring/scriptstdstring.cpp:489–529  ·  view source on GitHub ↗

AngelScript signature: string formatUInt(uint64 val, const string &in options, uint width)

Source from the content-addressed store, hash-verified

487// AngelScript signature:
488// string formatUInt(uint64 val, const string &in options, uint width)
489static string formatUInt(asQWORD value, const string &options, asUINT width)
490{
491 bool leftJustify = options.find("l") != string::npos;
492 bool padWithZero = options.find("0") != string::npos;
493 bool alwaysSign = options.find("+") != string::npos;
494 bool spaceOnSign = options.find(" ") != string::npos;
495 bool hexSmall = options.find("h") != string::npos;
496 bool hexLarge = options.find("H") != string::npos;
497
498 string fmt = "%";
499 if( leftJustify ) fmt += "-";
500 if( alwaysSign ) fmt += "+";
501 if( spaceOnSign ) fmt += " ";
502 if( padWithZero ) fmt += "0";
503
504#ifdef _WIN32
505 fmt += "*I64";
506#else
507#ifdef _LP64
508 fmt += "*l";
509#else
510 fmt += "*ll";
511#endif
512#endif
513
514 if( hexSmall ) fmt += "x";
515 else if( hexLarge ) fmt += "X";
516 else fmt += "u";
517
518 string buf;
519 buf.resize(width+30);
520#if _MSC_VER >= 1400 && !defined(__S3E__)
521 // MSVC 8.0 / 2005 or newer
522 sprintf_s(&buf[0], buf.size(), fmt.c_str(), width, value);
523#else
524 sprintf(&buf[0], fmt.c_str(), width, value);
525#endif
526 buf.resize(strlen(&buf[0]));
527
528 return buf;
529}
530
531// AngelScript signature:
532// string formatFloat(double val, const string &in options, uint width, uint precision)

Callers 1

formatUInt_GenericFunction · 0.85

Calls 1

findMethod · 0.80

Tested by

no test coverage detected