Skip to content

Commit 1d970b7

Browse files
committed
Update class API
1 parent 9e949b4 commit 1d970b7

File tree

12 files changed

+1109
-152
lines changed

12 files changed

+1109
-152
lines changed

Bar/include/bar/Bar.hpp

+87-20
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,120 @@
22

33
#include <cstdint>
44
#include <string>
5+
#include <vector>
56

67
//! @namespace bar The Bar namespace
78
namespace bar {
8-
//! @brief Free function in bar namespace.
9-
//! @param[in] level Scope level.
10-
void barHello(int level);
9+
//! @defgroup StringVector Vector of String usage.
10+
//! @{
11+
/*! @brief Test returning a vector of string.
12+
* @param level Scope level.
13+
* @return A vector of string.*/
14+
std::vector<std::string> stringVectorOutput(int level);
15+
/*! @brief Test using a vector of string passed by value.
16+
* @param data Input data.
17+
* @return The size of the data vector.*/
18+
int stringVectorInput(std::vector<std::string> data);
19+
/*! @brief Test using a vector of string passed by const ref.
20+
* @param data Input data.
21+
* @return The size of the data vector.*/
22+
int stringVectorRefInput(const std::vector<std::string>& data);
23+
//! @}
1124

12-
//! @brief Free function in bar namespace.
13-
//! @param[in] level Scope level.
14-
void barHello(int64_t level);
25+
//! @defgroup StringJaggedArray Vector of Vector of String usage.
26+
//! @{
27+
/*! @brief Test returning a jagged array of string.
28+
* @param level Scope level.
29+
* @return A jagged array of string.*/
30+
std::vector<std::vector<std::string>> stringJaggedArrayOutput(int level);
31+
/*! @brief Test using a jagged array of string passed by value.
32+
* @param data Input data.
33+
* @return The size of the data outer vector.*/
34+
int stringJaggedArrayInput(std::vector<std::vector<std::string>> data);
35+
/*! @brief Test using a jagged array of string passed by const ref.
36+
* @param data Input data.
37+
* @return The size of the data outer vector.*/
38+
int stringJaggedArrayRefInput(const std::vector<std::vector<std::string>>& data);
39+
//! @}
40+
41+
//! @defgroup PairVector Vector of Pair usage.
42+
//! @{
43+
/*! @brief Test returning a vector of pair.
44+
* @param level Scope level.
45+
* @return A vector of pair.*/
46+
std::vector<std::pair<int, int>> pairVectorOutput(int level);
47+
/*! @brief Test using a vector of pair passed by value.
48+
* @param data Input data.
49+
* @return The size of the data vector.*/
50+
int pairVectorInput(std::vector<std::pair<int, int>> data);
51+
/*! @brief Test using a vector of pair passed by const ref.
52+
* @param data Input data.
53+
* @return The size of the data vector.*/
54+
int pairVectorRefInput(const std::vector<std::pair<int, int>>& data);
55+
//! @}
56+
57+
//! @defgroup PairJaggedArray Jagged array of Pair<int, int> usage.
58+
//! @{
59+
/*! @brief Test returning a jagged array of pair.
60+
* @param level Scope level.
61+
* @return A jagged array of pair.*/
62+
std::vector<std::vector<std::pair<int, int>>> pairJaggedArrayOutput(int level);
63+
/*! @brief Test using a jagged array of pair passed by value.
64+
* @param data Input data.
65+
* @return The size of the data outer vector.*/
66+
int pairJaggedArrayInput(std::vector<std::vector<std::pair<int, int>>> data);
67+
/*! @brief Test using a jagged of pair passed by const ref.
68+
* @param data Input data.
69+
* @return The size of the data outer vector.*/
70+
int pairJaggedArrayRefInput(const std::vector<std::vector<std::pair<int, int>>>& data);
71+
//! @}
72+
73+
//! @defgroup FreeFunction Free function usage.
74+
//! @{
75+
/*! @brief Free function in bar namespace.
76+
* @param level Scope level.*/
77+
void freeFunction(int level);
78+
/*! @brief Free function in bar namespace.
79+
* @param level Scope level.*/
80+
void freeFunction(int64_t level);
81+
//! @}
1582

1683
//! @brief Class Bar.
1784
class Bar {
1885
public:
1986
//! @defgroup StaticMembers Static members
2087
//! @{
2188

22-
//! @brief Static method of Bar class.
23-
//! @param[in] level Scope level.
24-
static void hello(int level);
89+
/*! @brief Static method of Bar class.
90+
* @param[in] level Scope level.*/
91+
static void staticFunction(int level);
2592

26-
//! @brief Static method of Bar class.
27-
//! @param[in] level Scope level.
28-
static void hello(int64_t level);
93+
/*! @brief Static method of Bar class.
94+
* @param[in] level Scope level.*/
95+
static void staticFunction(int64_t level);
2996

3097
//! @}
3198

3299
//! @defgroup IntegerMembers Integer members
33100
//! @{
34101

35-
//! @brief Method (getter) of Bar class.
36-
//! @return A member value.
102+
/*! @brief Method (getter) of Bar class.
103+
* @return A member value.*/
37104
int getInt() const;
38-
//! @brief Method (setter) of Bar class.
39-
//! @param[in] input A member value.
105+
/*! @brief Method (setter) of Bar class.
106+
* @param[in] input A member value.*/
40107
void setInt(int input);
41108

42109
//! @}
43110

44111
//! @defgroup Int64Members Long Integer members
45112
//! @{
46113

47-
//! @brief Method (getter) of Bar class.
48-
//! @return A member value.
114+
/*! @brief Method (getter) of Bar class.
115+
* @return A member value.*/
49116
int64_t getInt64() const;
50-
//! @brief Method (setter) of Bar class.
51-
//! @param[in] input A member value.
117+
/*! @brief Method (setter) of Bar class.
118+
* @param[in] input A member value.*/
52119
void setInt64(int64_t input);
53120

54121
//! @}

Bar/src/Bar.cpp

+158-17
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,170 @@
11
#include "bar/Bar.hpp"
22

33
#include <iostream>
4+
#include <string>
5+
#include <utility>
46

57
namespace bar {
6-
void barHello(int level) {
7-
std::cout << "[" << level << "] Enter barHello(int)" << std::endl;
8-
std::cout << "[" << level << "] Exit barHello(int)" << std::endl;
8+
std::vector<std::string> stringVectorOutput(int level) {
9+
std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl;
10+
std::vector<std::string> result(level, std::to_string(level));
11+
std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl;
12+
return result;
913
}
1014

11-
void barHello(int64_t level) {
12-
std::cout << "[" << level << "] Enter barHello(int64_t)" << std::endl;
13-
std::cout << "[" << level << "] Exit barHello(int64_t)" << std::endl;
15+
int stringVectorInput(std::vector<std::string> data) {
16+
std::cout << "Enter " << __func__ << "()" << std::endl;
17+
std::cout << "{";
18+
for (const auto& item : data) {
19+
std::cout << item << ", ";
20+
}
21+
std::cout << "}" << std::endl;
22+
std::cout << "Exit " << __func__ << "()" << std::endl;
23+
return data.size();
1424
}
1525

16-
void Bar::hello(int level) {
17-
std::cout << "[" << level << "] Enter Bar::hello(int)" << std::endl;
18-
bar::barHello(level + 1);
19-
std::cout << "[" << level << "] Exit Bar::hello(int)" << std::endl;
26+
int stringVectorRefInput(const std::vector<std::string>& data) {
27+
std::cout << "Enter " << __func__ << "()" << std::endl;
28+
std::cout << "{";
29+
for (const auto& item : data) {
30+
std::cout << item << ", ";
31+
}
32+
std::cout << "}" << std::endl;
33+
std::cout << "Exit " << __func__ << "()" << std::endl;
34+
return data.size();
2035
}
2136

22-
void Bar::hello(int64_t level) {
23-
std::cout << "[" << level << "] Enter Bar::hello(int64_t)" << std::endl;
24-
bar::barHello(level + 1);
25-
std::cout << "[" << level << "] Exit Bar::hello(int64_t)" << std::endl;
37+
std::vector<std::vector<std::string>> stringJaggedArrayOutput(int level) {
38+
std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl;
39+
std::vector<std::vector<std::string>> result;
40+
result.reserve(level);
41+
for (int i = 1; i <= level; ++i) {
42+
result.emplace_back(std::vector<std::string>(i, std::to_string(i)));
43+
}
44+
std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl;
45+
return result;
2646
}
2747

28-
std::string Bar::operator()() const {
29-
return std::string{"\"Bar\":{\"int\":"} + std::to_string(_intValue) +
30-
",\"int64\":" + std::to_string(_int64Value) + "}";
48+
int stringJaggedArrayInput(std::vector<std::vector<std::string>> data) {
49+
std::cout << "Enter " << __func__ << "()" << std::endl;
50+
std::cout << "{";
51+
for (const auto& inner : data) {
52+
std::cout << "{";
53+
for (const auto& item : inner) {
54+
std::cout << item << ", ";
55+
}
56+
std::cout << "}, ";
57+
}
58+
std::cout << "}" << std::endl;
59+
std::cout << "Exit " << __func__ << "()" << std::endl;
60+
return data.size();
61+
}
62+
63+
int stringJaggedArrayRefInput(const std::vector<std::vector<std::string>>& data) {
64+
std::cout << "Enter " << __func__ << "()" << std::endl;
65+
std::cout << "{";
66+
for (const auto& inner : data) {
67+
std::cout << "{";
68+
for (const auto& item : inner) {
69+
std::cout << item << ", ";
70+
}
71+
std::cout << "}, ";
72+
}
73+
std::cout << "}" << std::endl;
74+
std::cout << "Exit " << __func__ << "()" << std::endl;
75+
return data.size();
76+
}
77+
78+
std::vector<std::pair<int, int>> pairVectorOutput(int level) {
79+
std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl;
80+
std::vector<std::pair<int, int>> result(level, std::make_pair(level, level));
81+
std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl;
82+
return result;
83+
}
84+
85+
int pairVectorInput(std::vector<std::pair<int, int>> data) {
86+
std::cout << "Enter " << __func__ << "()" << std::endl;
87+
std::cout << "{";
88+
for (const auto& item : data) {
89+
std::cout << "[" << item.first << "," << item.second << "], ";
90+
}
91+
std::cout << "}" << std::endl;
92+
std::cout << "Exit " << __func__ << "()" << std::endl;
93+
return data.size();
94+
}
95+
96+
int pairVectorRefInput(const std::vector<std::pair<int, int>>& data) {
97+
std::cout << "Enter " << __func__ << "()" << std::endl;
98+
std::cout << "{";
99+
for (const auto& item : data) {
100+
std::cout << "[" << item.first << "," << item.second << "], ";
101+
}
102+
std::cout << "}" << std::endl;
103+
std::cout << "Exit " << __func__ << "()" << std::endl;
104+
return data.size();
105+
}
106+
107+
std::vector<std::vector<std::pair<int, int>>> pairJaggedArrayOutput(int level) {
108+
std::cout << "[" << level << "] Enter " << __func__ << "()" << std::endl;
109+
std::vector<std::vector<std::pair<int, int>>> result;
110+
result.reserve(level);
111+
for (int i = 1; i <= level; ++i) {
112+
result.emplace_back(std::vector<std::pair<int, int>>(i, std::make_pair(i, i)));
113+
}
114+
std::cout << "[" << level << "] Exit " << __func__ << "()" << std::endl;
115+
return result;
116+
}
117+
118+
int pairJaggedArrayInput(std::vector<std::vector<std::pair<int, int>>> data) {
119+
std::cout << "Enter " << __func__ << "()" << std::endl;
120+
std::cout << "{";
121+
for (const auto& inner : data) {
122+
std::cout << "{";
123+
for (const auto& item : inner) {
124+
std::cout << "[" << item.first << "," << item.second << "], ";
125+
}
126+
std::cout << "}, ";
127+
}
128+
std::cout << "}" << std::endl;
129+
std::cout << "Exit " << __func__ << "()" << std::endl;
130+
return data.size();
131+
}
132+
133+
int pairJaggedArrayRefInput(const std::vector<std::vector<std::pair<int, int>>>& data) {
134+
std::cout << "Enter " << __func__ << "()" << std::endl;
135+
std::cout << "{";
136+
for (const auto& inner : data) {
137+
std::cout << "{";
138+
for (const auto& item : inner) {
139+
std::cout << "[" << item.first << "," << item.second << "], ";
140+
}
141+
std::cout << "}, ";
142+
}
143+
std::cout << "}" << std::endl;
144+
std::cout << "Exit " << __func__ << "()" << std::endl;
145+
return data.size();
146+
}
147+
148+
void freeFunction(int level) {
149+
std::cout << "[" << level << "] Enter " << __func__ << "(int)" << std::endl;
150+
std::cout << "[" << level << "] Exit " << __func__ << "(int)" << std::endl;
151+
}
152+
153+
void freeFunction(int64_t level) {
154+
std::cout << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl;
155+
std::cout << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl;
156+
}
157+
158+
void Bar::staticFunction(int level) {
159+
std::cout << "[" << level << "] Enter " << __func__ << "(int)" << std::endl;
160+
freeFunction(level + 1);
161+
std::cout << "[" << level << "] Exit " << __func__ << "(int)" << std::endl;
162+
}
163+
164+
void Bar::staticFunction(int64_t level) {
165+
std::cout << "[" << level << "] Enter " << __func__ << "(int64_t)" << std::endl;
166+
freeFunction(level + 1);
167+
std::cout << "[" << level << "] Exit " << __func__ << "(int64_t)" << std::endl;
31168
}
32169

33170
int Bar::getInt() const {
@@ -46,4 +183,8 @@ void Bar::setInt64(int64_t input) {
46183
_int64Value = input;
47184
}
48185

186+
std::string Bar::operator()() const {
187+
return std::string{"\"Bar\":{\"int\":"} + std::to_string(_intValue) +
188+
",\"int64\":" + std::to_string(_int64Value) + "}";
189+
}
49190
} // namespace bar

0 commit comments

Comments
 (0)