Skip to content

Commit

Permalink
clang-format Objective-C files too
Browse files Browse the repository at this point in the history
  • Loading branch information
ClausKlein committed Sep 10, 2024
1 parent c3dbdca commit 7ba4a91
Show file tree
Hide file tree
Showing 84 changed files with 534 additions and 539 deletions.
17 changes: 12 additions & 5 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: Llvm
IndentWidth: 4
---
Language: Json
IndentWidth: 4
UseTab: Never
---
Language: JavaScript
# Don't format .js files.
DisableFormat: true
---
Language: Cpp
BasedOnStyle: Llvm
# TBD IndentWidth: 2

# ColumnLimit: 80
# AccessModifierOffset: -2
Expand All @@ -13,9 +19,6 @@ BasedOnStyle: Llvm
# ConstructorInitializerIndentWidth: 4
# ContinuationIndentWidth: 4
# DerivePointerAlignment: false
# #
# # TODO: TBD 4 instead of 2? CK
# # XXX IndentWidth: 4
# InsertBraces: true
# InsertNewlineAtEOF: true
# NamespaceIndentation: None
Expand All @@ -32,3 +35,7 @@ BasedOnStyle: Llvm
# BreakBeforeBraces: Custom
# BraceWrapping:
# AfterNamespace: true

---
# XXX Language: Objective-C
# Implicit supported .mm files.
4 changes: 2 additions & 2 deletions chapter01/simple_executable/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <iostream>

int main(int, char **) {
std::cout << "Welcome to CMake Best Practices\n";
return 0;
std::cout << "Welcome to CMake Best Practices\n";
return 0;
}
44 changes: 22 additions & 22 deletions chapter02/component1/include/framework/components/component1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ namespace framework::components {
* @brief Component 1 interface
*/
class component1 : public component_interface {
public:
/**
* @brief Construct a new component1 object
*/
component1();
public:
/**
* @brief Construct a new component1 object
*/
component1();

/**
* @brief Destroy the component1 object
*/
virtual ~component1() override;
/**
* @brief Destroy the component1 object
*/
virtual ~component1() override;

/**
* @brief Do some work
*
* @return true on success, false on failure
*/
virtual bool do_stuff() const override;
/**
* @brief Do some work
*
* @return true on success, false on failure
*/
virtual bool do_stuff() const override;

/**
* @brief Do other stuff
*
* @param param Argument
* @return int Stuffs completed
*/
virtual int do_other_stuff(int param) override;
/**
* @brief Do other stuff
*
* @param param Argument
* @return int Stuffs completed
*/
virtual int do_other_stuff(int param) override;
}; // class component1
} // namespace framework::components
4 changes: 2 additions & 2 deletions chapter02/component1/src/component1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
namespace framework::components {

component1::component1() {
std::cout << "Component 1 is constructed" << std::endl;
std::cout << "Component 1 is constructed" << std::endl;
}

component1::~component1() {
std::cout << "Component 1 is destructed" << std::endl;
std::cout << "Component 1 is destructed" << std::endl;
}

bool component1::do_stuff() const { return false; }
Expand Down
44 changes: 22 additions & 22 deletions chapter02/component2/include/framework/components/component2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ namespace framework::components {
* @brief Component 1 interface
*/
class component2 : public component_interface {
public:
/**
* @brief Construct a new component1 object
*/
component2();
public:
/**
* @brief Construct a new component1 object
*/
component2();

/**
* @brief Destroy the component1 object
*/
virtual ~component2() override;
/**
* @brief Destroy the component1 object
*/
virtual ~component2() override;

/**
* @brief Do some work
*
* @return true on success, false on failure
*/
virtual bool do_stuff() const override;
/**
* @brief Do some work
*
* @return true on success, false on failure
*/
virtual bool do_stuff() const override;

/**
* @brief Do other stuff
*
* @param param Argument
* @return int Stuffs completed
*/
virtual int do_other_stuff(int param) override;
/**
* @brief Do other stuff
*
* @param param Argument
* @return int Stuffs completed
*/
virtual int do_other_stuff(int param) override;
}; // class component2
} // namespace framework::components
4 changes: 2 additions & 2 deletions chapter02/component2/src/component2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
namespace framework::components {

component2::component2() {
std::cout << "Component 2 is constructed" << std::endl;
std::cout << "Component 2 is constructed" << std::endl;
}

component2::~component2() {
std::cout << "Component 2 is destructed" << std::endl;
std::cout << "Component 2 is destructed" << std::endl;
}

bool component2::do_stuff() const { return true; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ namespace framework::components {
* @brief Component interface
*/
class component_interface {
public:
/**
* @brief Destroy the component1 object
*/
virtual ~component_interface() = default;
public:
/**
* @brief Destroy the component1 object
*/
virtual ~component_interface() = default;

/**
* @brief Do some work
*
* @return true on success, false on failure
*/
virtual bool do_stuff() const = 0;
/**
* @brief Do some work
*
* @return true on success, false on failure
*/
virtual bool do_stuff() const = 0;

/**
* @brief Do other stuff
*
* @param param Argument
* @return int Stuffs completed
*/
virtual int do_other_stuff(int param) = 0;
/**
* @brief Do other stuff
*
* @param param Argument
* @return int Stuffs completed
*/
virtual int do_other_stuff(int param) = 0;
}; // class component_interface
} // namespace framework::components
30 changes: 15 additions & 15 deletions chapter02/driver_app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ enum class component_type : std::uint8_t { component1, component2 };
*/
std::unique_ptr<framework::components::component_interface>
component_factory(component_type ct) noexcept(false) {
switch (ct) {
case component_type::component1:
return std::unique_ptr<framework::components::component1>(
new framework::components::component1());
case component_type::component2:
return std::unique_ptr<framework::components::component2>(
new framework::components::component2());
}
throw std::runtime_error{"Invalid component type"};
switch (ct) {
case component_type::component1:
return std::unique_ptr<framework::components::component1>(
new framework::components::component1());
case component_type::component2:
return std::unique_ptr<framework::components::component2>(
new framework::components::component2());
}
throw std::runtime_error{"Invalid component type"};
}

/**
Expand All @@ -48,12 +48,12 @@ component_factory(component_type ct) noexcept(false) {
*/
int main(void) {

auto component_1 = component_factory(component_type::component1);
auto component_2 = component_factory(component_type::component2);
auto component_1 = component_factory(component_type::component1);
auto component_2 = component_factory(component_type::component2);

if (component_1->do_stuff() || component_2->do_stuff()) {
std::cout << "One of the component(s) did stuff" << std::endl;
}
if (component_1->do_stuff() || component_2->do_stuff()) {
std::cout << "One of the component(s) did stuff" << std::endl;
}

return component_1->do_other_stuff(1) + component_2->do_other_stuff(3);
return component_1->do_other_stuff(1) + component_2->do_other_stuff(3);
}
4 changes: 2 additions & 2 deletions chapter02/simple_example/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <iostream>

int main(int, char **) {
std::cout << "Welcome to CMake Best Practices\n";
return 0;
std::cout << "Welcome to CMake Best Practices\n";
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

namespace hello_header_only {
void print_hello(const std::string &name) {
std::cout << "Hello " << name << " from a header only library\n";
std::cout << "Hello " << name << " from a header only library\n";
}
} // namespace hello_header_only
10 changes: 5 additions & 5 deletions chapter03/hello_object_lib/include/hello_object/hello_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace hello_object {
/// Example class that is explicitly exported into a dll
class HelloObject {
public:
HelloObject(const std::string &name) : name_{name} {}
public:
HelloObject(const std::string &name) : name_{name} {}

void greet() const;
void greet() const;

private:
const std::string name_;
private:
const std::string name_;
};
} // namespace hello_object
2 changes: 1 addition & 1 deletion chapter03/hello_object_lib/src/hello_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace hello_object {
void HelloObject::greet() const {
std::cout << "Hello " << name_ << " From an object library\n";
std::cout << "Hello " << name_ << " From an object library\n";
}
} // namespace hello_object
10 changes: 5 additions & 5 deletions chapter03/hello_shared_lib/include/hello/hello.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
namespace hello {
/// Example class that is explicitly exported into a dll
class CH3_HELLO_SHARED_EXPORT Hello {
public:
Hello(const std::string &name) : name_{name} {}
public:
Hello(const std::string &name) : name_{name} {}

void greet() const;
void greet() const;

private:
const std::string name_;
private:
const std::string name_;
};
} // namespace hello
2 changes: 1 addition & 1 deletion chapter03/hello_shared_lib/src/internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace hello::details {
void print_impl(const std::string &name) {
std::cout << "Hello " << name << " from a shared library\n";
std::cout << "Hello " << name << " from a shared library\n";
}
} // namespace hello::details
10 changes: 5 additions & 5 deletions chapter03/hello_simple_library_example/include/hello/hello.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace hello {
/// Example class that is explicitly exported into a dll
class Hello {
public:
Hello(const std::string &name) : name_{name} {}
public:
Hello(const std::string &name) : name_{name} {}

void greet() const;
void greet() const;

private:
const std::string name_;
private:
const std::string name_;
};
} // namespace hello
2 changes: 1 addition & 1 deletion chapter03/hello_simple_library_example/src/internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace hello::details {
void print_impl(const std::string &name) {
std::cout << "Hello " << name << " from a shared library\n";
std::cout << "Hello " << name << " from a shared library\n";
}
} // namespace hello::details
10 changes: 5 additions & 5 deletions chapter03/hello_static_lib/include/hello/hello.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace hello {
/// Example class that is explicitly exported into a dll
class Hello {
public:
Hello(const std::string &name) : name_{name} {}
public:
Hello(const std::string &name) : name_{name} {}

void greet() const;
void greet() const;

private:
const std::string name_;
private:
const std::string name_;
};
} // namespace hello
2 changes: 1 addition & 1 deletion chapter03/hello_static_lib/src/internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace hello::details {
void print_impl(const std::string &name) {
std::cout << "Hello " << name << " from a shared library\n";
std::cout << "Hello " << name << " from a shared library\n";
}
} // namespace hello::details
Loading

0 comments on commit 7ba4a91

Please sign in to comment.