Skip to content

Commit 02c9e64

Browse files
committed
Imoproved
1 parent b9c2dd9 commit 02c9e64

File tree

4 files changed

+85
-2
lines changed

4 files changed

+85
-2
lines changed

app/common/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,13 @@ set(HEADERS
88
${PROJECT_SOURCE_DIR}/include/constants/Constants.h
99
${PROJECT_SOURCE_DIR}/include/types/Report.h
1010
${PROJECT_SOURCE_DIR}/include/types/ReportFormat.h
11-
${PROJECT_SOURCE_DIR}/include/types/User.h
12-
)
11+
${PROJECT_SOURCE_DIR}/include/types/User.h)
12+
13+
set(SOURCES
14+
${PROJECT_SOURCE_DIR}/src/types/User.cpp
15+
${PROJECT_SOURCE_DIR}/src/types/Report.cpp
16+
${PROJECT_SOURCE_DIR}/src/types/ReportFormat.cpp)
17+
18+
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
19+
20+
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/inc;include)

app/common/src/types/Report.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Created by sajith on 6/20/22.
3+
//
4+
5+
#include "types/Report.h"
6+
#include <tuple>
7+
8+
namespace types
9+
{
10+
bool operator==(const Report &lhs, const Report &rhs)
11+
{
12+
return std::tie(lhs.payer, lhs.tax, lhs.amount, lhs.year) == std::tie(rhs.payer, rhs.tax, rhs.amount, rhs.year);
13+
}
14+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Created by sajith on 6/20/22.
3+
//
4+
5+
#include "types/ReportFormat.h"
6+
7+
#include <iostream>
8+
#include <string>
9+
10+
#include <boost/algorithm/string.hpp>
11+
12+
std::istream &operator>>(std::istream &in, types::ReportFormat &format)
13+
{
14+
std::string token;
15+
in >> token;
16+
boost::algorithm::to_lower(token);
17+
18+
if (token == "json")
19+
{
20+
format = types::ReportFormat::Json;
21+
}
22+
else if (token == "xml")
23+
{
24+
format = types::ReportFormat::Xml;
25+
}
26+
else
27+
{
28+
in.setstate(std::ios_base::failbit);
29+
}
30+
31+
return in;
32+
}

app/common/src/types/User.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// Created by sajith on 6/20/22.
3+
//
4+
5+
#include "types/User.h"
6+
7+
namespace types
8+
{
9+
bool operator==(const Login &lhs, const Login &rhs)
10+
{
11+
return lhs.value == rhs.value;
12+
}
13+
14+
bool operator<(const User &lhs, const User &rhs)
15+
{
16+
return lhs.login.value < rhs.login.value;
17+
}
18+
19+
bool operator<(const User &a, const Login &l)
20+
{
21+
return a.login.value < l.value;
22+
}
23+
24+
bool operator<(const Login &l, const User &u)
25+
{
26+
return l.value < u.login.value;
27+
}
28+
29+
}

0 commit comments

Comments
 (0)