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

Method TryGetInteger

libraries/lib-xml/XMLAttributeValueView.cpp:318–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316
317template <typename ResultType>
318bool XMLAttributeValueView::TryGetInteger(ResultType& value) const noexcept
319{
320 static_assert(std::is_integral_v<ResultType>);
321
322 if (mType == Type::SignedInteger)
323 {
324 return CheckInteger(value, mInteger);
325 }
326 else if (mType == Type::UnsignedInteger)
327 {
328 return CheckInteger(value, static_cast<uint64_t>(mInteger));
329 }
330 else if (mType == Type::StringView)
331 {
332 const char* end = mStringView.Data + mStringView.Length;
333
334 ResultType tempValue = {};
335
336 const auto result = FromChars(mStringView.Data, end, tempValue);
337
338 if (result.ec == std::errc() && result.ptr == end)
339 {
340 value = tempValue;
341 return true;
342 }
343 }
344
345 return false;
346}

Callers

nothing calls this directly

Calls 2

CheckIntegerFunction · 0.85
FromCharsFunction · 0.85

Tested by

no test coverage detected