Coverage Report

Created: 2026-01-17 06:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/opendnp3/cpp/lib/src/app/parsing/APDUHeaderParser.h
Line
Count
Source
1
/*
2
 * Copyright 2013-2022 Step Function I/O, LLC
3
 *
4
 * Licensed to Green Energy Corp (www.greenenergycorp.com) and Step Function I/O
5
 * LLC (https://stepfunc.io) under one or more contributor license agreements.
6
 * See the NOTICE file distributed with this work for additional information
7
 * regarding copyright ownership. Green Energy Corp and Step Function I/O LLC license
8
 * this file to you under the Apache License, Version 2.0 (the "License"); you
9
 * may not use this file except in compliance with the License. You may obtain
10
 * a copy of the License at:
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
#ifndef OPENDNP3_APDUHEADERPARSER_H
21
#define OPENDNP3_APDUHEADERPARSER_H
22
23
#include "app/APDUHeader.h"
24
25
#include "opendnp3/logging/Logger.h"
26
#include "opendnp3/util/StaticOnly.h"
27
28
#include <ser4cpp/container/SequenceTypes.h>
29
30
namespace opendnp3
31
{
32
33
class APDUHeaderParser : private StaticOnly
34
{
35
36
public:
37
    template<class T> class Result
38
    {
39
    public:
40
        const bool success;
41
        const T header;
42
        const ser4cpp::rseq_t objects;
43
44
        static Result Ok(const T& header, const ser4cpp::rseq_t& objects)
45
51.9k
        {
46
51.9k
            return Result(header, objects);
47
51.9k
        }
opendnp3::APDUHeaderParser::Result<opendnp3::APDUHeader>::Ok(opendnp3::APDUHeader const&, ser4cpp::RSeq<unsigned long> const&)
Line
Count
Source
45
44.2k
        {
46
44.2k
            return Result(header, objects);
47
44.2k
        }
opendnp3::APDUHeaderParser::Result<opendnp3::APDUResponseHeader>::Ok(opendnp3::APDUResponseHeader const&, ser4cpp::RSeq<unsigned long> const&)
Line
Count
Source
45
7.76k
        {
46
7.76k
            return Result(header, objects);
47
7.76k
        }
48
49
        static Result Error()
50
447
        {
51
447
            return Result();
52
447
        }
opendnp3::APDUHeaderParser::Result<opendnp3::APDUHeader>::Error()
Line
Count
Source
50
243
        {
51
243
            return Result();
52
243
        }
opendnp3::APDUHeaderParser::Result<opendnp3::APDUResponseHeader>::Error()
Line
Count
Source
50
204
        {
51
204
            return Result();
52
204
        }
53
54
    private:
55
51.9k
        Result(const T& header, const ser4cpp::rseq_t& objects) : success(true), header(header), objects(objects) {}
opendnp3::APDUHeaderParser::Result<opendnp3::APDUHeader>::Result(opendnp3::APDUHeader const&, ser4cpp::RSeq<unsigned long> const&)
Line
Count
Source
55
44.2k
        Result(const T& header, const ser4cpp::rseq_t& objects) : success(true), header(header), objects(objects) {}
opendnp3::APDUHeaderParser::Result<opendnp3::APDUResponseHeader>::Result(opendnp3::APDUResponseHeader const&, ser4cpp::RSeq<unsigned long> const&)
Line
Count
Source
55
7.76k
        Result(const T& header, const ser4cpp::rseq_t& objects) : success(true), header(header), objects(objects) {}
56
57
447
        Result() : success(false) {}
opendnp3::APDUHeaderParser::Result<opendnp3::APDUHeader>::Result()
Line
Count
Source
57
243
        Result() : success(false) {}
opendnp3::APDUHeaderParser::Result<opendnp3::APDUResponseHeader>::Result()
Line
Count
Source
57
204
        Result() : success(false) {}
58
    };
59
60
    static Result<APDUHeader> ParseRequest(const ser4cpp::rseq_t& apdu, Logger* logger = nullptr);
61
62
    static Result<APDUResponseHeader> ParseResponse(const ser4cpp::rseq_t& apdu, Logger* logger = nullptr);
63
};
64
65
} // namespace opendnp3
66
67
#endif