8000 Fix typos and issues and code smells · VXAPPS/sqlite_functions@1017ea6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1017ea6

Browse files
committed
Fix typos and issues and code smells
1 parent 23dfba4 commit 1017ea6

File tree

11 files changed

+81
-30
lines changed

11 files changed

+81
-30
lines changed

.clang-format

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ BraceWrapping:
4242
SplitEmptyFunction: 'false'
4343
SplitEmptyRecord: 'false'
4444
SplitEmptyNamespace: 'false'
45-
46-
BreakBeforeConceptDeclarations: Always
45+
46+
BreakBeforeConceptDeclarations: Always
4747
BreakBeforeTernaryOperators: 'true'
4848
BreakConstructorInitializers: BeforeColon
4949
BreakInheritanceList: BeforeColon

cmake/clang_warnings.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ set(WARNING_FLAGS
3838
-Wno-c++98-compat # C++11
3939
-Wno-c++98-compat-pedantic # C++11
4040
-Wno-padded
41+
42+
-Wno-unsafe-buffer-usage-in-container
4143
)
4244

4345
foreach(WARNING_FLAG ${WARNING_FLAGS})

cmake/external/icu.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ else()
5454
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
5555
set(ICU_ARCH )
5656
else()
57-
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES arm)
57+
if(MSVC_CXX_ARCHITECTURE_ID MATCHES ARM64)
5858
set(ICU_ARCH ARM64)
5959
else()
6060
set(ICU_ARCH 64)

examples/distance/main.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
2828
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
/* c header */
32+
#include <cstdint> // std::int32_t
33+
#include <cstdlib> // EXIT_FAILURE, EXIT_SUCCESS
34+
3135
/* stl header */
32-
#include <codecvt>
3336
#include <iomanip>
3437
#include <iostream>
3538
#include <limits>
3639
#include <me 67E6 mory>
37-
#include <numeric>
40+
#include <string>
41+
#include <system_error>
3842

3943
/* sqlite header */
4044
#include <sqlite3.h>
@@ -53,15 +57,18 @@
5357
* Tokyo | 35.6839 | 139.7744
5458
*/
5559

56-
static std::int32_t printResultAndExit( std::int32_t _code,
57-
const std::string &_message,
58-
const std::string &_sql ) {
60+
namespace {
61+
62+
std::int32_t printResultAndExit( std::int32_t _code,
63+
const std::string &_message,
64+
const std::string &_sql ) {
5965

60-
std::cout << "RESULT CODE: (" << _code << ")" << std::endl;
61-
std::cout << "ERROR: '" << _message << "'" << std::endl;
62-
std::cout << "SQL: '" << _sql << "'" << std::endl;
63-
std::cout << std::endl;
64-
return EXIT_FAILURE;
66+
std::cout << "RESULT CODE: (" << _code << ")" << std::endl;
67+
std::cout << "ERROR: '" << _message << "'" << std::endl;
68+
std::cout << "SQL: '" << _sql << "'" << std::endl;
69+
std::cout << std::endl;
70+
return EXIT_FAILURE;
71+
}
6572
}
6673

6774
std::int32_t main() {

examples/memory_attach/main.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
/* c header */
32+
#include <cstdint> // std::int32_t
33+
#include <cstdlib> // EXIT_FAILURE, EXIT_SUCCESS
34+
3135
/* stl header */
32-
#include <codecvt>
33-
#include <fstream>
3436
#include <iostream>
35-
#include <locale>
3637
#include <memory>
37-
#include <vector>
38+
#include <string>
39+
#include <system_error>
3840

3941
/* sqlite header */
4042
#include <sqlite3.h>
@@ -64,15 +66,18 @@
6466
* Melbourne | -37.8136 | 144.9631
6567
*/
6668

67-
static std::int32_t printResultAndExit( std::int32_t _code,
68-
const std::string &_message,
69-
const std::string &_sql ) {
69+
namespace {
70+
71+
std::int32_t printResultAndExit( std::int32_t _code,
72+
const std::string &_message,
73+
const std::string &_sql ) {
7074

71-
std::cout << "RESULT CODE: (" << _code << ")" << std::endl;
72-
std::cout << "ERROR: '" << _message << "'" << std::endl;
73-
std::cout << "SQL: '" << _sql << "'" << std::endl;
74-
std::cout << std::endl;
75-
return EXIT_FAILURE;
75+
std::cout << "RESULT CODE: (" << _code << ")" << std::endl;
76+
std::cout << "ERROR: '" << _message << "'" << std::endl;
77+
std::cout << "SQL: '" << _sql << "'" << std::endl;
78+
std::cout << std::endl;
79+
return EXIT_FAILURE;
80+
}
7681
}
7782

7883
std::int32_t main() {

source/SqliteError.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@
3030

3131
#pragma once
3232

33+
/* c header */
34+
#include <cstdint> // std::int32_t
35+
3336
/* stl header */
3437
#include <string>
3538
#include <string_view>
3639
#include <system_error>
40+
#include <type_traits>
3741

3842
/* modern.cpp.core */
3943
#include <Singleton.h>

source/SqliteUtils.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,35 @@
3030

3131
/* c header */
3232
#include <cmath>
33+
#include <cstdint> // std::int32_t
3334
#include <cstring> // std::memcpy
3435

3536
/* stl header */
3637
#include <filesystem>
3738
#include <fstream>
39+
#include <iosfwd>
3840
#include <iostream>
41+
#include <memory>
3942
#include <numeric>
43+
#include <optional>
4044
#if __cplusplus > 201703L && ( defined __GNUC__ && __GNUC__ >= 10 || defined _MSC_VER && _MSC_VER >= 1926 || defined __clang__ && __clang_major__ >= 10 )
4145
#include <span>
4246
#endif
47+
#include <string>
48+
#include <system_error>
4349
#include <vector>
4450

4551
/* sqlite header */
4652
#include <sqlite3.h>
4753

4854
/* icu header */
55+
#include <unicode/stringpiece.h>
4956
#include <unicode/translit.h>
5057
#include <unicode/unistr.h>
58+
#include <unicode/utrans.h>
59+
#include <unicode/utypes.h>
5160

5261
/* modern.cpp.core */
53-
#include <Logger.h>
5462
#include <StringUtils.h>
5563

5664
/* local header */
@@ -272,11 +280,14 @@ namespace vx::sqlite_utils {
272280
return {};
273281
}
274282

275-
/**
283+
namespace {
284+
285+
/**
276286
* @brief Generate own PI.
277287
* @return Calculated pi value.
278288
*/
279-
static double pi() { return std::atan( 1 ) * 4; }
289+
double pi() { return std::atan( 1 ) * 4; }
290+
}
280291

281292
void distance( sqlite3_context *_context,
282293
std::int32_t _argc,

source/SqliteUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
#pragma once
3232

33+
/* c header */
34+
#include <cstdint> // std::int32_t
35+
3336
/* stl header */
3437
#include <memory>
3538
#include <string>

tests/test_distance.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,18 @@
2828
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
/* c header */
32+
#include <cstdint> // std::int32_t
33+
3134
/* gtest header */
3235
#include <gtest/gtest.h>
3336

3437
/* sqlite header */
3538
#include <sqlite3.h>
3639

40+
/* stl header */
41+
#include <system_error>
42+
3743
/* sqlite_functions */
3844
#include <SqliteUtils.h>
3945

tests/test_dump.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,20 @@
2828
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
/* stl header */
32-
#include <filesystem>
31+
/* c header */
32+
#include <cstdint> // std::int32_t
3333

3434
/* gtest header */
3535
#include <gtest/gtest.h>
3636

3737
/* sqlite header */
3838
#include <sqlite3.h>
3939

40+
/* stl header */
41+
#include <filesystem>
42+
#include <string_view>
43+
#include <system_error>
44+
4045
/* sqlite_functions */
4146
#include <SqliteUtils.h>
4247

tests/test_transliteration.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,20 @@
2828
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
/* c header */
32+
#include <cstdint> // std::int32_t
33+
3134
/* gtest header */
3235
#include <gtest/gtest.h>
3336

3437
/* sqlite header */
3538
#include <sqlite3.h>
3639

40+
/* stl header */
41+
#include <optional>
42+
#include <system_error>
43+
#include <vector>
44+
3745
/* modern.cpp.core */
3846
#include <StringUtils.h>
3947

0 commit comments

Comments
 (0)
0