Skip to content

Commit 0c8a571

Browse files
committed
all so far
1 parent 606bf0d commit 0c8a571

File tree

15 files changed

+163
-21
lines changed

15 files changed

+163
-21
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ BreakBeforeTernaryOperators: true
4040
BreakConstructorInitializers: BeforeColon
4141
BreakConstructorInitializersBeforeComma: false
4242
BreakStringLiterals: true
43-
ColumnLimit: 80 # used to be 120 - wtf
43+
ColumnLimit: 90 # used to be 120 - wtf
4444
CommentPragmas: '^ IWYU pragma:'
4545
CompactNamespaces: false
4646
ConstructorInitializerAllOnOneLineOrOnePerLine: false

.idea/codeStyles/Project.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,4 @@ set(CPACK_PACKAGE_FILE_NAME
184184
"${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${GIT_SHORT_SHA}-${CMAKE_SYSTEM_NAME}-${CMAKE_BUILD_TYPE}-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}"
185185
)
186186

187-
include(CPack)
188-
189-
187+
include(CPack)

include/CharParser/CharParser.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
//
2-
// Created by putii-legion-2 on 20.04.2024.
3-
//
4-
51
#ifndef JSONPARSER_CHARPARSER_H
62
#define JSONPARSER_CHARPARSER_H
73

4+
#include <optional>
5+
#include <string>
6+
#include <utility>
7+
8+
class CharParser {
9+
public:
10+
//std::optional<std::pair<char, std::string>> operator()(const std::string& str);
811

9-
class CharParser {};
12+
private:
13+
};
1014

1115

1216
#endif // JSONPARSER_CHARPARSER_H

include/Functor/Functor.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef JSONPARSER_FUNCTOR_HPP
2+
#define JSONPARSER_FUNCTOR_HPP
3+
4+
#include <functional>
5+
6+
7+
template<typename A, typename B, template <typename> typename C>
8+
struct Functor {
9+
virtual C<B> fmap(const std::function<B(A)>&, const C<A>&) const = 0;
10+
virtual ~Functor() = default;
11+
};
12+
13+
14+
#endif // JSONPARSER_FUNCTOR_HPP

include/JsonValue/JsonValue.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ union JsonContent {
2424
std::unordered_map<std::string, JsonValue> o;
2525
};
2626

27-
struct JsonValue {
27+
struct JsonValue { // parsing tree
2828
JsonType t;
2929
JsonContent c;
3030
};

include/Parser/Parser.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef JSONPARSER_CHARPARSER_H
2+
#define JSONPARSER_CHARPARSER_H
3+
4+
#include <functional>
5+
#include <optional>
6+
#include <string>
7+
#include <utility>
8+
9+
template<typename T>
10+
using optParsedRestStrPair = std::optional<std::pair<T, std::string>>;
11+
12+
/**
13+
* Mr. Parser
14+
* It takes string, parses part of it
15+
* and returns optional pair of effect of parsing and rest of string
16+
* @tparam T
17+
*/
18+
template<typename T>
19+
class Parser {
20+
public:
21+
explicit Parser(std::function<optParsedRestStrPair<T>(const std::string& str)> inF) : f(inF) {};
22+
23+
/**
24+
* I want to call Parser objects with string as parameter
25+
* which will delegate to f
26+
* @param str to be parsed string
27+
* @return
28+
*/
29+
optParsedRestStrPair<T> operator()(const std::string& str);
30+
private:
31+
/**
32+
* Injected dependency doing specialiazed parsing
33+
*/
34+
std::function<optParsedRestStrPair<T>(const std::string& str)> f;
35+
};
36+
37+
#endif // JSONPARSER_CHARPARSER_H

src/CMakeLists.txt

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,39 @@
1-
################### LIFETIME CLASS PLAYGROUND ###################
1+
################################ LIFETIME CLASS PLAYGROUND ################################
22

33
add_executable(lifetime lifetime.cpp)
44

5+
################################ CharParser STATIC LIBRARY ################################
6+
add_library(Parser Parser.cpp)
7+
8+
# Include the directory containing the header file
9+
target_include_directories(Parser
10+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/Parser>
11+
)
12+
13+
################################ CharParser STATIC LIBRARY ################################
14+
add_library(CharParser CharParser.cpp)
15+
16+
# Include the directory containing the header file
17+
target_include_directories(CharParser
18+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/CharParser>
19+
)
20+
21+
################################ JsonValue STATIC LIBRARY ################################
22+
add_library(JsonValue JsonValue.cpp)
23+
24+
# Include the directory containing the header file
25+
target_include_directories(JsonValue
26+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/JsonValue>
27+
)
28+
29+
################################ Functor STATIC LIBRARY ################################
30+
add_library(Functor Functor.cpp)
31+
32+
# Include the directory containing the header file
33+
target_include_directories(Functor
34+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/Functor>
35+
)
36+
537
################### MAIN BINARY ###################
638
# Create executable target for your main source file
739
add_executable(main main.cpp)

src/CharParser.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
//
2-
// Created by putii-legion-2 on 20.04.2024.
3-
//
4-
5-
#include "CharParser.h"
1+
#include "CharParser.hpp"

src/Functor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "Functor.hpp"

0 commit comments

Comments
 (0)