2 /******************************************************************************
4 * Copyright (c) 2019 AT&T Intellectual Property.
5 * Copyright (c) 2018-2019 Nokia.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************************/
21 // Standard Includes: ANSI C/C++, MSA, and Third-Party Libraries
23 // Local Includes: Application specific classes, functions, and libraries
28 /***************************************************************************************
30 ***************************************************************************************/
33 static tag_value_t decode(DecoderCtx& ctx, size_t& length, tag_value_t const* tag_ptr = nullptr)
35 auto & buffer = ctx.refBuffer();
36 tag_value_t tag = tag_ptr ? *tag_ptr : get_tag(ctx);
37 length = Length::decode(ctx);
43 else if(length == indefinite_length)
49 _tag = OpenType::decode(ctx, _length);
51 } while(ctx && !(_tag == 0 && _length == 0));
55 if (buffer.getBytesLeft() < length)
57 ctx.refErrorCtx().lengthErrorBytes(buffer.getBytesLeft(), length);
62 DecoderCtx::buf_type::pointer end = buffer.end();
63 buffer.set_end(buffer.begin() + length);