Astyle code formatting
authorJan Olszak <j.olszak@samsung.com>
Tue, 18 Mar 2014 10:40:44 +0000 (11:40 +0100)
committerJan Olszak <j.olszak@samsung.com>
Mon, 19 May 2014 11:47:15 +0000 (13:47 +0200)
[Issue#]      PSDAC-64
[Bug]         N/A
[Cause]       N/A
[Solution]    N/A
[Verfication] run astyle --options=./astylerc --recursive ./*.cpp ./*.hpp
              all files unchanged

Change-Id: I5e0474568d623fcb70c2f8fb7a05ad948c73187d

README
astylerc [new file with mode: 0644]
src/server/include/scs-configuration.hpp
src/server/src/main.cpp
src/server/unit_tests/ut-scs-configuration.cpp

diff --git a/README b/README
index 2337122..d194922 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,18 @@
-Documentation.
+# Documentation
 
-Generate documentation by executing command generate_documentation.sh from doc directory.
-Documentation will be generated in doc/html directory.
+Generate documentation by executing command generate_documentation.sh
+from doc directory. Documentation will be generated in doc/html directory.
 There is also GUI tool named doxywizard.
 
+    cd ./doc
+    ./generate_documentation.sh
+
+
+# Code formatting
+
+We use astyle for code formatting.
+Get the latest version from http://sourceforge.net/projects/astyle/files/astyle/
+(at least v2.04). You can find the options file in the root of the project.
+For example to format all .cpp and .hpp files run in the project directory:
+
+    astyle --options=./astylerc --recursive ./*.cpp ./*.hpp
diff --git a/astylerc b/astylerc
new file mode 100644 (file)
index 0000000..eecd3ee
--- /dev/null
+++ b/astylerc
@@ -0,0 +1,14 @@
+style=stroustrup
+suffix=none
+indent=spaces=4
+indent-col1-comments
+min-conditional-indent=2
+max-instatement-indent=40
+pad-oper
+pad-header
+unpad-paren
+align-pointer=type
+align-reference=type
+add-brackets
+keep-one-line-statements
+convert-tabs
index 785dc91..332b9bf 100644 (file)
@@ -34,8 +34,7 @@
 
 namespace security_containers {
 
-enum class ConfigProcessMode : int
-{
+enum class ConfigProcessMode : int {
     Read,
     Write
 };
@@ -89,8 +88,7 @@ enum class ConfigProcessMode : int
     // use parsed object:
     std::cout << config.bar;
 */
-class ConfigurationBase
-{
+class ConfigurationBase {
 public:
     virtual ~ConfigurationBase() {}
 
@@ -163,7 +161,7 @@ protected:
         }
         int len = json_object_array_length(array);
         val.resize(len);
-        for (int i = 0; i<len; ++i) {
+        for (int i = 0; i < len; ++i) {
             val[i] = getValueFromJsonObj<T>(json_object_array_get_idx(array, i));
         }
     }
@@ -223,7 +221,7 @@ protected:
 
         int len = json_object_array_length(obj);
         val.resize(len);
-        for (int i = 0; i<len; ++i) {
+        for (int i = 0; i < len; ++i) {
             json_object* arrayObj = json_object_array_get_idx(obj, i);
             val[i].process(arrayObj, ConfigProcessMode::Read);
         }
index 6fd1fe7..699c1a6 100644 (file)
@@ -29,8 +29,8 @@
 namespace po = boost::program_options;
 
 namespace {
-    const std::string PROGRAM_NAME_AND_VERSION =
-            "Security Containers Server " PROGRAM_VERSION;
+const std::string PROGRAM_NAME_AND_VERSION =
+    "Security Containers Server " PROGRAM_VERSION;
 }
 
 int main(int argc, char* argv[])
@@ -38,8 +38,8 @@ int main(int argc, char* argv[])
     po::options_description desc("Allowed options");
 
     desc.add_options()
-        ("help,h", "print this help")
-        ("version,v", "show application version")
+    ("help,h", "print this help")
+    ("version,v", "show application version")
     ;
 
     po::variables_map vm;
@@ -52,7 +52,7 @@ int main(int argc, char* argv[])
     if (!unrecognized_options.empty()) {
         std::cout << "Unrecognized options: ";
 
-        for (auto& uo: unrecognized_options) {
+        for (auto& uo : unrecognized_options) {
             std::cout << ' ' << uo;
         }
 
index 661a17e..59dad02 100644 (file)
@@ -30,15 +30,12 @@ using namespace security_containers;
 
 BOOST_AUTO_TEST_SUITE(ConfigSuite)
 
-struct TestConfig : public ConfigurationBase
-{
+struct TestConfig : public ConfigurationBase {
     // subtree class
-    struct SubConfig : public ConfigurationBase
-    {
+    struct SubConfig : public ConfigurationBase {
         int intVal;
 
-        CONFIG_REGISTER
-        {
+        CONFIG_REGISTER {
             CONFIG_VALUE(intVal)
         }
 
@@ -60,8 +57,7 @@ struct TestConfig : public ConfigurationBase
     SubConfig subObj;
     std::vector<SubConfig> subVector;
 
-    CONFIG_REGISTER
-    {
+    CONFIG_REGISTER {
         CONFIG_VALUE(intVal)
         CONFIG_VALUE(stringVal)
         CONFIG_VALUE(floatVal)