Skip to content

Commit

Permalink
Reordering.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfjlaros committed Aug 21, 2022
1 parent 8308735 commit e4f68de
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 51 deletions.
8 changes: 0 additions & 8 deletions src/textparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ ccp TextParser::findEnd_(ccp line) const {
}


bool strmatch(ccpc begin, ccpc end, ccpc str) {
ccp p;
ccp q;
for (p = begin, q = str; p < end and *q and *p == *q; p++, q++);
return p == end and not *q;
}


void TextParser::parse(char& result, ccpc begin, ccpc end) const {
result = 0;
if (begin < end) {
Expand Down
43 changes: 1 addition & 42 deletions src/textparser.h
Original file line number Diff line number Diff line change
@@ -1,49 +1,8 @@
#pragma once

#include <stdlib.h>
#include <string.h>

typedef char const* ccp; //!< Pointer to a constant string.
typedef ccp const ccpc; //!< Constant pointer to a constant string.

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

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

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


/*! String comparison.
*
* \param[in] begin Pointer to the first C string.
* \param[in] end Pointer to end of the first C string.
* \param[in] str Pointer to the second C string.
*/
bool strmatch(ccpc begin, ccpc end, ccpc str);

#include "texttypes.h"

/*! Line based text parser. */
class TextParser {
Expand Down
8 changes: 8 additions & 0 deletions src/texttypes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "texttypes.h"

bool strmatch(ccpc begin, ccpc end, ccpc str) {
ccp p;
ccp q;
for (p = begin, q = str; p < end and *q and *p == *q; p++, q++);
return p == end and not *q;
}
44 changes: 44 additions & 0 deletions src/texttypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include <stdlib.h>

typedef char const* ccp; //!< Pointer to a constant string.
typedef ccp const ccpc; //!< Constant pointer to a constant string.

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

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

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


/*! String comparison.
*
* \param[in] begin Pointer to the first C string.
* \param[in] end Pointer to end of the first C string.
* \param[in] str Pointer to the second C string.
*/
bool strmatch(ccpc begin, ccpc end, ccpc str);
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ EXEC := run_tests
MAIN := test_lib
TESTS := test_parser
FIXTURES :=
LIBS := ../src/textparser
LIBS := ../src/textparser ../src/texttypes


CC := g++
Expand Down

0 comments on commit e4f68de

Please sign in to comment.