Skip to content

Commit

Permalink
Reformat all code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtv committed Dec 31, 2019
1 parent 642bb16 commit 2c475f0
Show file tree
Hide file tree
Showing 169 changed files with 5,283 additions and 5,844 deletions.
6 changes: 4 additions & 2 deletions config-tests/charconv_float.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ int main()
{
char z[100];
auto rt = std::to_chars(std::begin(z), std::end(z), 3.14159L);
if (rt.ec != std::errc{}) return 1;
if (rt.ec != std::errc{})
return 1;
long double n;
auto rf = std::from_chars(std::cbegin(z), std::cend(z), n);
if (rf.ec != std::errc{}) return 2;
if (rf.ec != std::errc{})
return 2;
return (n > 3 and n < 4) ? 0 : 1;
}
6 changes: 4 additions & 2 deletions config-tests/charconv_int.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ int main()
{
char z[100];
auto rt = std::to_chars(std::begin(z), std::end(z), 9ULL);
if (rt.ec != std::errc{}) return 1;
if (rt.ec != std::errc{})
return 1;
unsigned long long n;
auto rf = std::from_chars(std::cbegin(z), std::cend(z), n);
if (rf.ec != std::errc{}) return 2;
if (rf.ec != std::errc{})
return 2;
return (n == 9ULL) ? 0 : 1;
}
5 changes: 4 additions & 1 deletion config-tests/gcc_pure.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Test for gcc-style "pure" attribute.
int __attribute__ ((pure)) f() { return 0; }
int __attribute__((pure)) f()
{
return 0;
}

int main()
{
Expand Down
2 changes: 1 addition & 1 deletion config-tests/gcc_visibility.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Test for gcc-style "visibility" attribute.
struct __attribute__ ((visibility("hidden"))) D
struct __attribute__((visibility("hidden"))) D
{
D() {}
int f() { return 0; }
Expand Down
2 changes: 1 addition & 1 deletion config-tests/strnlen.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <cstring>

#if __has_include(<string.h>)
#include <string.h>
# include <string.h>
#endif


Expand Down
2 changes: 1 addition & 1 deletion config-tests/strnlen_s.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <cstring>

#if __has_include(<string.h>)
#include <string.h>
# include <string.h>
#endif


Expand Down
13 changes: 6 additions & 7 deletions include/pqxx/array.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Copyright (c) 2000-2019, Jeroen T. Vermeulen.
*
* See COPYING for copyright license. If you did not receive a file called
* COPYING with this source code, please notify the distributor of this mistake,
* or contact the author.
* COPYING with this source code, please notify the distributor of this
* mistake, or contact the author.
*/
#ifndef PQXX_H_ARRAY
#define PQXX_H_ARRAY
Expand Down Expand Up @@ -63,8 +63,8 @@ public:

/// Constructor. You don't need this; use @c field::as_array instead.
explicit array_parser(
std::string_view input,
internal::encoding_group=internal::encoding_group::MONOBYTE);
std::string_view input,
internal::encoding_group = internal::encoding_group::MONOBYTE);

/// Parse the next step in the array.
/** Returns what it found. If the juncture is @c string_value, the string
Expand All @@ -89,9 +89,8 @@ private:
std::string parse_unquoted_string(std::string::size_type end) const;

std::string::size_type scan_glyph(std::string::size_type pos) const;
std::string::size_type scan_glyph(
std::string::size_type pos,
std::string::size_type end) const;
std::string::size_type
scan_glyph(std::string::size_type pos, std::string::size_type end) const;
};
} // namespace pqxx

Expand Down
66 changes: 37 additions & 29 deletions include/pqxx/binarystring.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Copyright (c) 2000-2019, Jeroen T. Vermeulen.
*
* See COPYING for copyright license. If you did not receive a file called
* COPYING with this source code, please notify the distributor of this mistake,
* or contact the author.
* COPYING with this source code, please notify the distributor of this
* mistake, or contact the author.
*/
#ifndef PQXX_H_BINARYSTRING
#define PQXX_H_BINARYSTRING
Expand All @@ -26,16 +26,16 @@ namespace pqxx
/** @ingroup escaping-functions
*
* This class represents a binary string as stored in a field of type bytea.
* The raw value returned by a bytea field contains escape sequences for certain
* characters, which are filtered out by binarystring.
* The raw value returned by a bytea field contains escape sequences for
* certain characters, which are filtered out by binarystring.
*
* Internally a binarystring is zero-terminated, but it may also contain null
* bytes, they're just like any other byte value. So don't assume that it's
* safe to treat the contents as a C-style string unless you've made sure of it
* yourself.
*
* The binarystring retains its value even if the result it was obtained from is
* destroyed, but it cannot be copied or assigned.
* The binarystring retains its value even if the result it was obtained from
* is destroyed, but it cannot be copied or assigned.
*
* \relatesalso transaction_base::esc_raw
*
Expand All @@ -44,11 +44,11 @@ namespace pqxx
* esc_raw() functions.
*
* @warning This class is implemented as a reference-counting smart pointer.
* Copying, swapping, and destroying binarystring objects that refer to the same
* underlying data block is <em>not thread-safe</em>. If you wish to pass
* binarystrings around between threads, make sure that each of these operations
* is protected against concurrency with similar operations on the same object,
* or other objects pointing to the same data block.
* Copying, swapping, and destroying binarystring objects that refer to the
* same underlying data block is <em>not thread-safe</em>. If you wish to pass
* binarystrings around between threads, make sure that each of these
* operations is protected against concurrency with similar operations on the
* same object, or other objects pointing to the same data block.
*/
class PQXX_LIBEXPORT binarystring
{
Expand All @@ -62,10 +62,11 @@ public:
using const_iterator = const_pointer;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;

binarystring(const binarystring &) =default;
binarystring(const binarystring &) = default;

/// Read and unescape bytea field.
/** The field will be zero-terminated, even if the original bytea field isn't.
/** The field will be zero-terminated, even if the original bytea field
* isn't.
* @param F the field to read; must be a bytea field
*/
explicit binarystring(const field &);
Expand All @@ -80,33 +81,37 @@ public:
size_type size() const noexcept { return m_size; }
/// Size of converted string in bytes.
size_type length() const noexcept { return size(); }
bool empty() const noexcept { return size()==0; }
bool empty() const noexcept { return size() == 0; }

const_iterator begin() const noexcept { return data(); }
const_iterator cbegin() const noexcept { return begin(); }
const_iterator end() const noexcept { return data()+m_size; }
const_iterator end() const noexcept { return data() + m_size; }
const_iterator cend() const noexcept { return end(); }

const_reference front() const noexcept { return *begin(); }
const_reference back() const noexcept
{ return *(data()+m_size-1); }
const_reference back() const noexcept { return *(data() + m_size - 1); }

const_reverse_iterator rbegin() const
{ return const_reverse_iterator{end()}; }
{
return const_reverse_iterator{end()};
}
const_reverse_iterator crbegin() const { return rbegin(); }
const_reverse_iterator rend() const
{ return const_reverse_iterator{begin()}; }
{
return const_reverse_iterator{begin()};
}
const_reverse_iterator crend() const { return rend(); }

/// Unescaped field contents.
const value_type *data() const noexcept {return m_buf.get();}
const value_type *data() const noexcept { return m_buf.get(); }

const_reference operator[](size_type i) const noexcept
{ return data()[i]; }
const_reference operator[](size_type i) const noexcept { return data()[i]; }

PQXX_PURE bool operator==(const binarystring &) const noexcept;
bool operator!=(const binarystring &rhs) const noexcept
{ return not operator==(rhs); }
{
return not operator==(rhs);
}

binarystring &operator=(const binarystring &);

Expand All @@ -121,11 +126,15 @@ public:
* a null character, you will not find one here.
*/
const char *get() const noexcept
{ return reinterpret_cast<const char *>(m_buf.get()); }
{
return reinterpret_cast<const char *>(m_buf.get());
}

/// Read contents as a std::string_view.
std::string_view view() const noexcept
{ return std::string_view(get(), size()); }
{
return std::string_view(get(), size());
}

/// Read as regular C++ string (may include null characters).
/** This creates and returns a new string object. Don't call this
Expand All @@ -139,17 +148,16 @@ private:
using smart_pointer_type = std::shared_ptr<value_type>;

/// Shorthand: construct a smart_pointer_type.
static smart_pointer_type make_smart_pointer(unsigned char *buf=nullptr)
static smart_pointer_type make_smart_pointer(unsigned char *buf = nullptr)
{
return smart_pointer_type{
buf,
internal::freemallocmem_templated<unsigned char>};
buf, internal::freemallocmem_templated<unsigned char>};
}

smart_pointer_type m_buf;
size_type m_size;
};
}
} // namespace pqxx

#include "pqxx/internal/compiler-internal-post.hxx"
#endif
90 changes: 45 additions & 45 deletions include/pqxx/compiler-public.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Copyright (c) 2000-2019, Jeroen T. Vermeulen.
*
* See COPYING for copyright license. If you did not receive a file called
* COPYING with this source code, please notify the distributor of this mistake,
* or contact the author.
* COPYING with this source code, please notify the distributor of this
* mistake, or contact the author.
*/
#ifndef PQXX_H_COMPILER_PUBLIC
#define PQXX_H_COMPILER_PUBLIC
Expand All @@ -22,9 +22,9 @@

#if defined(__GNUC__) && defined(PQXX_HAVE_GCC_PURE)
/// Declare function "pure": no side effects, only reads globals and its args.
#define PQXX_PURE __attribute__ ((pure))
# define PQXX_PURE __attribute__((pure))
#else
#define PQXX_PURE
# define PQXX_PURE
#endif


Expand All @@ -35,36 +35,36 @@
* by the compiler when linking to the dynamic version of the runtime library,
* according to "gzh"
*/
#if defined(PQXX_SHARED) && !defined(PQXX_LIBEXPORT)
#define PQXX_LIBEXPORT __declspec(dllimport)
#endif // PQXX_SHARED && !PQXX_LIBEXPORT
# if defined(PQXX_SHARED) && !defined(PQXX_LIBEXPORT)
# define PQXX_LIBEXPORT __declspec(dllimport)
# endif // PQXX_SHARED && !PQXX_LIBEXPORT


// Workarounds for Microsoft Visual C++
#ifdef _MSC_VER
# ifdef _MSC_VER

// Suppress vtables on abstract classes.
#define PQXX_NOVTABLE __declspec(novtable)
# define PQXX_NOVTABLE __declspec(novtable)

// Automatically link with the appropriate libpq (static or dynamic, debug or
// release). The default is to use the release DLL. Define PQXX_PQ_STATIC to
// link to a static version of libpq, and _DEBUG to link to a debug version.
// The two may be combined.
#if defined(PQXX_AUTOLINK)
#if defined(PQXX_PQ_STATIC)
#ifdef _DEBUG
#pragma comment(lib, "libpqd")
#else
#pragma comment(lib, "libpq")
#endif
#else
#ifdef _DEBUG
#pragma comment(lib, "libpqddll")
#else
#pragma comment(lib, "libpqdll")
#endif
#endif
#endif
# if defined(PQXX_AUTOLINK)
# if defined(PQXX_PQ_STATIC)
# ifdef _DEBUG
# pragma comment(lib, "libpqd")
# else
# pragma comment(lib, "libpq")
# endif
# else
# ifdef _DEBUG
# pragma comment(lib, "libpqddll")
# else
# pragma comment(lib, "libpqdll")
# endif
# endif
# endif

// If we're not compiling libpqxx itself, automatically link with the
// appropriate libpqxx library. To link with the libpqxx DLL, define
Expand All @@ -74,36 +74,36 @@
// The preprocessor macro PQXX_INTERNAL is used to detect whether we
// are compiling the libpqxx library itself. When you compile the library
// yourself using your own project file, make sure to include this macro.
#if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
#ifdef PQXX_SHARED
#ifdef _DEBUG
#pragma comment(lib, "libpqxxD")
#else
#pragma comment(lib, "libpqxx")
#endif
#else // !PQXX_SHARED
#ifdef _DEBUG
#pragma comment(lib, "libpqxx_staticD")
#else
#pragma comment(lib, "libpqxx_static")
#endif
#endif
#endif

#endif // _MSC_VER
#endif // _WIN32
# if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
# ifdef PQXX_SHARED
# ifdef _DEBUG
# pragma comment(lib, "libpqxxD")
# else
# pragma comment(lib, "libpqxx")
# endif
# else // !PQXX_SHARED
# ifdef _DEBUG
# pragma comment(lib, "libpqxx_staticD")
# else
# pragma comment(lib, "libpqxx_static")
# endif
# endif
# endif

# endif // _MSC_VER
#endif // _WIN32


#ifndef PQXX_LIBEXPORT
#define PQXX_LIBEXPORT
# define PQXX_LIBEXPORT
#endif

#ifndef PQXX_PRIVATE
#define PQXX_PRIVATE
# define PQXX_PRIVATE
#endif

#ifndef PQXX_NOVTABLE
#define PQXX_NOVTABLE
# define PQXX_NOVTABLE
#endif

#endif
Loading

0 comments on commit 2c475f0

Please sign in to comment.