Skip to content

Commit

Permalink
Format all the code (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
a4z committed May 11, 2023
1 parent 664cfb1 commit 50cca73
Show file tree
Hide file tree
Showing 41 changed files with 1,351 additions and 1,492 deletions.
5 changes: 2 additions & 3 deletions include/sl3/columns.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down Expand Up @@ -114,7 +114,6 @@ namespace sl3
*/
DbValue getValue (int idx, Type type) const;


/**
* \brief Get all columns at once
*
Expand Down Expand Up @@ -151,7 +150,7 @@ namespace sl3

/**
* \brief Get the size of a column
*
*
* The size sqlite3 uses to store the value of the given field.
*
* \param idx wanted index
Expand Down
43 changes: 21 additions & 22 deletions include/sl3/command.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down Expand Up @@ -47,10 +47,10 @@ namespace sl3
const std::string& sql,
DbValues parameters);

Command () = delete;
Command (const Command&) = delete;
Command () = delete;
Command (const Command&) = delete;
Command operator= (const Command&) = delete;
Command operator= (Command&&) = delete;
Command operator= (Command&&) = delete;

public:
/**
Expand Down Expand Up @@ -120,7 +120,7 @@ namespace sl3
* \return false if processing the query result shall stop
* \n true otherwise
*/
using Callback = std::function<bool(Columns)>;
using Callback = std::function<bool (Columns)>;

/**
* \brief Execute the command
Expand All @@ -131,7 +131,6 @@ namespace sl3
*/
void execute ();


/**
* \brief Execute the command
*
Expand All @@ -143,25 +142,25 @@ namespace sl3
void execute (const DbValues& parameters);

/**
* \brief Execute the command applying given callback
*
* Applies given parameters and run the current command.
*
* \throw sl3::ErrTypeMisMatch given parameters are of the wrong size.
* \param cb a callback
* \param parameters a list of parameters
*/
* \brief Execute the command applying given callback
*
* Applies given parameters and run the current command.
*
* \throw sl3::ErrTypeMisMatch given parameters are of the wrong size.
* \param cb a callback
* \param parameters a list of parameters
*/
void execute (RowCallback& cb, const DbValues& parameters = {});

/**
* \brief Execute the command applying given callback
*
* Applies given parameters and run the current command.
*
* \throw sl3::ErrTypeMisMatch given parameters are of the wrong size.
* \param cb a callback
* \param parameters a list of parameters
*/
* \brief Execute the command applying given callback
*
* Applies given parameters and run the current command.
*
* \throw sl3::ErrTypeMisMatch given parameters are of the wrong size.
* \param cb a callback
* \param parameters a list of parameters
*/
void execute (Callback cb, const DbValues& parameters = {});

/**
Expand Down
15 changes: 12 additions & 3 deletions include/sl3/container.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down Expand Up @@ -212,13 +212,22 @@ namespace sl3
* behaves undefined if given index is invalid
* \return reference to element at requested index
*/
reference operator[] (size_t i) { return _cont[i]; }
reference
operator[] (size_t i)
{
return _cont[i];
}
/**\brief unchecked random access
* \param i index
* behaves undefined if given index is invalid
* \return reference to element at requested index
*/
const_reference operator[] (size_t i) const { return _cont[i]; }
const_reference
operator[] (size_t i) const
{
return _cont[i];
}

protected:
/// Container T
ContainerType _cont;
Expand Down
2 changes: 1 addition & 1 deletion include/sl3/database.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down
15 changes: 7 additions & 8 deletions include/sl3/dataset.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down Expand Up @@ -80,8 +80,8 @@ namespace sl3
Dataset (Dataset&&) noexcept (
std::is_nothrow_move_constructible<Container<DbValues>>::value&&
std::is_nothrow_move_constructible<Types>::value&&
std::is_nothrow_move_constructible<std::vector<std::string>>::
value);
std::is_nothrow_move_constructible<
std::vector<std::string>>::value);
// = default; no mscv does not like it

/**
Expand Down Expand Up @@ -160,9 +160,10 @@ namespace sl3
*
* \see Dataset::sort
*/
typedef bool (*DbValueSort)(const DbValue&, const DbValue&);
typedef bool (*DbValueSort) (const DbValue&, const DbValue&);

//using DbValueSort = std::function<bool(const DbValue&, const DbValue&)> ;
// using DbValueSort = std::function<bool(const DbValue&, const DbValue&)>
// ;

/**
* \brief Sort the Dataset
Expand All @@ -174,9 +175,7 @@ namespace sl3
* \param idxs list of field indexes
* \param cmp pointer to a less than compare function, default dbval_lt
*/
void sort (const std::vector<size_t>& idxs,
DbValueSort cmp = &dbval_lt
);
void sort (const std::vector<size_t>& idxs, DbValueSort cmp = &dbval_lt);

private:
Types _fieldtypes;
Expand Down
7 changes: 1 addition & 6 deletions include/sl3/dbvalue.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand All @@ -16,7 +16,6 @@
#include <sl3/types.hpp>
#include <sl3/value.hpp>


// todo after a wile, type and storage type become confusing
// find better name, type should be value type,
// storage type something else, find better name!
Expand Down Expand Up @@ -319,7 +318,6 @@ namespace sl3
*/
Type dbtype () const;


/**
* \brief Returns the type of the underlying Value
*
Expand All @@ -331,7 +329,6 @@ namespace sl3
*/
Type type () const;


/**
* \brief Check if assignment would be OK
*
Expand All @@ -358,7 +355,6 @@ namespace sl3
friend class DbValues;

void assign (const DbValue& other);

};

/**
Expand Down Expand Up @@ -426,7 +422,6 @@ namespace sl3
*/
bool dbval_lt (const DbValue& a, const DbValue& b) noexcept;


}

#endif /* DbValue_HPP_ */
2 changes: 1 addition & 1 deletion include/sl3/dbvalues.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down
2 changes: 1 addition & 1 deletion include/sl3/error.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down
10 changes: 5 additions & 5 deletions include/sl3/rowcallback.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down Expand Up @@ -59,10 +59,10 @@ namespace sl3
virtual void onStart ();

/**
* \brief Called after a query result has been processed
*
* The default implementation does nothing.
*/
* \brief Called after a query result has been processed
*
* The default implementation does nothing.
*/
virtual void onEnd ();
};
}
Expand Down
4 changes: 2 additions & 2 deletions include/sl3/types.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down Expand Up @@ -69,7 +69,7 @@ namespace sl3
using reference = conatiner_type::reference;
using const_reference = conatiner_type::const_reference;
using size_type = conatiner_type::size_type;
//@}
//@}

#ifndef _MSC_VER
using Container::Container;
Expand Down
28 changes: 11 additions & 17 deletions include/sl3/value.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand All @@ -15,11 +15,9 @@
#include <sl3/error.hpp>
#include <sl3/types.hpp>


namespace sl3
{


/**
* \brief
*
Expand All @@ -38,7 +36,7 @@ namespace sl3
*
* Creates a Null Value
*/
Value () noexcept ;
Value () noexcept;

/** \brief Constructor
*
Expand Down Expand Up @@ -226,11 +224,10 @@ namespace sl3
*/
Type getType () const noexcept;

// friend bool operator== (const Value& a, const Value& b) noexcept;
// friend bool operator< (const Value& a, const Value& b) noexcept;
// friend bool operator== (const Value& a, const Value& b) noexcept;
// friend bool operator< (const Value& a, const Value& b) noexcept;
friend std::ostream& operator<< (std::ostream& stm, const sl3::Value& v);


friend bool value_type_eq (const Value& a, const Value& b) noexcept;
friend bool value_type_lt (const Value& a, const Value& b) noexcept;

Expand All @@ -244,8 +241,7 @@ namespace sl3
*
* \param other value to swap with
*/
void swap(Value& other) noexcept;

void swap (Value& other) noexcept;

private:
Type _type{Type::Null};
Expand Down Expand Up @@ -285,8 +281,6 @@ namespace sl3
*/
bool value_type_eq (const Value& a, const Value& b) noexcept;



/**
* \brief less than, including type info
*
Expand All @@ -309,7 +303,6 @@ namespace sl3
*/
bool value_type_lt (const Value& a, const Value& b) noexcept;


/**
* \brief equality, ignoring type info
*
Expand Down Expand Up @@ -343,16 +336,17 @@ namespace sl3
void swap (Value& a, Value& b) noexcept;

/// Define a constant for a Value that is null
//static const Value NullValue{};
// static const Value NullValue{};
}

namespace std
{ // only allowed to extend namespace std with specializations
{ // only allowed to extend namespace std with specializations

template<> // specialization
inline void swap<sl3::Value>(sl3::Value& lhs, sl3::Value& rhs)
template <> // specialization
inline void
swap<sl3::Value> (sl3::Value& lhs, sl3::Value& rhs)
{
sl3::swap(lhs, rhs) ;
sl3::swap (lhs, rhs);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/sl3/columns.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down
2 changes: 1 addition & 1 deletion src/sl3/command.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
------------- Copyright (c) 2009-2017 H a r a l d A c h i t z ---------------
------------- Copyright (c) 2009-2023 H a r a l d A c h i t z ---------------
---------- < h a r a l d dot a c h i t z at g m a i l dot c o m > ------------
---- This Source Code Form is subject to the terms of the Mozilla Public -----
---- License, v. 2.0. If a copy of the MPL was not distributed with this -----
Expand Down
Loading

0 comments on commit 50cca73

Please sign in to comment.