| Directory: | src/ |
|---|---|
| File: | src/Base.h |
| Date: | 2026-09-03 17:04:53 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 9 | 16 | 56.2% |
| Branches: | 26 | 64 | 40.6% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /***************************************************************************** | ||
| 2 | * | ||
| 3 | * Copyright (C) 2021 - 2022 Jonathan Grahl <jonathan.grahl@igh.de> | ||
| 4 | * 2021 - 2022 Florian Pose <florian.pose@igh.de> | ||
| 5 | * | ||
| 6 | * This file is part of the reta library (realtime-automation). | ||
| 7 | * | ||
| 8 | * The reta library is free software: you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU Lesser General Public License as published | ||
| 10 | * by the Free Software Foundation, either version 3 of the License, or (at | ||
| 11 | * your option) any later version. | ||
| 12 | * | ||
| 13 | * The reta library is distributed in the hope that it will be useful, but | ||
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
| 16 | * General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU Lesser General Public License | ||
| 19 | * along with the reta library. If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | * | ||
| 21 | ****************************************************************************/ | ||
| 22 | |||
| 23 | #ifndef RETA_BASE_H | ||
| 24 | #define RETA_BASE_H | ||
| 25 | |||
| 26 | /****************************************************************************/ | ||
| 27 | |||
| 28 | #include <sstream> | ||
| 29 | #include <stdexcept> | ||
| 30 | #include <string> | ||
| 31 | #include <vector> | ||
| 32 | |||
| 33 | /****************************************************************************/ | ||
| 34 | |||
| 35 | namespace Reta { | ||
| 36 | 314 | class Base | |
| 37 | { | ||
| 38 | public: | ||
| 39 | Base(const std::string &); | ||
| 40 | |||
| 41 | void checkZeroWidth(unsigned int) const; | ||
| 42 | |||
| 43 | template <class T> | ||
| 44 | ✗ | void checkNegativeInput(T input) const | |
| 45 | { | ||
| 46 | ✗ | if (input >= 0.0) { | |
| 47 | ✗ | return; | |
| 48 | } | ||
| 49 | |||
| 50 | ✗ | std::stringstream str; | |
| 51 | ✗ | str << __PRETTY_FUNCTION__ << ": " << path | |
| 52 | ✗ | << " Negative input not allowed!"; | |
| 53 | ✗ | throw std::invalid_argument(str.str()); | |
| 54 | } | ||
| 55 | |||
| 56 | template <class TInput, class TMember> | ||
| 57 | 291 | void checkSize( | |
| 58 | const std::vector<TInput> &input, | ||
| 59 | const std::vector<TMember> &member) const | ||
| 60 | { | ||
| 61 |
4/4✓ Branch 2 taken 243 times.
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 4 times.
|
291 | if (input.size() == member.size()) { |
| 62 | 572 | return; | |
| 63 | } | ||
| 64 | |||
| 65 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
10 | std::stringstream str; |
| 66 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
5 | str << __PRETTY_FUNCTION__ << ": " << path |
| 67 |
10/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 4 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 4 times.
✗ Branch 27 not taken.
✓ Branch 30 taken 4 times.
✗ Branch 31 not taken.
|
5 | << " Size mismatch! Input has " << input.size() |
| 68 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
|
5 | << " elements while attribute has " << member.size() << "."; |
| 69 |
4/8✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
|
5 | throw std::out_of_range(str.str()); |
| 70 | } | ||
| 71 | |||
| 72 | private: | ||
| 73 | const std::string path; | ||
| 74 | }; | ||
| 75 | |||
| 76 | } // namespace Reta | ||
| 77 | |||
| 78 | #endif // RETA_BASE_H | ||
| 79 | |||
| 80 | /****************************************************************************/ | ||
| 81 |