Skip to content

Commit

Permalink
Types now inherit from Container type.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfjlaros committed Sep 30, 2022
1 parent e4f68de commit 32b1c40
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ If the fields have different types, we can use multiple variables.
char a[4];
int b;
double c;
parser.parseLine("one, 2, 3.4, 0x38", a, b, c);
parser.parseLine("one, 2, 3.4", a, b, c);
.. _ReadTheDocs: https://arduinotextparser.readthedocs.io
3 changes: 3 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Functions
Types
-----

.. doxygenstruct:: Container_
:members:

.. doxygenstruct:: Number
:members:

Expand Down
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Integers in arbitrary bases are supported via the `Number` type.
.. code-block:: cpp
Number<int, 16> a; // Hexadecimal number.
Number<int, 2> a; // Binary number.
Number<int, 2> b; // Binary number.
parser.parseLine("0x1f, 101001", a, b);
Expand Down
23 changes: 13 additions & 10 deletions src/texttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,37 @@
typedef char const* ccp; //!< Pointer to a constant string.
typedef ccp const ccpc; //!< Constant pointer to a constant string.

/*! Generic container.
*
* \tparam T Value type.
*/
template <class T>
struct Container_ {
T value; //!< Value.
};

/*! Integer number.
*
* \tparam T Integer type.
* \tparam base Integer base.
*/
template <class T, size_t base>
struct Number {
T value; //!< Value.
};
struct Number : Container_<T> {};

/*! Boolean.
*
* \tparam truth Truth value.
*/
template <ccp truth>
struct Bool {
bool value; //!< Value.
};
struct Bool : Container_<bool> {};

/*! Category.
*
* \tparam T Integer type.
* \tparam .
* \tparam labels Labels.
*/
template <class T, ccp* labels>
struct Category {
T value; //!< Value.
};
struct Category : Container_<T> {};


/*! String comparison.
Expand Down

0 comments on commit 32b1c40

Please sign in to comment.