Skip to content

Commit

Permalink
Get headers under control, at last.
Browse files Browse the repository at this point in the history
Fold `compiler-public.hxx` into `header-pre.hxx`.  Make all internal
`#include`s use the `.hxx` versions of the headers.  Forbid nesting of
`header-pre.hxx`/`header-post.hxx`.

This should make things a bit more regular and easier to understand,
apart from the fact that libpqxx code now sets a bad example for
including the `<pqxx/*>`-style headers, because internally it uses the
`<pqxx/*.hxx>`-style ones.  It may save a bit of compile time as well.

One thing I still expect to go wrong: it looks as if clang-tidy reorders
includes that are not separated by blank lines, alphabetically.  That's
great, except things like `header-pre.hxx` and `header-post.hxx` get put
in weird places and that explains a lot of the trouble I've run into.
  • Loading branch information
jtv committed Mar 19, 2022
1 parent 345049d commit 20fc436
Show file tree
Hide file tree
Showing 111 changed files with 378 additions and 383 deletions.
1 change: 0 additions & 1 deletion include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ nobase_include_HEADERS= pqxx/pqxx \
pqxx/version pqxx/version.hxx \
pqxx/internal/array-composite.hxx \
pqxx/internal/callgate.hxx \
pqxx/internal/compiler-public.hxx \
pqxx/internal/concat.hxx \
pqxx/internal/conversions.hxx \
pqxx/internal/encoding_group.hxx \
Expand Down
1 change: 0 additions & 1 deletion include/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ nobase_include_HEADERS = pqxx/pqxx \
pqxx/version pqxx/version.hxx \
pqxx/internal/array-composite.hxx \
pqxx/internal/callgate.hxx \
pqxx/internal/compiler-public.hxx \
pqxx/internal/concat.hxx \
pqxx/internal/conversions.hxx \
pqxx/internal/encoding_group.hxx \
Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/array
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/array.hxx"

#include "pqxx/internal/header-post.hxx"
8 changes: 4 additions & 4 deletions include/pqxx/array.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
#ifndef PQXX_H_ARRAY
#define PQXX_H_ARRAY

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

#include "pqxx/internal/encoding_group.hxx"
#include "pqxx/internal/encodings.hxx"

#include <stdexcept>
#include <string>
#include <utility>

#include "pqxx/internal/encoding_group.hxx"
#include "pqxx/internal/encodings.hxx"


namespace pqxx
{
Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/binarystring
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/binarystring.hxx"

#include "pqxx/internal/header-post.hxx"
2 changes: 1 addition & 1 deletion include/pqxx/binarystring.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef PQXX_H_BINARYSTRING
#define PQXX_H_BINARYSTRING

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/blob
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/blob.hxx"

#include "pqxx/internal/header-post.hxx"
2 changes: 1 addition & 1 deletion include/pqxx/blob.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef PQXX_H_BLOB
#define PQXX_H_BLOB

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/composite
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/composite.hxx"

#include "pqxx/internal/header-post.hxx"
2 changes: 1 addition & 1 deletion include/pqxx/composite.hxx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PQXX_H_COMPOSITE
#define PQXX_H_COMPOSITE

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/connection
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/connection.hxx"

#include "pqxx/internal/header-post.hxx"
2 changes: 1 addition & 1 deletion include/pqxx/connection.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef PQXX_H_CONNECTION
#define PQXX_H_CONNECTION

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/cursor
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/cursor.hxx"

#include "pqxx/internal/header-post.hxx"
2 changes: 1 addition & 1 deletion include/pqxx/cursor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef PQXX_H_CURSOR
#define PQXX_H_CURSOR

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/dbtransaction
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/dbtransaction.hxx"

#include "pqxx/internal/header-post.hxx"
2 changes: 1 addition & 1 deletion include/pqxx/dbtransaction.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef PQXX_H_DBTRANSACTION
#define PQXX_H_DBTRANSACTION

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/errorhandler
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/errorhandler.hxx"

#include "pqxx/internal/header-post.hxx"
2 changes: 1 addition & 1 deletion include/pqxx/errorhandler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef PQXX_H_ERRORHANDLER
#define PQXX_H_ERRORHANDLER

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/except
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/except.hxx"

#include "pqxx/internal/header-post.hxx"
2 changes: 1 addition & 1 deletion include/pqxx/except.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef PQXX_H_EXCEPT
#define PQXX_H_EXCEPT

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

Expand Down
3 changes: 0 additions & 3 deletions include/pqxx/field
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
*/
// Actual definitions in .hxx file so editors and such recognize file type.
#include "pqxx/internal/header-pre.hxx"
#include "pqxx/internal/compiler-public.hxx"

#include "pqxx/field.hxx"

#include "pqxx/internal/header-post.hxx"
2 changes: 1 addition & 1 deletion include/pqxx/field.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef PQXX_H_FIELD
#define PQXX_H_FIELD

#if !defined(PQXX_H_COMPILER_PUBLIC)
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif

Expand Down
134 changes: 0 additions & 134 deletions include/pqxx/internal/compiler-public.hxx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <pqxx/internal/callgate.hxx>

#include <pqxx/connection>
#include "pqxx/connection.hxx"


namespace pqxx
Expand Down
2 changes: 2 additions & 0 deletions include/pqxx/internal/gates/connection-pipeline.hxx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "pqxx/internal/libpq-forward.hxx"
#include <pqxx/internal/callgate.hxx>

#include "pqxx/pipeline.hxx"

namespace pqxx::internal::gate
{
class PQXX_PRIVATE connection_pipeline : callgate<connection>
Expand Down
3 changes: 3 additions & 0 deletions include/pqxx/internal/gates/connection-stream_to.hxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <pqxx/internal/callgate.hxx>

#include "pqxx/stream_to.hxx"


namespace pqxx::internal::gate
{
class PQXX_PRIVATE connection_stream_to : callgate<connection>
Expand Down
2 changes: 2 additions & 0 deletions include/pqxx/internal/gates/transaction-transaction_focus.hxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <pqxx/internal/callgate.hxx>

#include "pqxx/transaction_base.hxx"

namespace pqxx::internal::gate
{
class PQXX_PRIVATE transaction_transaction_focus : callgate<transaction_base>
Expand Down
2 changes: 2 additions & 0 deletions include/pqxx/internal/header-post.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
#if defined(_MSC_VER)
# pragma warning(pop) // Restore compiler's warning state
#endif

#undef PQXX_HEADER_PRE
Loading

0 comments on commit 20fc436

Please sign in to comment.