MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / from_base64

Function from_base64

src/ifcparse/IfcGlobalId.cpp:52–66  ·  view source on GitHub ↗

Converts a base64 string into an unsigned integer

Source from the content-addressed store, hash-verified

50
51// Converts a base64 string into an unsigned integer
52unsigned from_base64(const std::string& string) {
53 std::string::size_type zeros = string.find_first_not_of('0');
54 unsigned result = 0;
55 if (zeros != std::string::npos) {
56 for (std::string::const_iterator i = string.begin() + zeros; i != string.end(); ++i) {
57 result *= 64;
58 const char* character = strchr(chars, *i);
59 if (character == nullptr) {
60 throw IfcParse::IfcException("Failed to decode GlobalId");
61 }
62 result += (unsigned)(character - chars);
63 }
64 }
65 return result;
66}
67
68// Compresses the UUID byte array into a base64 representation
69std::string compress(unsigned char* value) {

Callers 1

expandFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected