Skip to content

Commit

Permalink
Changed namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
crosscode-nl committed Nov 16, 2020
1 parent fade368 commit a7ae9c9
Show file tree
Hide file tree
Showing 31 changed files with 44 additions and 35 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.8.2)

project(influxdblptool
VERSION 1.1.0
VERSION 2.0.0
#DESCRIPTION "InfluxDb Line Protocol Tool"
LANGUAGES C CXX)

Expand Down
2 changes: 1 addition & 1 deletion examples/example01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// By default the current timestamp is added with a nanosecond resolution.
// The point can be serialized to an ostream.
int main() {
using namespace influxdblptool;
using namespace crosscode::influxdblptool;
std::cout << point{"measurement",field{"field_key","field_value"}};
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/example02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//
// Overloads of the value parameter of the field constructor exist to convert from C++ types that don't cause narrowing.
int main() {
using namespace influxdblptool;
using namespace crosscode::influxdblptool;
point pt{"measurement",field{"string","string value"}};
pt << field{"double",1.5};
pt << field{"bool",true};
Expand Down
2 changes: 1 addition & 1 deletion examples/example03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// The point is augmented with a tag. One or more tags can be added.
// A tag is something you would like to filter on in InfluxDB.
int main() {
using namespace influxdblptool;
using namespace crosscode::influxdblptool;
point pt{"measurement",field{"field_key","field_value"}};
pt << tag{"tag_key1","tag_value1"} << tag{"tag_key2","tag_value2"};
std::cout << pt;
Expand Down
2 changes: 1 addition & 1 deletion examples/example04.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// When a point does not have a timestamp it will get a timestamp of the current time when it is inserted into InfluxDB.
int main() {
using namespace influxdblptool;
using namespace crosscode::influxdblptool;
using namespace std::literals;

point pt{"measurement",field{"field_key","field_value"}};
Expand Down
2 changes: 1 addition & 1 deletion examples/example05.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// You can use chrono::duration to set a timestamp since epoch (1970-01-01 00:00:00 UTC)
int main() {
using namespace influxdblptool;
using namespace crosscode::influxdblptool;
using namespace std::literals;

point pt1{"measurement",field{"field_key","field_value"}};
Expand Down
2 changes: 1 addition & 1 deletion examples/example06.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// The insert prefix can be used for loading the data via the CLI. https://docs.influxdata.com/influxdb/v1.8/tools/shell/
int main() {
using namespace influxdblptool;
using namespace crosscode::influxdblptool;
using namespace std::literals;

point ptn{"measurement",field{"field_key","field_value"}};
Expand Down
2 changes: 1 addition & 1 deletion examples/example07.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// The insert prefix can be used for loading the data via the CLI. https://docs.influxdata.com/influxdb/v1.8/tools/shell/
int main() {
using namespace influxdblptool;
using namespace crosscode::influxdblptool;

point pt{"measurement",field{"field_key","field_value"}};
pt << insert_prefix;
Expand Down
2 changes: 1 addition & 1 deletion examples/example08.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// in the collection. It makes no sense to individually change these settings per point, and when you do so
// it will not have an effect.

using namespace influxdblptool;
using namespace crosscode::influxdblptool;

point make_point() {
return (point{"measurement",field{"field_string","field_string_value"}}
Expand Down
2 changes: 1 addition & 1 deletion examples/example09.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
// See validators.cpp or InfluxDB documentation for all possible invalid input.

using namespace influxdblptool;
using namespace crosscode::influxdblptool;

int main() {
using namespace std::literals;
Expand Down
2 changes: 1 addition & 1 deletion examples/example10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// Serialization can be achieved using the output stream operator, but to_string method is also supported.

using namespace influxdblptool;
using namespace crosscode::influxdblptool;

int main() {
using namespace std::literals;
Expand Down
2 changes: 1 addition & 1 deletion include/influxdblptool/collections.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "string_types.h"
#include "field_value.h"

namespace influxdblptool {
namespace crosscode::influxdblptool {

/// tags_map is an alias of std::map<tag_key, tag_value>
using tags_map = std::map<tag_key, tag_value>;
Expand Down
2 changes: 1 addition & 1 deletion include/influxdblptool/escapers.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <array>

/// The escapers namespace contains all escapers. It is internally used by this library.
namespace influxdblptool::escapers {
namespace crosscode::influxdblptool::escapers {

/// Escapes a string_view to become an acceptable input as a measurement.
/// Escapes commas and spaces.
Expand Down
2 changes: 1 addition & 1 deletion include/influxdblptool/field_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <variant>
#include "string_types.h"

namespace influxdblptool {
namespace crosscode::influxdblptool {

/// The traits namespace contains all custom type traits. It is internally used by this library.
namespace traits {
Expand Down
2 changes: 1 addition & 1 deletion include/influxdblptool/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <optional>

/// This is the main namespace. Users of this library only need to use this namespace.
namespace influxdblptool {
namespace crosscode::influxdblptool {

/// \brief The option_timestamp can be used to provide a time_point or nothing.
///
Expand Down
2 changes: 1 addition & 1 deletion include/influxdblptool/serializers.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "string_types.h"
#include "point.h"

namespace influxdblptool {
namespace crosscode::influxdblptool {

std::ostream& operator<<(std::ostream& s, const tag_key& tk);
std::ostream& operator<<(std::ostream& s, const tag_value& tv);
Expand Down
2 changes: 1 addition & 1 deletion include/influxdblptool/string_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "influxdblptool/validators.h"
#include "influxdblptool/escapers.h"

namespace influxdblptool {
namespace crosscode::influxdblptool {

namespace intern {

Expand Down
2 changes: 1 addition & 1 deletion include/influxdblptool/validators.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdexcept>


namespace influxdblptool {
namespace crosscode::influxdblptool {

class validator_exception : public std::invalid_argument {
using std::invalid_argument::invalid_argument;
Expand Down
6 changes: 5 additions & 1 deletion include/influxdblptool/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
#define INFLUXDBLPTOOL_VERSION_H
#include <string_view>

namespace crosscode::influxdblptool {

/// Get the semver version of this library. See: https://www.semver.org
/// \return A std::string_view containing the a semver formatted version of this library
std::string_view version();
std::string_view version();

}

#endif //INFLUXDBLPTOOL_VERSION_H
2 changes: 1 addition & 1 deletion src/influxdblptool/escapers.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "influxdblptool/escapers.h"
#include <numeric>

namespace influxdblptool::escapers {
namespace crosscode::influxdblptool::escapers {

template <char... Ch>
std::size_t escape_count(std::string_view input) {
Expand Down
2 changes: 1 addition & 1 deletion src/influxdblptool/field_value.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "influxdblptool/field_value.h"

namespace influxdblptool {
namespace crosscode::influxdblptool {

field_double::field_double(double value) : value_(value) {
validators::throw_when_double_value_invalid(value_);
Expand Down
2 changes: 1 addition & 1 deletion src/influxdblptool/point.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "influxdblptool/point.h"

namespace influxdblptool {
namespace crosscode::influxdblptool {

using namespace std::literals;

Expand Down
2 changes: 1 addition & 1 deletion src/influxdblptool/serializers.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "influxdblptool/serializers.h"

namespace influxdblptool {
namespace crosscode::influxdblptool {

std::ostream& serialize_timepoint(std::ostream& s, const std::chrono::system_clock::time_point& timePoint, timestamp_resolution tr) {
// This assumes that epoch is 1970-01-01T00:00:00Z, which it probably is in case of a system_clock. However,
Expand Down
2 changes: 1 addition & 1 deletion src/influxdblptool/validators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <cmath>
#include <string>

namespace influxdblptool::validators {
namespace crosscode::influxdblptool::validators {

using namespace std::literals;
using namespace influxdblptool;
Expand Down
4 changes: 4 additions & 0 deletions src/influxdblptool/version.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

using namespace std::literals;

namespace crosscode::influxdblptool {

std::string_view version() {
constexpr std::string_view version_value = "@influxdblptool_VERSION@"sv;
return version_value;
}

}
2 changes: 1 addition & 1 deletion tests/escapers_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace std::literals;
* Field value = Double quote, Backslash
*/

using namespace influxdblptool::escapers;
using namespace crosscode::influxdblptool::escapers;
TEST_SUITE("escapers") {
TEST_CASE("escape_measurement_value escapes: Comma, Space")
{
Expand Down
2 changes: 1 addition & 1 deletion tests/field_value_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "influxdblptool/field_value.h"

using namespace std::literals;
using namespace influxdblptool;
using namespace crosscode::influxdblptool;

TEST_SUITE("field_value") {
TEST_CASE("field_double works correctly") {
Expand Down
2 changes: 1 addition & 1 deletion tests/serializers_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "influxdblptool/serializers.h"

using namespace std::literals;
using namespace influxdblptool;
using namespace crosscode::influxdblptool;

std::chrono::system_clock::time_point fake_now() {
return std::chrono::system_clock::time_point{1s};
Expand Down
12 changes: 6 additions & 6 deletions tests/string_types_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#include "doctest.h"
#include "influxdblptool/string_types.h"

using namespace influxdblptool;
using namespace crosscode::influxdblptool;
using namespace std::literals;

const int KB = 1024;

TEST_SUITE("string_types_tests") {

static_assert(std::is_same_v<tag_key,influxdblptool::intern::validated_string<validators::throw_when_tag_key_invalid>>);
static_assert(std::is_same_v<tag_value,influxdblptool::intern::validated_string<validators::throw_when_tag_value_invalid>>);
static_assert(std::is_same_v<field_key,influxdblptool::intern::validated_string<validators::throw_when_field_key_invalid>>);
static_assert(std::is_same_v<field_string_value,influxdblptool::intern::validated_string<validators::throw_when_field_string_value_invalid>>);
static_assert(std::is_same_v<measurement_value,influxdblptool::intern::validated_string<validators::throw_when_measurement_invalid>>);
static_assert(std::is_same_v<tag_key,crosscode::influxdblptool::intern::validated_string<validators::throw_when_tag_key_invalid>>);
static_assert(std::is_same_v<tag_value,crosscode::influxdblptool::intern::validated_string<validators::throw_when_tag_value_invalid>>);
static_assert(std::is_same_v<field_key,crosscode::influxdblptool::intern::validated_string<validators::throw_when_field_key_invalid>>);
static_assert(std::is_same_v<field_string_value,crosscode::influxdblptool::intern::validated_string<validators::throw_when_field_string_value_invalid>>);
static_assert(std::is_same_v<measurement_value,crosscode::influxdblptool::intern::validated_string<validators::throw_when_measurement_invalid>>);
static_assert(std::is_same_v<measurement,measurement_value>);
TEST_CASE("measurement")
{
Expand Down
4 changes: 2 additions & 2 deletions tests/validators_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <algorithm>
#include <string>

using namespace influxdblptool;
using namespace influxdblptool::validators;
using namespace crosscode::influxdblptool;
using namespace crosscode::influxdblptool::validators;

const int KB = 1024;

Expand Down
1 change: 1 addition & 0 deletions tests/version_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "influxdblptool/version.h"
#include <regex>
using namespace std::literals;
using namespace crosscode::influxdblptool;

TEST_SUITE("version") {
TEST_CASE ("Test if version is valid semver") {
Expand Down

0 comments on commit a7ae9c9

Please sign in to comment.