Skip to content

Commit

Permalink
CONFIG: prefix include files with "bxzstr_" to avoid name clashes (fixes
Browse files Browse the repository at this point in the history
 tmaklin#27)

- place strict_fstream into bxzstr namespace to avoid name clashes
  • Loading branch information
olesenm committed Jun 10, 2024
1 parent 6c426ef commit aaa2e56
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ else()
endif()
endif()

configure_file(include/config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/config.hpp @ONLY)
configure_file(include/bxzstr_config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/bxzstr_config.hpp @ONLY)

if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Wpedantic")
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ be turned on.

## Configuration
You can use the library without one of libz, libbz2, or liblzma by
modifying the `config.hpp` file. For example, to disable lzma support,
set BXZSTR_LZMA_SUPPORT to 0:
modifying the `bxzstr_config.hpp` file by undefining the corresponding
entry or setting it to zero (whichever you prefer).
For example, to disable lzma and zstd support:
```
#ifndef BXZSTR_CONFIG_HPP
#define BXZSTR_CONFIG_HPP
#define BXZSTR_Z_SUPPORT 1
#define BXZSTR_BZ2_SUPPORT 1
#define BXZSTR_LZMA_SUPPORT 0
#define BXZSTR_ZSTD_SUPPORT 0
#undef BXZSTR_ZSTD_SUPPORT
#endif
```
Expand All @@ -79,7 +80,7 @@ e. g. as part of a larger project, by running
```
cmake .
```
in the root directory. CMake will modify `config.hpp` to match the
in the root directory. CMake will modify `bxzstr_config.hpp` to match the
libraries supported on the system. If the
[find_package](https://cmake.org/cmake/help/v3.0/command/find_package.html)
command has already been run in CMake, automatic configuration will
Expand Down
8 changes: 4 additions & 4 deletions include/bxzstr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file from the zstr project (https://github.com/mateidavid/zstr)
* written by Matei David (https://github.com/mateidavid). */

#include "config.hpp"
#include "bxzstr_config.hpp"

#ifndef BXZSTR_BXZSTR_HPP
#define BXZSTR_BXZSTR_HPP
Expand All @@ -16,9 +16,9 @@
#include <memory>
#include <stdexcept>

#include "stream_wrapper.hpp"
#include "strict_fstream.hpp"
#include "compression_types.hpp"
#include "bxzstr_stream_wrapper.hpp"
#include "bxzstr_strict_fstream.hpp"
#include "bxzstr_compression_types.hpp"

namespace bxz {
class istreambuf : public std::streambuf {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <sstream>
#include <exception>

#include "stream_wrapper.hpp"
#include "bxzstr_stream_wrapper.hpp"

namespace bxz {
/// Exception class thrown by failed bzlib operations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

#include <exception>

#include "stream_wrapper.hpp"
#include "bz_stream_wrapper.hpp"
#include "lzma_stream_wrapper.hpp"
#include "z_stream_wrapper.hpp"
#include "zstd_stream_wrapper.hpp"
#include "bxzstr_stream_wrapper.hpp"
#include "bxzstr_bz_stream.hpp"
#include "bxzstr_lzma_stream.hpp"
#include "bxzstr_z_stream.hpp"
#include "bxzstr_zstd_stream.hpp"

namespace bxz {
enum Compression { z, bz2, lzma, zstd, plaintext };
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <sstream>
#include <exception>

#include "stream_wrapper.hpp"
#include "bxzstr_stream_wrapper.hpp"

namespace bxz {
/// Exception class thrown by failed liblzma operations.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include <cstring>
#include <string>

// Place strict_fstream into bxzstr namespace to avoid any clashes
namespace bxz {

/**
* This namespace defines wrappers for std::ifstream, std::ofstream, and
* std::fstream objects. The wrappers perform the following steps:
Expand Down Expand Up @@ -206,4 +209,6 @@ class fstream

} // namespace strict_fstream

} // namespace bxzstr

#endif
4 changes: 2 additions & 2 deletions include/z_stream_wrapper.hpp → include/bxzstr_z_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <sstream>
#include <exception>

#include "stream_wrapper.hpp"
#include "bxzstr_stream_wrapper.hpp"

namespace bxz {
/// Exception class thrown by failed zlib operations.
Expand Down Expand Up @@ -108,7 +108,7 @@ class z_stream_wrapper : public z_stream, public stream_wrapper {
private:
bool is_input;
int ret;
}; // class bz_stream_wrapper
}; // class z_stream_wrapper
} // namespace detail
} // namespace bxz

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <string>
#include <exception>

#include "stream_wrapper.hpp"
#include "bxzstr_stream_wrapper.hpp"

namespace bxz {
/// Exception class thrown by failed zstd operations.
Expand Down

0 comments on commit aaa2e56

Please sign in to comment.