| // Copyright 2026 Google LLC |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // https://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| // |
| |
| #ifndef THIRD_PARTY_CREDENTIO_JUMBF_PARSE_H_ |
| #define THIRD_PARTY_CREDENTIO_JUMBF_PARSE_H_ |
| |
| #include "absl/status/statusor.h" |
| #include "absl/strings/string_view.h" |
| #include "jumbf/box.h" |
| |
| namespace jumbf { |
| |
| // Consumes the first serialized JUMBF super_box in `serialized_super_box`. |
| // Performs only basic validation. Does not check that description boxes |
| // correspond with content box types. `recursion_limit` is the maximum number of |
| // levels of super_box that will be parsed. If negative, no limit will be |
| // enforced. If the limit is reached, the raw content of any further nested |
| // super_boxes will be returned as `SerializedSuperBox` structs. If parsing is |
| // not successful, `serialized_super_box` will not be modified. |
| // |
| // `allow_implicit_length` determines if boxes may set LBox to 0 to indicate |
| // that the box extends to the end of the input. |
| // |
| // The return value contains references (in the form of `absl::string_view`) to |
| // the string underlying `serialized_super_box`. Callers must ensure that string |
| // outlives the return value. |
| absl::StatusOr<SuperBox> ConsumeSuperBox( |
| absl::string_view* serialized_super_box, int recursion_limit, |
| bool allow_implicit_length = true); |
| |
| } // namespace jumbf |
| |
| #endif // THIRD_PARTY_CREDENTIO_JUMBF_PARSE_H_ |