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

Function formatInt

external/as_add_on/scriptstdstring/scriptstdstring.cpp:445–485  ·  view source on GitHub ↗

AngelScript signature: string formatInt(int64 val, const string &in options, uint width)

Source from the content-addressed store, hash-verified

443// AngelScript signature:
444// string formatInt(int64 val, const string &in options, uint width)
445static string formatInt(asINT64 value, const string &options, asUINT width)
446{
447 bool leftJustify = options.find("l") != string::npos;
448 bool padWithZero = options.find("0") != string::npos;
449 bool alwaysSign = options.find("+") != string::npos;
450 bool spaceOnSign = options.find(" ") != string::npos;
451 bool hexSmall = options.find("h") != string::npos;
452 bool hexLarge = options.find("H") != string::npos;
453
454 string fmt = "%";
455 if( leftJustify ) fmt += "-";
456 if( alwaysSign ) fmt += "+";
457 if( spaceOnSign ) fmt += " ";
458 if( padWithZero ) fmt += "0";
459
460#ifdef _WIN32
461 fmt += "*I64";
462#else
463#ifdef _LP64
464 fmt += "*l";
465#else
466 fmt += "*ll";
467#endif
468#endif
469
470 if( hexSmall ) fmt += "x";
471 else if( hexLarge ) fmt += "X";
472 else fmt += "d";
473
474 string buf;
475 buf.resize(width+30);
476#if _MSC_VER >= 1400 && !defined(__S3E__)
477 // MSVC 8.0 / 2005 or newer
478 sprintf_s(&buf[0], buf.size(), fmt.c_str(), width, value);
479#else
480 sprintf(&buf[0], fmt.c_str(), width, value);
481#endif
482 buf.resize(strlen(&buf[0]));
483
484 return buf;
485}
486
487// AngelScript signature:
488// string formatUInt(uint64 val, const string &in options, uint width)

Callers 1

formatInt_GenericFunction · 0.85

Calls 1

findMethod · 0.80

Tested by

no test coverage detected