Ignore:
Timestamp:
09/04/17 03:24:01 (7 years ago)
Author:
Maciej Komosinski
Message:

Support for reading/parsing and writing 64-bit integer values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/sstringutils.cpp

    r529 r691  
    77#include <common/log.h>
    88#include <common/nonstd.h>
     9#include <common/Convert.h>
    910
    1011int loadSString(const char* filename, SString& s, const char* framsgmodule, const char* error, bool remove_cr)
     
    1920        }
    2021        else if (framsgmodule)
    21                 logPrintf(framsgmodule, "loadSString", LOG_WARN, error ? error : "can't open file \"%s\"", filename);
     22                logPrintf(framsgmodule, "loadSString", LOG_WARN, error ? error : "Can't open file \"%s\"", filename);
    2223        return ret;
    2324}
     
    323324}
    324325
     326SString getUIDString(uint64_t uid, char prefix)
     327{
     328        return SString::sprintf("%c" UINT64_FORMAT, prefix, uid);
     329}
     330
     331bool parseUIDString(const char* str, char prefix, uint64_t &uid, bool err)
     332{
     333        if ((str[0] == prefix) && (isdigit(str[1])))
     334        {
     335                char* end;
     336                uid = strtoull(str + 1, &end, 10);
     337                if (end == (str + 1 + strlen(str + 1)))
     338                        return true;
     339        }
     340        if (err)
     341                logPrintf("SString", "parseUIDString", LOG_ERROR, "Invalid uid: '%s'", str);
     342        return false;
     343}
Note: See TracChangeset for help on using the changeset viewer.