MCPcopy Create free account
hub / github.com/audacity/audacity / FromString

Method FromString

libraries/lib-uuid/Uuid.cpp:119–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119Uuid Uuid::FromString(const std::string& str)
120{
121 const size_t length = str.length();
122
123 if (length == 0)
124 return {};
125
126 const bool hasBraces = str[0] == '{';
127
128 if (hasBraces && (length != BRACED_UUID_LENGTH || str.back() != '}'))
129 return {};
130 else if (!hasBraces && length != UUID_LENGTH)
131 return {};
132
133 const unsigned int iteratorOffset = hasBraces ? 1 : 0;
134
135 std::string::const_iterator currentSymbol = str.begin() + iteratorOffset;
136 std::string::const_iterator inputEnd = str.end() - iteratorOffset;
137
138 Uuid uuid;
139 Bytes::iterator currentByte = uuid.mData.begin();
140
141 for (int i = 0; i < 16; ++i)
142 {
143 if (!readByte(currentByte, currentSymbol, inputEnd))
144 return {};
145
146 if (currentSymbol != inputEnd && *currentSymbol == '-')
147 ++currentSymbol;
148 }
149
150 return uuid;
151}
152
153bool Uuid::IsNil() const noexcept
154{

Callers

nothing calls this directly

Calls 4

readByteFunction · 0.85
lengthMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected