Skip to content

Commit

Permalink
Apply clang-format Llvm on C++ code
Browse files Browse the repository at this point in the history
run-clang-tidy -checks='-*,modernize-concat-nested-namespaces' -fix
  • Loading branch information
ClausKlein committed Sep 7, 2024
1 parent 1e7f332 commit a95952c
Show file tree
Hide file tree
Showing 103 changed files with 398 additions and 475 deletions.
2 changes: 1 addition & 1 deletion chapter01/policy_example/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
int main(int, char **) { return 0; }
int main(int, char **) { return 0; }
2 changes: 1 addition & 1 deletion chapter01/simple_executable/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
int main(int, char **) {
std::cout << "Welcome to CMake Best Practices\n";
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

#include <framework/components/component_interface.hpp>

namespace framework {
namespace components {
namespace framework::components {

/**
* @brief Component 1 interface
Expand Down Expand Up @@ -43,5 +42,4 @@ class component1 : public component_interface {
*/
virtual int do_other_stuff(int param) override;
}; // class component1
} // namespace components
} // namespace framework
} // namespace framework::components
6 changes: 2 additions & 4 deletions chapter02/component1/src/component1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

#include <iostream>

namespace framework {
namespace components {
namespace framework::components {

component1::component1() {
std::cout << "Component 1 is constructed" << std::endl;
Expand All @@ -24,5 +23,4 @@ component1::~component1() {
bool component1::do_stuff() const { return false; }

int component1::do_other_stuff(int param) { return param; }
} // namespace components
} // namespace framework
} // namespace framework::components
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

#include <framework/components/component_interface.hpp>

namespace framework {
namespace components {
namespace framework::components {

/**
* @brief Component 1 interface
Expand Down Expand Up @@ -43,5 +42,4 @@ class component2 : public component_interface {
*/
virtual int do_other_stuff(int param) override;
}; // class component2
} // namespace components
} // namespace framework
} // namespace framework::components
6 changes: 2 additions & 4 deletions chapter02/component2/src/component2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include <cmath>
#include <iostream>

namespace framework {
namespace components {
namespace framework::components {

component2::component2() {
std::cout << "Component 2 is constructed" << std::endl;
Expand All @@ -25,5 +24,4 @@ component2::~component2() {
bool component2::do_stuff() const { return true; }

int component2::do_other_stuff(int param) { return std::sqrt(param) * 2; }
} // namespace components
} // namespace framework
} // namespace framework::components
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

#pragma once

namespace framework {
namespace components {
namespace framework::components {
/**
* @brief Component interface
*/
Expand All @@ -35,5 +34,4 @@ class component_interface {
*/
virtual int do_other_stuff(int param) = 0;
}; // class component_interface
} // namespace components
} // namespace framework
} // namespace framework::components
2 changes: 1 addition & 1 deletion chapter02/driver_app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ int main(void) {
}

return component_1->do_other_stuff(1) + component_2->do_other_stuff(3);
}
}
2 changes: 1 addition & 1 deletion chapter02/simple_example/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
int main(int, char **) {
std::cout << "Welcome to CMake Best Practices\n";
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
#include <iostream>
#include <string>

namespace hello_header_only
{
void print_hello(const std::string& name) {
std::cout << "Hello " << name << " from a header only library\n";
}
}
namespace hello_header_only {
void print_hello(const std::string &name) {
std::cout << "Hello " << name << " from a header only library\n";
}
} // namespace hello_header_only
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class HelloObject {
private:
const std::string name_;
};
} // namespace hello_object
} // 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 @@ -6,4 +6,4 @@ namespace hello_object {
void HelloObject::greet() const {
std::cout << "Hello " << name_ << " From an object library\n";
}
} // namespace hello_object
} // namespace hello_object
24 changes: 12 additions & 12 deletions chapter03/hello_shared_lib/include/hello/hello.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#pragma once
#pragma once

#include <string>
#include "hello/export_hello.hpp"
#include <string>

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} {}

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} {}
void greet() const;

void greet() const;
private:
const std::string name_;
};
}
private:
const std::string name_;
};
} // namespace hello
8 changes: 3 additions & 5 deletions chapter03/hello_shared_lib/src/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "internal.hpp"

namespace hello{
void Hello::greet() const {
details::print_impl(name_);
}
}
namespace hello {
void Hello::greet() const { details::print_impl(name_); }
} // namespace hello
11 changes: 5 additions & 6 deletions chapter03/hello_shared_lib/src/internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

#include <iostream>

namespace hello::details{
void print_impl(const std::string& name)
{
std::cout << "Hello " << name << " from a shared library\n";
}
}
namespace hello::details {
void print_impl(const std::string &name) {
std::cout << "Hello " << name << " from a shared library\n";
}
} // namespace hello::details
10 changes: 5 additions & 5 deletions chapter03/hello_shared_lib/src/internal.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
#pragma once

#include <string>

namespace hello::details{
namespace hello::details {

void print_impl(const std::string& name);
}
void print_impl(const std::string &name);

}
25 changes: 13 additions & 12 deletions chapter03/hello_simple_library_example/include/hello/hello.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#pragma once
#pragma once

#include <string>

namespace hello{
/// Example class that is explicitly exported into a dll
class Hello {
public:
Hello(const std::string& name) : name_{name} {}

void greet() const;
private:
const std::string name_;
};
}
namespace hello {
/// Example class that is explicitly exported into a dll
class Hello {
public:
Hello(const std::string &name) : name_{name} {}

void greet() const;

private:
const std::string name_;
};
} // namespace hello
8 changes: 3 additions & 5 deletions chapter03/hello_simple_library_example/src/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "internal.hpp"

namespace hello{
void Hello::greet() const {
details::print_impl(name_);
}
}
namespace hello {
void Hello::greet() const { details::print_impl(name_); }
} // namespace hello
11 changes: 5 additions & 6 deletions chapter03/hello_simple_library_example/src/internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

#include <iostream>

namespace hello::details{
void print_impl(const std::string& name)
{
std::cout << "Hello " << name << " from a shared library\n";
}
}
namespace hello::details {
void print_impl(const std::string &name) {
std::cout << "Hello " << name << " from a shared library\n";
}
} // namespace hello::details
10 changes: 5 additions & 5 deletions chapter03/hello_simple_library_example/src/internal.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
#pragma once

#include <string>

namespace hello::details{
namespace hello::details {

void print_impl(const std::string& name);
}
void print_impl(const std::string &name);

}
25 changes: 13 additions & 12 deletions chapter03/hello_static_lib/include/hello/hello.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#pragma once
#pragma once

#include <string>

namespace hello{
/// Example class that is explicitly exported into a dll
class Hello {
public:
Hello(const std::string& name) : name_{name} {}

void greet() const;
private:
const std::string name_;
};
}
namespace hello {
/// Example class that is explicitly exported into a dll
class Hello {
public:
Hello(const std::string &name) : name_{name} {}

void greet() const;

private:
const std::string name_;
};
} // namespace hello
8 changes: 3 additions & 5 deletions chapter03/hello_static_lib/src/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "internal.hpp"

namespace hello{
void Hello::greet() const {
details::print_impl(name_);
}
}
namespace hello {
void Hello::greet() const { details::print_impl(name_); }
} // namespace hello
11 changes: 5 additions & 6 deletions chapter03/hello_static_lib/src/internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

#include <iostream>

namespace hello::details{
void print_impl(const std::string& name)
{
std::cout << "Hello " << name << " from a shared library\n";
}
}
namespace hello::details {
void print_impl(const std::string &name) {
std::cout << "Hello " << name << " from a shared library\n";
}
} // namespace hello::details
10 changes: 5 additions & 5 deletions chapter03/hello_static_lib/src/internal.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
#pragma once

#include <string>

namespace hello::details{
namespace hello::details {

void print_impl(const std::string& name);
}
void print_impl(const std::string &name);

}
5 changes: 1 addition & 4 deletions chapter03/hello_world_standalone/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#include <iostream>

int main(int, char**)
{
std::cout << "Welcome to chapter 3\n";
}
int main(int, char **) { std::cout << "Welcome to chapter 3\n"; }
2 changes: 1 addition & 1 deletion chapter03/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ int main(int, char **) {
hello::Hello hello("Jane Doe");
hello.greet();
return 0;
}
}
4 changes: 1 addition & 3 deletions chapter04/ex01_executable/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@

#include <iostream>

int main(void) {
std::cout << "Hello from Chapter 4 executable!" << std::endl;
}
int main(void) { std::cout << "Hello from Chapter 4 executable!" << std::endl; }
Loading

0 comments on commit a95952c

Please sign in to comment.