LCOV - code coverage report
Current view: top level - setup_payload - ManualSetupPayloadParser.h (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 0 5 0.0 %
Date: 2024-02-15 08:20:41 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /**
       2             :  *
       3             :  *    Copyright (c) 2020 Project CHIP Authors
       4             :  *
       5             :  *    Licensed under the Apache License, Version 2.0 (the "License");
       6             :  *    you may not use this file except in compliance with the License.
       7             :  *    You may obtain a copy of the License at
       8             :  *
       9             :  *        http://www.apache.org/licenses/LICENSE-2.0
      10             :  *
      11             :  *    Unless required by applicable law or agreed to in writing, software
      12             :  *    distributed under the License is distributed on an "AS IS" BASIS,
      13             :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14             :  *    See the License for the specific language governing permissions and
      15             :  *    limitations under the License.
      16             :  */
      17             : 
      18             : /**
      19             :  *    @file
      20             :  *      This file describes a Manual Setup Payload parser based on the
      21             :  *      CHIP specification.
      22             :  */
      23             : 
      24             : #pragma once
      25             : 
      26             : #include "SetupPayload.h"
      27             : 
      28             : #include <algorithm>
      29             : #include <lib/core/CHIPError.h>
      30             : #include <string>
      31             : #include <utility>
      32             : 
      33             : namespace chip {
      34             : 
      35             : /**
      36             :  * @class ManualSetupPayloadParser
      37             :  * A class that can be used to convert a decimal encoded payload to a SetupPayload object
      38             :  * */
      39             : class ManualSetupPayloadParser
      40             : {
      41             : private:
      42             :     std::string mDecimalStringRepresentation;
      43             : 
      44             : public:
      45           0 :     ManualSetupPayloadParser(std::string decimalRepresentation) : mDecimalStringRepresentation(std::move(decimalRepresentation))
      46             :     {
      47             :         // '-' might be being used in the decimal code as a digit group
      48             :         // separator, to aid in readability.  It's not actually part of the
      49             :         // decomal code, so strip it out.
      50           0 :         mDecimalStringRepresentation.erase(
      51           0 :             std::remove(mDecimalStringRepresentation.begin(), mDecimalStringRepresentation.end(), '-'),
      52           0 :             mDecimalStringRepresentation.end());
      53           0 :     }
      54             :     CHIP_ERROR populatePayload(SetupPayload & outPayload);
      55             : 
      56             :     static CHIP_ERROR CheckDecimalStringValidity(std::string decimalString, std::string & decimalStringWithoutCheckDigit);
      57             :     static CHIP_ERROR CheckCodeLengthValidity(const std::string & decimalString, bool isLongCode);
      58             :     static CHIP_ERROR ToNumber(const std::string & decimalString, uint32_t & dest);
      59             :     static CHIP_ERROR ReadDigitsFromDecimalString(const std::string & decimalString, size_t & index, uint32_t & dest,
      60             :                                                   size_t numberOfCharsToRead);
      61             : };
      62             : 
      63             : } // namespace chip

Generated by: LCOV version 1.14