Skip to content

Commit e7123a8

Browse files
committed
Added clang format
1 parent 66b60d6 commit e7123a8

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

run_clang_format.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
clang-format -style=file -i src/wsjcpp_sql_builder.h
4+
clang-format -style=file -i src/wsjcpp_sql_builder.cpp

src/wsjcpp_sql_builder.cpp

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* copies of the Software, and to permit persons to whom the Software is
1111
* furnished to do so, subject to the following conditions:
1212
*
13-
* The above copyright notice and this permission notice shall be included in all
14-
* copies or substantial portions of the Software.
13+
* The above copyright notice and this permission notice shall be included in
14+
*all copies or substantial portions of the Software.
1515
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -28,9 +28,8 @@
2828
// ---------------------------------------------------------------------
2929
// WsjcppSqlBuilder
3030

31-
WsjcppSqlBuilder::WsjcppSqlBuilder(
32-
WsjcppSqlBuilderType nSqlType, const std::string &sSqlTable
33-
) {
31+
WsjcppSqlBuilder::WsjcppSqlBuilder(WsjcppSqlBuilderType nSqlType,
32+
const std::string &sSqlTable) {
3433
m_nSqlType = nSqlType;
3534
m_sSqlTable = sSqlTable;
3635
m_bValid = true;
@@ -59,7 +58,8 @@ bool WsjcppSqlBuilder::sel(const std::string &sColumnName) {
5958
return true;
6059
}
6160

62-
bool WsjcppSqlBuilder::add(const std::string &sColumnName, const std::string &sValue) {
61+
bool WsjcppSqlBuilder::add(const std::string &sColumnName,
62+
const std::string &sValue) {
6363
if (!checkName(sColumnName)) {
6464
return false;
6565
}
@@ -87,8 +87,8 @@ bool WsjcppSqlBuilder::add(const std::string &sColumnName, const std::string &sV
8787
// /* Make the replacement. */
8888
// str.replace(index, 3, "def");
8989

90-
// /* Advance index forward so the next iteration doesn't pick it up as well. */
91-
// index += 3;
90+
// /* Advance index forward so the next iteration doesn't pick it up as
91+
// well. */ index += 3;
9292
// }
9393
return true;
9494
}
@@ -129,7 +129,8 @@ bool WsjcppSqlBuilder::add(const std::string &sColumnName, long nValue) {
129129
return true;
130130
}
131131

132-
bool WsjcppSqlBuilder::where(const std::string &sColumnName, const std::string &sValue) {
132+
bool WsjcppSqlBuilder::where(const std::string &sColumnName,
133+
const std::string &sValue) {
133134
if (!checkName(sColumnName)) {
134135
return false;
135136
}
@@ -183,18 +184,22 @@ std::string WsjcppSqlBuilder::getTextQuery() {
183184
if (m_nSqlType == WsjcppSqlBuilderType::SELECT) {
184185
// TODO refactor this to vector and join
185186
sSqlQuery = m_sSqlQuery0;
186-
if (size0 > 2 && m_sSqlQuery0[size0 - 1] == ' ' && m_sSqlQuery0[size0 - 2] == ',') {
187+
if (size0 > 2 && m_sSqlQuery0[size0 - 1] == ' ' &&
188+
m_sSqlQuery0[size0 - 2] == ',') {
187189
sSqlQuery += m_sSqlQuery0.substr(0, size0 - 2);
188190
}
189191
sSqlQuery += m_sSqlQuery1;
190-
if (size2 > 2 && m_sSqlQuery2[size2 - 1] == ' ' && m_sSqlQuery2[size2 - 2] == ',') {
192+
if (size2 > 2 && m_sSqlQuery2[size2 - 1] == ' ' &&
193+
m_sSqlQuery2[size2 - 2] == ',') {
191194
sSqlQuery += m_sSqlQuery2.substr(0, size2 - 2);
192195
}
193196
} else if (m_nSqlType == WsjcppSqlBuilderType::INSERT) {
194-
if (size0 > 2 && m_sSqlQuery0[size0 - 1] == ' ' && m_sSqlQuery0[size0 - 2] == ',') {
197+
if (size0 > 2 && m_sSqlQuery0[size0 - 1] == ' ' &&
198+
m_sSqlQuery0[size0 - 2] == ',') {
195199
sSqlQuery += m_sSqlQuery0.substr(0, size0 - 2);
196200
}
197-
if (size1 > 2 && m_sSqlQuery1[size1 - 1] == ' ' && m_sSqlQuery1[size1 - 2] == ',') {
201+
if (size1 > 2 && m_sSqlQuery1[size1 - 1] == ' ' &&
202+
m_sSqlQuery1[size1 - 2] == ',') {
198203
sSqlQuery += m_sSqlQuery1.substr(0, size1 - 2);
199204
}
200205
sSqlQuery += m_sSqlQuery2;
@@ -210,7 +215,8 @@ std::string WsjcppSqlBuilder::getErrorMessage() { return m_sErrorMessage; }
210215

211216
bool WsjcppSqlBuilder::checkName(const std::string &sColumnName) {
212217
if (sColumnName.size() < 2) {
213-
m_sErrorMessage = "Parameter '" + sColumnName + "' must more than 2 characters";
218+
m_sErrorMessage =
219+
"Parameter '" + sColumnName + "' must more than 2 characters";
214220
m_bValid = false;
215221
return false;
216222
}
@@ -264,16 +270,16 @@ std::string WsjcppSqlBuilder::prepareStringValue(const std::string &sValue) {
264270
// WsjcppSqlBuilderSelect
265271

266272
WsjcppSqlBuilderSelect::WsjcppSqlBuilderSelect(const std::string &sSqlTable)
267-
: WsjcppSqlBuilder(WsjcppSqlBuilderType::SELECT, sSqlTable) {}
273+
: WsjcppSqlBuilder(WsjcppSqlBuilderType::SELECT, sSqlTable) {}
268274

269275
// ---------------------------------------------------------------------
270276
// WsjcppSqlBuilderInsert
271277

272278
WsjcppSqlBuilderInsert::WsjcppSqlBuilderInsert(const std::string &sSqlTable)
273-
: WsjcppSqlBuilder(WsjcppSqlBuilderType::INSERT, sSqlTable) {}
279+
: WsjcppSqlBuilder(WsjcppSqlBuilderType::INSERT, sSqlTable) {}
274280

275281
// ---------------------------------------------------------------------
276282
// WsjcppSqlBuilderUpdate
277283

278284
WsjcppSqlBuilderUpdate::WsjcppSqlBuilderUpdate(const std::string &sSqlTable)
279-
: WsjcppSqlBuilder(WsjcppSqlBuilderType::UPDATE, sSqlTable) {}
285+
: WsjcppSqlBuilder(WsjcppSqlBuilderType::UPDATE, sSqlTable) {}

src/wsjcpp_sql_builder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* copies of the Software, and to permit persons to whom the Software is
1111
* furnished to do so, subject to the following conditions:
1212
*
13-
* The above copyright notice and this permission notice shall be included in all
14-
* copies or substantial portions of the Software.
13+
* The above copyright notice and this permission notice shall be included in
14+
*all copies or substantial portions of the Software.
1515
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

0 commit comments

Comments
 (0)