Skip to content

Commit 38aa145

Browse files
committed
styling + typedefs
1 parent 3ee93de commit 38aa145

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+15681
-11418
lines changed

.clang-format

Lines changed: 10 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -5,97 +5,16 @@
55
---
66
Language: Cpp
77

8-
AccessModifierOffset: -2
9-
AlignAfterOpenBracket: DontAlign
10-
AlignConsecutiveAssignments: true
11-
AlignConsecutiveDeclarations: false
12-
AlignEscapedNewlinesLeft: false
13-
AlignOperands: true
14-
AlignTrailingComments: true
15-
AllowAllParametersOfDeclarationOnNextLine: false
16-
AllowShortBlocksOnASingleLine: true
17-
AllowShortCaseLabelsOnASingleLine: true
18-
AllowShortFunctionsOnASingleLine: All
19-
AllowShortIfStatementsOnASingleLine: true
20-
AllowShortLoopsOnASingleLine: true
21-
AlwaysBreakAfterDefinitionReturnType: All
22-
AlwaysBreakAfterReturnType: AllDefinitions
23-
AlwaysBreakBeforeMultilineStrings: false
24-
AlwaysBreakTemplateDeclarations: true
25-
BinPackArguments: true
26-
BinPackParameters: true
27-
# Ignored if BreakBeforeBraces different from Custom
28-
BraceWrapping:
29-
AfterClass: false
30-
AfterControlStatement: false
31-
AfterEnum: false
32-
AfterFunction: false
33-
AfterNamespace: false
34-
AfterObjCDeclaration: false
35-
AfterStruct: false
36-
AfterUnion: false
37-
BeforeCatch: true
38-
BeforeElse: true
39-
IndentBraces: false
40-
BreakBeforeBinaryOperators: NonAssignment
41-
BreakBeforeBraces: Custom
42-
BreakBeforeTernaryOperators: true
43-
BreakConstructorInitializersBeforeComma: true
44-
# Ignored in C++
45-
BreakAfterJavaFieldAnnotations: false
46-
BreakStringLiterals: false
47-
ColumnLimit: 0
48-
CommentPragmas: '.*'
49-
ConstructorInitializerAllOnOneLineOrOnePerLine: true
50-
ConstructorInitializerIndentWidth: 0
51-
ContinuationIndentWidth: 2
52-
Cpp11BracedListStyle: true
53-
DerivePointerAlignment: false
54-
DisableFormat: false
55-
ExperimentalAutoDetectBinPacking: false
56-
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
57-
IncludeCategories:
58-
- Regex: 'cpp_redis'
59-
Priority: 1
60-
IncludeIsMainRegex: '$'
61-
IndentCaseLabels: false
62-
IndentWidth: 2
63-
IndentWrappedFunctionNames: false
64-
# Ignored in C++
65-
JavaScriptQuotes: Leave
66-
# Ignored in C++
67-
JavaScriptWrapImports: true
68-
KeepEmptyLinesAtTheStartOfBlocks: true
69-
MacroBlockBegin: ''
70-
MacroBlockEnd: ''
71-
MaxEmptyLinesToKeep: 2
72-
NamespaceIndentation: None
73-
# Ignored in C++
74-
ObjCBlockIndentWidth: 2
75-
# Ignored in C++
76-
ObjCSpaceAfterProperty: false
77-
# Ignored in C++
78-
ObjCSpaceBeforeProtocolList: true
79-
PenaltyBreakBeforeFirstCallParameter: 19
80-
PenaltyBreakComment: 300
81-
PenaltyBreakFirstLessLess: 120
82-
PenaltyBreakString: 1000
83-
PenaltyExcessCharacter: 1000000
84-
PenaltyReturnTypeOnItsOwnLine: 60
85-
PointerAlignment: Left
86-
ReflowComments: true
87-
SortIncludes: true
88-
SpaceAfterCStyleCast: true
89-
SpaceBeforeAssignmentOperators: true
90-
SpaceBeforeParens: ControlStatements
91-
SpaceInEmptyParentheses: false
92-
SpacesBeforeTrailingComments: 1
93-
SpacesInAngles: false
94-
SpacesInContainerLiterals: true
95-
SpacesInCStyleCastParentheses: false
96-
SpacesInParentheses: false
97-
SpacesInSquareBrackets: false
8+
BasedOnStyle: LLVM
9+
AlignAfterOpenBracket: Align
10+
AllowAllParametersOfDeclarationOnNextLine: 'true'
11+
AlwaysBreakAfterReturnType: All
12+
BinPackArguments: 'false'
13+
BinPackParameters: 'false'
9814
Standard: Cpp11
9915
TabWidth: 8
100-
UseTab: Never
16+
UseTab: Always
17+
ReflowComments: true
18+
FixNamespaceComments: true
19+
AlignTrailingComments: true
10120
...

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "tacopie"]
2-
path = tacopie
3-
url = https://github.com/Cylix/tacopie.git

clang_format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
find sources includes tests examples \( -name '*.cpp' -o -name '*.hpp' -o -name '*.ipp' -o -name '*.c' -o -name '*.h' \) -exec clang-format -i {} ';'
3+
find sources includes tests examples -maxdepth 3 \( -name '*.cpp' -o -name '*.hpp' -o -name '*.ipp' -o -name '*.c' -o -name '*.h' \) -exec clang-format -i {} ';'

examples/cpp_redis_client.cpp

Lines changed: 95 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// copies of the Software, and to permit persons to whom the Software is
1010
// furnished to do so, subject to the following conditions:
1111
//
12-
// The above copyright notice and this permission notice shall be included in all
13-
// copies or substantial portions of the Software.
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
1414
//
1515
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -19,114 +19,122 @@
1919
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
22-
#include <string>
2322
#include <cpp_redis/cpp_redis>
2423
#include <cpp_redis/misc/macro.hpp>
24+
#include <string>
2525

2626
#define ENABLE_SESSION = 1
2727

2828
#ifdef _WIN32
2929
#include <Winsock2.h>
30-
#endif /* _WIN32 */
30+
#endif //! _WIN32
3131

3232
int
3333
main(void) {
3434
#ifdef _WIN32
35-
//! Windows netword DLL init
36-
WORD version = MAKEWORD(2, 2);
37-
WSADATA data;
38-
39-
if (WSAStartup(version, &data) != 0) {
40-
std::cerr << "WSAStartup() failure" << std::endl;
41-
return -1;
42-
}
43-
#endif /* _WIN32 */
44-
45-
//! Enable logging
46-
cpp_redis::active_logger = std::unique_ptr<cpp_redis::logger>(new cpp_redis::logger);
47-
48-
cpp_redis::client client;
49-
50-
client.connect("127.0.0.1", 6379,
51-
[](const std::string &host, std::size_t port, cpp_redis::connect_state status) {
52-
if (status == cpp_redis::connect_state::dropped) {
53-
std::cout << "client disconnected from " << host << ":" << port << std::endl;
54-
}
55-
});
56-
57-
auto replcmd = [](const cpp_redis::reply &reply) {
58-
std::cout << "set hello 42: " << reply << std::endl;
59-
// if (reply.is_string())
60-
// do_something_with_string(reply.as_string())
61-
};
62-
63-
const std::string group_name = "groupone";
64-
const std::string session_name = "sessone";
65-
const std::string consumer_name = "ABCD";
66-
67-
std::multimap<std::string, std::string> ins;
68-
ins.insert(std::pair<std::string, std::string>{"message", "hello"});
35+
//! Windows netword DLL init
36+
WORD version = MAKEWORD(2, 2);
37+
WSADATA data;
38+
39+
if (WSAStartup(version, &data) != 0) {
40+
std::cerr << "WSAStartup() failure" << std::endl;
41+
return -1;
42+
}
43+
#endif //! _WIN32
44+
45+
//! Enable logging
46+
cpp_redis::active_logger =
47+
std::unique_ptr<cpp_redis::logger>(new cpp_redis::logger);
48+
49+
cpp_redis::client client;
50+
51+
client.connect("127.0.0.1",
52+
6379,
53+
[](const std::string &host,
54+
std::size_t port,
55+
cpp_redis::connect_state status) {
56+
if (status == cpp_redis::connect_state::dropped) {
57+
std::cout << "client disconnected from " << host << ":"
58+
<< port << std::endl;
59+
}
60+
});
61+
62+
auto replcmd = [](const cpp_redis::reply_t &reply) {
63+
std::cout << "set hello 42: " << reply << std::endl;
64+
// if (reply.is_string())
65+
// do_something_with_string(reply.as_string())
66+
};
67+
68+
const std::string group_name = "groupone";
69+
const std::string session_name = "sessone";
70+
const std::string consumer_name = "ABCD";
71+
72+
std::multimap<std::string, std::string> ins;
73+
ins.insert(std::pair<std::string, std::string>{"message", "hello"});
6974

7075
#ifdef ENABLE_SESSION
7176

72-
client.xadd(session_name, "*", ins, replcmd);
73-
client.xgroup_create(session_name, group_name, "0", replcmd);
74-
75-
client.sync_commit();
76-
77-
client.xrange(session_name, {"-", "+", 10}, replcmd);
78-
79-
client.xreadgroup({group_name,
80-
consumer_name,
81-
{{session_name}, {">"}},
82-
1, // Count
83-
0, // block milli
84-
false, // no ack
85-
}, [](cpp_redis::reply &reply) {
86-
std::cout << "set hello 42: " << reply << std::endl;
87-
auto msg = reply.as_array();
88-
std::cout << "Mes: " << msg[0] << std::endl;
89-
// if (reply.is_string())
90-
// do_something_with_string(reply.as_string())
91-
});
77+
client.xadd(session_name, "*", ins, replcmd);
78+
client.xgroup_create(session_name, group_name, "0", replcmd);
79+
80+
client.sync_commit();
81+
82+
client.xrange(session_name, {"-", "+", 10}, replcmd);
83+
84+
client.xreadgroup(
85+
{
86+
group_name,
87+
consumer_name,
88+
{{session_name}, {">"}},
89+
1, // Count
90+
0, // block milli
91+
false, // no ack
92+
},
93+
[](cpp_redis::reply_t &reply) {
94+
std::cout << "set hello 42: " << reply << std::endl;
95+
auto msg = reply.as_array();
96+
std::cout << "Mes: " << msg[0] << std::endl;
97+
// if (reply.is_string())
98+
// do_something_with_string(reply.as_string())
99+
});
92100

93101
#else
94102

95-
// same as client.send({ "SET", "hello", "42" }, ...)
96-
client.set("hello", "42", [](cpp_redis::reply &reply) {
97-
std::cout << "set hello 42: " << reply << std::endl;
98-
// if (reply.is_string())
99-
// do_something_with_string(reply.as_string())
100-
});
101-
102-
// same as client.send({ "DECRBY", "hello", 12 }, ...)
103-
client.decrby("hello", 12, [](cpp_redis::reply &reply) {
104-
std::cout << "decrby hello 12: " << reply << std::endl;
105-
// if (reply.is_integer())
106-
// do_something_with_integer(reply.as_integer())
107-
});
108-
109-
// same as client.send({ "GET", "hello" }, ...)
110-
client.get("hello", [](cpp_redis::reply &reply) {
111-
std::cout << "get hello: " << reply << std::endl;
112-
// if (reply.is_string())
113-
// do_something_with_string(reply.as_string())
114-
});
103+
// same as client.send({ "SET", "hello", "42" }, ...)
104+
client.set("hello", "42", [](cpp_redis::reply_t &reply) {
105+
std::cout << "set hello 42: " << reply << std::endl;
106+
// if (reply.is_string())
107+
// do_something_with_string(reply.as_string())
108+
});
109+
110+
// same as client.send({ "DECRBY", "hello", 12 }, ...)
111+
client.decrby("hello", 12, [](cpp_redis::reply_t &reply) {
112+
std::cout << "decrby hello 12: " << reply << std::endl;
113+
// if (reply.is_integer())
114+
// do_something_with_integer(reply.as_integer())
115+
});
116+
117+
// same as client.send({ "GET", "hello" }, ...)
118+
client.get("hello", [](cpp_redis::reply_t &reply) {
119+
std::cout << "get hello: " << reply << std::endl;
120+
// if (reply.is_string())
121+
// do_something_with_string(reply.as_string())
122+
});
115123

116124
#endif
117125

118-
// commands are pipelined and only sent when client.commit() is called
119-
// client.commit();
126+
// commands are pipelined and only sent when client.commit() is called
127+
// client.commit();
120128

121-
// synchronous commit, no timeout
122-
client.sync_commit();
129+
// synchronous commit, no timeout
130+
client.sync_commit();
123131

124-
// synchronous commit, timeout
125-
// client.sync_commit(std::chrono::milliseconds(100));
132+
// synchronous commit, timeout
133+
// client.sync_commit(std::chrono::milliseconds(100));
126134

127135
#ifdef _WIN32
128-
WSACleanup();
129-
#endif /* _WIN32 */
136+
WSACleanup();
137+
#endif //! _WIN32
130138

131-
return 0;
139+
return 0;
132140
}

0 commit comments

Comments
 (0)