Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Exclude InfluxDB::query() if boost is not found (#46)
Browse files Browse the repository at this point in the history
* Exclude InfluxDB::query() if boost is not found

* Fix detectoing boost in query method

Co-authored-by: Adam Wegrzynek <[email protected]>
  • Loading branch information
rstephan and awegrzyn committed Jan 9, 2020
1 parent e844661 commit 1d069ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,15 @@ set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include")

set(SRCS
# Create library
add_library(InfluxDB SHARED
src/InfluxDB.cxx
src/Point.cxx
src/InfluxDBFactory.cxx
$<$<BOOL:${Boost_FOUND}>:src/UDP.cxx>
$<$<BOOL:${Boost_FOUND}>:src/UnixSocket.cxx>
src/HTTP.cxx
)

# Create library
add_library(InfluxDB SHARED ${SRCS})
target_include_directories(InfluxDB
PUBLIC
$<INSTALL_INTERFACE:include>
Expand Down
10 changes: 10 additions & 0 deletions src/InfluxDB.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
#include <iostream>
#include <memory>
#include <string>

#ifdef INFLUXDB_WITH_BOOST
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#endif

namespace influxdb
{
Expand Down Expand Up @@ -73,6 +76,7 @@ void InfluxDB::write(Point&& metric)
}
}

#ifdef INFLUXDB_WITH_BOOST
std::vector<Point> InfluxDB::query(const std::string& query)
{
auto response = mTransport->query(query);
Expand Down Expand Up @@ -112,5 +116,11 @@ std::vector<Point> InfluxDB::query(const std::string& query)
}
return points;
}
#else
std::vector<Point> InfluxDB::query(const std::string& /*query*/)
{
throw std::runtime_error("InfluxDB query() requires boost");
}
#endif

} // namespace influxdb

0 comments on commit 1d069ff

Please sign in to comment.