Skip to content

Commit

Permalink
clang-format: ColumnLimit to 0 + format whole project
Browse files Browse the repository at this point in the history
I applied some manual changes to canonmn_int.cpp so that the array
elements are split in different lines:
- Add extra comma after last item in the arrays
- If a comment is present in the last item (i.e // To silence warnings),
then we also need to add a comment after the first item.
  • Loading branch information
piponazo committed Mar 16, 2022
1 parent ad7f178 commit 5ef2f8b
Show file tree
Hide file tree
Showing 67 changed files with 2,121 additions and 1,132 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Indentation for all files
ColumnLimit: 120
ColumnLimit: 0
IndentWidth: 4
TabWidth: 4
UseTab: Never
Expand Down
3 changes: 2 additions & 1 deletion include/exiv2/basicio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ namespace Exiv2
//! @name Creators
//@{
//! Constructor, takes a BasicIo reference
explicit IoCloser(BasicIo& bio) : bio_(bio)
explicit IoCloser(BasicIo& bio)
: bio_(bio)
{
}
//! Destructor, closes the BasicIo reference
Expand Down
3 changes: 2 additions & 1 deletion include/exiv2/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ namespace Exiv2

//! Constructor taking an error code and one argument
template <typename A>
Error(ErrorCode code, const A& arg1) : code_(code), arg1_(toBasicString<char>(arg1))
Error(ErrorCode code, const A& arg1)
: code_(code), arg1_(toBasicString<char>(arg1))
{
setMsg(1);
}
Expand Down
6 changes: 3 additions & 3 deletions include/exiv2/jpgimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ namespace Exiv2
// Todo: Public for now
static constexpr std::array<const char*, 4> irbId_{"8BIM", "AgHg", "DCSR", "PHUT"}; //!< %Photoshop IRB markers
inline static const char* ps3Id_ = "Photoshop 3.0\0"; //!< %Photoshop marker
inline static const char* bimId_ = "8BIM"; //!< %Photoshop IRB marker (deprecated)
inline static const uint16_t iptc_ = 0x0404; //!< %Photoshop IPTC marker
inline static const uint16_t preview_ = 0x040c; //!< %Photoshop preview marker
inline static const char* bimId_ = "8BIM"; //!< %Photoshop IRB marker (deprecated)
inline static const uint16_t iptc_ = 0x0404; //!< %Photoshop IPTC marker
inline static const uint16_t preview_ = 0x040c; //!< %Photoshop preview marker

/*!
@brief Checks an IRB
Expand Down
9 changes: 6 additions & 3 deletions include/exiv2/slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace Exiv2
*/
struct SliceBase
{
inline SliceBase(size_t begin, size_t end) : begin_(begin), end_(end)
inline SliceBase(size_t begin, size_t end)
: begin_(begin), end_(end)
{
if (begin >= end) {
throw std::out_of_range("Begin must be smaller than end");
Expand Down Expand Up @@ -291,7 +292,8 @@ namespace Exiv2
* @throw std::out_of_range when end is larger than the container's
* size.
*/
ContainerStorage(container& data, size_t /* begin*/, size_t end) : data_(data)
ContainerStorage(container& data, size_t /* begin*/, size_t end)
: data_(data)
{
if (end > data.size()) {
throw std::out_of_range("Invalid input parameters to slice");
Expand Down Expand Up @@ -362,7 +364,8 @@ namespace Exiv2
*
* @throw std::invalid_argument when ptr is `NULL`
*/
PtrSliceStorage(storage_type ptr, size_t /*begin*/, size_t /*end*/) : data_(ptr)
PtrSliceStorage(storage_type ptr, size_t /*begin*/, size_t /*end*/)
: data_(ptr)
{
if (!ptr) {
throw std::invalid_argument("Null pointer passed to slice constructor");
Expand Down
21 changes: 14 additions & 7 deletions include/exiv2/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,12 @@ namespace Exiv2
//! LangAltValueComparator comparison case insensitive function
bool operator()(const std::string& str1, const std::string& str2) const
{
int result = str1.size() < str2.size() ? 1 : str1.size() > str2.size() ? -1 : 0;
int result = str1.size() < str2.size() ? 1 : str1.size() > str2.size() ? -1
: 0;
if (result == 0) {
for (auto c1 = str1.begin(), c2 = str2.begin(); result == 0 && c1 != str1.end(); ++c1, ++c2) {
result = tolower(*c1) < tolower(*c2) ? 1 : tolower(*c1) > tolower(*c2) ? -1 : 0;
result = tolower(*c1) < tolower(*c2) ? 1 : tolower(*c1) > tolower(*c2) ? -1
: 0;
}
}
return result < 0;
Expand Down Expand Up @@ -1540,29 +1542,34 @@ namespace Exiv2
}

template <typename T>
ValueType<T>::ValueType() : Value(getType<T>())
ValueType<T>::ValueType()
: Value(getType<T>())
{
}

template <typename T>
ValueType<T>::ValueType(TypeId typeId) : Value(typeId)
ValueType<T>::ValueType(TypeId typeId)
: Value(typeId)
{
}

template <typename T>
ValueType<T>::ValueType(const byte* buf, size_t len, ByteOrder byteOrder, TypeId typeId) : Value(typeId)
ValueType<T>::ValueType(const byte* buf, size_t len, ByteOrder byteOrder, TypeId typeId)
: Value(typeId)
{
read(buf, len, byteOrder);
}

template <typename T>
ValueType<T>::ValueType(const T& val, TypeId typeId) : Value(typeId)
ValueType<T>::ValueType(const T& val, TypeId typeId)
: Value(typeId)
{
value_.push_back(val);
}

template <typename T>
ValueType<T>::ValueType(const ValueType<T>& rhs) : Value(rhs.typeId()), value_(rhs.value_)
ValueType<T>::ValueType(const ValueType<T>& rhs)
: Value(rhs.typeId()), value_(rhs.value_)

{
if (rhs.sizeDataArea_ > 0) {
Expand Down
22 changes: 16 additions & 6 deletions samples/Jzon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,14 @@ namespace Jzon
const char *second;
};
static constexpr std::array<chrPair, 8> chars{
chrPair{'\\', "\\\\"}, chrPair{'/', "\\/"}, chrPair{'\"', "\\\""}, chrPair{'\n', "\\n"},
chrPair{'\t', "\\t"}, chrPair{'\b', "\\b"}, chrPair{'\f', "\\f"}, chrPair{'\r', "\\r"},
chrPair{'\\', "\\\\"},
chrPair{'/', "\\/"},
chrPair{'\"', "\\\""},
chrPair{'\n', "\\n"},
chrPair{'\t', "\\t"},
chrPair{'\b', "\\b"},
chrPair{'\f', "\\f"},
chrPair{'\r', "\\r"},
};
static constexpr char nullUnescaped = '\0';
static constexpr const char *nullEscaped = "\0\0";
Expand Down Expand Up @@ -614,7 +620,8 @@ namespace Jzon
return new Array(*this);
}

FileWriter::FileWriter(std::string filename) : filename(std::move(filename))
FileWriter::FileWriter(std::string filename)
: filename(std::move(filename))
{
}

Expand Down Expand Up @@ -688,7 +695,8 @@ namespace Jzon
return true;
}

Writer::Writer(const Node &root, const Format &format) : fi(new FormatInterpreter), root(root)
Writer::Writer(const Node &root, const Format &format)
: fi(new FormatInterpreter), root(root)
{
SetFormat(format);
}
Expand Down Expand Up @@ -768,10 +776,12 @@ namespace Jzon
}
}

Parser::Parser(Node &root) : root(root)
Parser::Parser(Node &root)
: root(root)
{
}
Parser::Parser(Node &root, const std::string &json) : root(root)
Parser::Parser(Node &root, const std::string &json)
: root(root)
{
SetJson(json);
}
Expand Down
30 changes: 20 additions & 10 deletions samples/Jzon.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ namespace Jzon
class TypeException : public std::logic_error
{
public:
TypeException() : std::logic_error("A Node was used as the wrong type")
TypeException()
: std::logic_error("A Node was used as the wrong type")
{
}
};
class NotFoundException : public std::out_of_range
{
public:
NotFoundException() : std::out_of_range("The node could not be found")
NotFoundException()
: std::out_of_range("The node could not be found")
{
}
};
Expand Down Expand Up @@ -261,10 +263,12 @@ namespace Jzon
class iterator : public std::iterator<std::input_iterator_tag, NamedNode>
{
public:
iterator(NamedNodePtr *o) : p(o)
iterator(NamedNodePtr *o)
: p(o)
{
}
iterator(const iterator &it) : p(it.p)
iterator(const iterator &it)
: p(it.p)
{
}

Expand Down Expand Up @@ -300,10 +304,12 @@ namespace Jzon
class const_iterator : public std::iterator<std::input_iterator_tag, const NamedNode>
{
public:
const_iterator(const NamedNodePtr *o) : p(o)
const_iterator(const NamedNodePtr *o)
: p(o)
{
}
const_iterator(const const_iterator &it) : p(it.p)
const_iterator(const const_iterator &it)
: p(it.p)
{
}

Expand Down Expand Up @@ -373,10 +379,12 @@ namespace Jzon
class iterator : public std::iterator<std::input_iterator_tag, Node>
{
public:
iterator(Node **o) : p(o)
iterator(Node **o)
: p(o)
{
}
iterator(const iterator &it) : p(it.p)
iterator(const iterator &it)
: p(it.p)
{
}

Expand Down Expand Up @@ -412,10 +420,12 @@ namespace Jzon
class const_iterator : public std::iterator<std::input_iterator_tag, const Node>
{
public:
const_iterator(const Node *const *o) : p(o)
const_iterator(const Node *const *o)
: p(o)
{
}
const_iterator(const const_iterator &it) : p(it.p)
const_iterator(const const_iterator &it)
: p(it.p)
{
}

Expand Down
6 changes: 4 additions & 2 deletions samples/geotag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ strings_t gFiles;
class Position
{
public:
Position(time_t time, double lat, double lon, double ele) : time_(time), lon_(lon), lat_(lat), ele_(ele)
Position(time_t time, double lat, double lon, double ele)
: time_(time), lon_(lon), lat_(lat), ele_(ele)
{
}

Expand Down Expand Up @@ -275,7 +276,8 @@ time_t Position::deltaMax_ = 60;
// UserData - used by XML Parser
struct UserData final
{
explicit UserData(Options& options) : options_(options)
explicit UserData(Options& options)
: options_(options)
{
}

Expand Down
3 changes: 2 additions & 1 deletion samples/metacopy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class Params : public Util::Getopt
/*!
@brief Default constructor. Note that optstring_ is initialized here.
*/
Params() : optstring_(":iecxaph")
Params()
: optstring_(":iecxaph")
{
}

Expand Down
24 changes: 16 additions & 8 deletions src/basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ namespace Exiv2
Impl& operator=(const Impl& rhs) = delete; //!< Assignment
}; // class FileIo::Impl

FileIo::Impl::Impl(std::string path) : path_(std::move(path))
FileIo::Impl::Impl(std::string path)
: path_(std::move(path))
{
}

Expand Down Expand Up @@ -198,7 +199,8 @@ namespace Exiv2
return ret;
} // FileIo::Impl::stat

FileIo::FileIo(const std::string& path) : p_(std::make_unique<Impl>(path))
FileIo::FileIo(const std::string& path)
: p_(std::make_unique<Impl>(path))
{
}

Expand Down Expand Up @@ -624,7 +626,8 @@ namespace Exiv2
Impl& operator=(const Impl& rhs) = delete; //!< Assignment
}; // class MemIo::Impl

MemIo::Impl::Impl(const byte* data, size_t size) : data_(const_cast<byte*>(data)), size_(size)
MemIo::Impl::Impl(const byte* data, size_t size)
: data_(const_cast<byte*>(data)), size_(size)
{
}

Expand Down Expand Up @@ -744,11 +747,13 @@ namespace Exiv2
}
}

MemIo::MemIo() : p_(std::make_unique<Impl>())
MemIo::MemIo()
: p_(std::make_unique<Impl>())
{
}

MemIo::MemIo(const byte* data, size_t size) : p_(std::make_unique<Impl>(data, size))
MemIo::MemIo(const byte* data, size_t size)
: p_(std::make_unique<Impl>(data, size))
{
}

Expand Down Expand Up @@ -992,7 +997,8 @@ namespace Exiv2
}

#else
XPathIo::XPathIo(const std::string& orgPath) : FileIo(XPathIo::writeDataToFile(orgPath)), isTemp_(true)
XPathIo::XPathIo(const std::string& orgPath)
: FileIo(XPathIo::writeDataToFile(orgPath)), isTemp_(true)
{
tempFilePath_ = path();
}
Expand Down Expand Up @@ -1547,7 +1553,8 @@ namespace Exiv2
HttpImpl& operator=(const HttpImpl& rhs) = delete; //!< Assignment
}; // class HttpIo::HttpImpl

HttpIo::HttpImpl::HttpImpl(const std::string& url, size_t blockSize) : Impl(url, blockSize)
HttpIo::HttpImpl::HttpImpl(const std::string& url, size_t blockSize)
: Impl(url, blockSize)
{
hostInfo_ = Exiv2::Uri::Parse(url);
Exiv2::Uri::Decode(hostInfo_);
Expand Down Expand Up @@ -1708,7 +1715,8 @@ namespace Exiv2
long timeout_; //!< The number of seconds to wait while trying to connect.
}; // class RemoteIo::Impl

CurlIo::CurlImpl::CurlImpl(const std::string& url, size_t blockSize) : Impl(url, blockSize), curl_(curl_easy_init())
CurlIo::CurlImpl::CurlImpl(const std::string& url, size_t blockSize)
: Impl(url, blockSize), curl_(curl_easy_init())
{
if (!curl_) {
throw Error(ErrorCode::kerErrorMessage, "Unable to init libcurl.");
Expand Down
3 changes: 2 additions & 1 deletion src/bmpimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
// class member definitions
namespace Exiv2
{
BmpImage::BmpImage(BasicIo::UniquePtr io) : Image(ImageType::bmp, mdNone, std::move(io))
BmpImage::BmpImage(BasicIo::UniquePtr io)
: Image(ImageType::bmp, mdNone, std::move(io))
{
}

Expand Down
Loading

0 comments on commit 5ef2f8b

Please sign in to comment.