Skip to content

Commit d302035

Browse files
committed
Use anonymous namespace for internal linkage
1 parent 0f106b4 commit d302035

File tree

8 files changed

+45
-13
lines changed

8 files changed

+45
-13
lines changed

test/t/complex/reader_test_cases.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,9 @@ TEST_CASE("write complex data using pbf_builder: all") {
616616
REQUIRE(number_of_u == 5);
617617
}
618618

619-
static void check_message(const std::string& buffer) {
619+
namespace {
620+
621+
void check_message(const std::string& buffer) {
620622
protozero::pbf_reader item{buffer};
621623

622624
while (item.next()) {
@@ -640,6 +642,8 @@ static void check_message(const std::string& buffer) {
640642
}
641643
}
642644

645+
} // anonymous namespace
646+
643647
TEST_CASE("write complex with subwriter using pbf_writer") {
644648
std::string buffer_test;
645649
protozero::pbf_writer pbf_test{buffer_test};

test/t/nested/reader_test_cases.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
#include <test.hpp>
33

4-
inline void check_subsub(protozero::pbf_reader message) {
4+
namespace {
5+
6+
void check_subsub(protozero::pbf_reader message) {
57
while (message.next()) {
68
switch (message.tag()) {
79
case 1: {
@@ -20,7 +22,7 @@ inline void check_subsub(protozero::pbf_reader message) {
2022
}
2123
}
2224

23-
inline void check_sub(protozero::pbf_reader message) {
25+
void check_sub(protozero::pbf_reader message) {
2426
while (message.next()) {
2527
switch (message.tag()) {
2628
case 1: {
@@ -39,7 +41,7 @@ inline void check_sub(protozero::pbf_reader message) {
3941
}
4042
}
4143

42-
inline void check(protozero::pbf_reader message) {
44+
void check(protozero::pbf_reader message) {
4345
while (message.next()) {
4446
switch (message.tag()) {
4547
case 1: {
@@ -58,7 +60,7 @@ inline void check(protozero::pbf_reader message) {
5860
}
5961
}
6062

61-
inline void check_empty(protozero::pbf_reader message) {
63+
void check_empty(protozero::pbf_reader message) {
6264
while (message.next()) {
6365
switch (message.tag()) {
6466
case 1: {
@@ -77,6 +79,8 @@ inline void check_empty(protozero::pbf_reader message) {
7779
}
7880
}
7981

82+
} // anonymous namespace
83+
8084
TEST_CASE("read nested message fields: string") {
8185
const std::string buffer = load_data("nested/data-message");
8286

test/t/tag_and_type/reader_test_cases.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
#include <test.hpp>
99

10+
namespace {
11+
1012
enum class ExampleMsg : protozero::pbf_tag_type {
1113
repeated_uint32_x = 1
1214
};
1315

14-
inline std::vector<uint32_t> read_data(const std::string& data) {
16+
std::vector<uint32_t> read_data(const std::string& data) {
1517
std::vector<uint32_t> values;
1618

1719
protozero::pbf_message<ExampleMsg> message{data};
@@ -35,7 +37,7 @@ inline std::vector<uint32_t> read_data(const std::string& data) {
3537
return values;
3638
}
3739

38-
inline std::vector<uint32_t> read_data_packed(const std::string& data) {
40+
std::vector<uint32_t> read_data_packed(const std::string& data) {
3941
std::vector<uint32_t> values;
4042

4143
protozero::pbf_message<ExampleMsg> message{data};
@@ -47,6 +49,8 @@ inline std::vector<uint32_t> read_data_packed(const std::string& data) {
4749
return values;
4850
}
4951

52+
} // anonymous namespace
53+
5054
TEST_CASE("read not packed repeated field with tag_and_type") {
5155
const auto values = read_data(load_data("tag_and_type/data-not-packed"));
5256

test/t/tags/reader_test_cases.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
#include <test.hpp>
33

4-
inline void check_tag(const std::string& buffer, protozero::pbf_tag_type tag) {
4+
namespace {
5+
6+
void check_tag(const std::string& buffer, protozero::pbf_tag_type tag) {
57
protozero::pbf_reader item{buffer};
68

79
REQUIRE(item.next());
@@ -10,6 +12,8 @@ inline void check_tag(const std::string& buffer, protozero::pbf_tag_type tag) {
1012
REQUIRE_FALSE(item.next());
1113
}
1214

15+
} // anonymous namespace
16+
1317
TEST_CASE("read tag: 1") {
1418
check_tag(load_data("tags/data-tag-1"), 1UL);
1519
}

test/t/vector_tile/reader_test_cases.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
#include <string>
55
#include <vector>
66

7+
namespace {
8+
79
// Input data.vector is encoded according to
810
// https://github.com/mapbox/mapnik-vector-tile/blob/master/proto/vector_tile.proto
911

10-
static std::string get_name(protozero::pbf_reader layer) { // copy!
12+
std::string get_name(protozero::pbf_reader layer) { // copy!
1113
while (layer.next(1)) { // required string name
1214
return layer.get_string();
1315
}
1416
REQUIRE(false); // should never be here
1517
return "";
1618
}
1719

20+
} // anonymous namespace
21+
1822
TEST_CASE("reading vector tiles") {
1923
static const std::vector<std::string> expected_layer_names = {
2024
"landuse", "waterway", "water", "aeroway", "barrier_line", "building",

test/unit/test_endian.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@
66

77
#include <protozero/byteswap.hpp>
88

9-
static int32_t check_swap_4(int32_t data) noexcept {
9+
namespace {
10+
11+
int32_t check_swap_4(int32_t data) noexcept {
1012
protozero::byteswap_inplace(&data);
1113
protozero::byteswap_inplace(&data);
1214
return data;
1315
}
1416

15-
static int64_t check_swap_8(int64_t data) noexcept {
17+
int64_t check_swap_8(int64_t data) noexcept {
1618
protozero::byteswap_inplace(&data);
1719
protozero::byteswap_inplace(&data);
1820
return data;
1921
}
2022

23+
} // anonymous namespace
24+
2125
TEST_CASE("byte swapping") {
2226
REQUIRE(0 == check_swap_4(0));
2327
REQUIRE(1 == check_swap_4(1));

test/unit/test_zigzag.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ static_assert(protozero::decode_zigzag64(0xfffffffffffffffdULL) == -0x7fffffffff
3939
static_assert(protozero::decode_zigzag64(2 * static_cast<uint64_t>(std::numeric_limits<int64_t>::max()) ) == std::numeric_limits<int64_t>::max(), "test constexpr zigzag functions");
4040
static_assert(protozero::decode_zigzag64(2 * static_cast<uint64_t>(std::numeric_limits<int64_t>::max()) - 1) == -std::numeric_limits<int64_t>::max(), "test constexpr zigzag functions");
4141

42-
inline constexpr int32_t zz32(int32_t val) noexcept {
42+
namespace {
43+
44+
constexpr int32_t zz32(int32_t val) noexcept {
4345
return protozero::decode_zigzag32(protozero::encode_zigzag32(val));
4446
}
4547

46-
inline constexpr int64_t zz64(int64_t val) noexcept {
48+
constexpr int64_t zz64(int64_t val) noexcept {
4749
return protozero::decode_zigzag64(protozero::encode_zigzag64(val));
4850
}
4951

52+
} // anonymous namespace
53+
5054
TEST_CASE("zigzag encode some 32 bit values") {
5155
REQUIRE(protozero::encode_zigzag32( 0L) == 0UL);
5256
REQUIRE(protozero::encode_zigzag32(-1L) == 1UL);

tools/pbf-decoder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Call with --help/-h to see more options.
3333
#include <stdexcept>
3434
#include <string>
3535

36+
namespace {
37+
3638
std::string decode(const char* data, std::size_t len, const std::string& indent);
3739

3840
// Try decoding as a nested message
@@ -203,6 +205,8 @@ std::string read_from_stdin() {
203205
std::istreambuf_iterator<char>()};
204206
}
205207

208+
} // anonymous namespace
209+
206210
int main(int argc, char* argv[]) {
207211
static struct option long_options[] = {
208212
{"help", no_argument, nullptr, 'h'},

0 commit comments

Comments
 (0)