Converts a base64 string into an unsigned integer
| 50 | |
| 51 | // Converts a base64 string into an unsigned integer |
| 52 | unsigned 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 |
| 69 | std::string compress(unsigned char* value) { |