MCPcopy Create free account
hub / github.com/PABannier/bark.cpp / get_ubjson_ndarray_size

Method get_ubjson_ndarray_size

examples/server/json.hpp:11018–11070  ·  view source on GitHub ↗

! @param[out] dim an integer vector storing the ND array dimensions @return whether reading ND array size vector is successful */

Source from the content-addressed store, hash-verified

11016 @return whether reading ND array size vector is successful
11017 */
11018 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11019 {
11020 std::pair<std::size_t, char_int_type> size_and_type;
11021 size_t dimlen = 0;
11022 bool no_ndarray = true;
11023
11024 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type, no_ndarray)))
11025 {
11026 return false;
11027 }
11028
11029 if (size_and_type.first != npos)
11030 {
11031 if (size_and_type.second != 0)
11032 {
11033 if (size_and_type.second != 'N')
11034 {
11035 for (std::size_t i = 0; i < size_and_type.first; ++i)
11036 {
11037 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray, size_and_type.second)))
11038 {
11039 return false;
11040 }
11041 dim.push_back(dimlen);
11042 }
11043 }
11044 }
11045 else
11046 {
11047 for (std::size_t i = 0; i < size_and_type.first; ++i)
11048 {
11049 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray)))
11050 {
11051 return false;
11052 }
11053 dim.push_back(dimlen);
11054 }
11055 }
11056 }
11057 else
11058 {
11059 while (current != ']')
11060 {
11061 if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_value(dimlen, no_ndarray, current)))
11062 {
11063 return false;
11064 }
11065 dim.push_back(dimlen);
11066 get_ignore_noop();
11067 }
11068 }
11069 return true;
11070 }
11071
11072 /*!
11073 @param[out] result determined size

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected