Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
harryherold committed Jun 12, 2019
1 parent 3b4b5f6 commit d20cc02
Show file tree
Hide file tree
Showing 15 changed files with 1,447 additions and 1,323 deletions.
46 changes: 23 additions & 23 deletions otf2_merger.clang-format
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
// All these settings have been taken from the clang-format manual,
// and can be customised form within Sublime Text settings files.
// Please note, the defaults set below are completely random values.
// Take a look at http://clang.llvm.org/docs/ClangFormatStyleOptions.html
// For examples.

// The style used for all options not specifically set in the configuration.
// Possible "values":
// LLVM
// Google
// Chromium
// Mozilla
// WebKit
"BasedOnStyle": "LLVM",
// All these settings have been taken from the clang-format manual,
// and can be customised form within Sublime Text settings files.
// Please note, the defaults set below are completely random values.
// Take a look at http://clang.llvm.org/docs/ClangFormatStyleOptions.html
// For examples.

// The style used for all options not specifically set in the configuration.
// Possible "values":
// LLVM
// Google
// Chromium
// Mozilla
// WebKit
"BasedOnStyle": "LLVM",

// The extra indent or outdent of access modifiers, e.g. "public":.
// "AccessModifierOffset": 2,
Expand Down Expand Up @@ -399,14 +399,14 @@
// LS_Auto (in "configuration": Auto) Automatic detection based on the input.
"Standard": "Cpp11",

// The number of columns used for tab stops.
// "TabWidth": 2,
// The number of columns used for tab stops.
// "TabWidth": 2,

// The way to use tab characters in the resulting file.
// Possible "values":
// UT_Never (in "configuration": Never) Never use tab. UT_ForIndentation (in
// "configuration": ForIndentation) Use tabs only for indentation. UT_Always
// (in "configuration": Always) Use tabs whenever we need to fill whitespace
// that spans at least from one tab stop to the next one.
// "UseTab": "Never"
// The way to use tab characters in the resulting file.
// Possible "values":
// UT_Never (in "configuration": Never) Never use tab. UT_ForIndentation (in
// "configuration": ForIndentation) Use tabs only for indentation. UT_Always
// (in "configuration": Always) Use tabs whenever we need to fill whitespace
// that spans at least from one tab stop to the next one.
// "UseTab": "Never"
}
89 changes: 48 additions & 41 deletions src/config.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#include <config.h>

Config::Config(int argc, char** argv) : m_argc{argc}, m_argv{argv} {};
Config::Config(int argc, char **argv) : m_argc{argc}, m_argv{argv} {};

void Config::help() {
std::cout << "OTF2 Merger v1.0 unifies multiple input traces into absolute one. \n\n";
std::cout << "OTF2 Merger v1.0 unifies multiple input traces into absolute "
"one. \n\n";

std::cout
<< "Commands:\n\n"
" --traceFile <tfile>: Set trace files with absloute paths. (req.)\n"
" --commGroupPattern <pname>: Provide a pattern name, to be followed by comm and group defintions in the unified trace. (req.)\n"
" --outputPath <path>: Set an output trace path. (req.)\n"
" --mergedTraceName <tname>: Set an output trace name, by default \"traces\". \n"
" --version: Display otf2 merger version.\n"
" --help: Show help. \n\n";
<< "Commands:\n\n"
" --traceFile <tfile>: Set trace files with absloute paths. (req.)\n"
" --commGroupPattern <pname>: Provide a pattern name, to be followed "
"by comm and group defintions in the unified trace. (req.)\n"
" --outputPath <path>: Set an output trace path. (req.)\n"
" --mergedTraceName <tname>: Set an output trace name, by default "
"\"traces\". \n"
" --version: Display otf2 merger version.\n"
" --help: Show help. \n\n";
std::cout << "Required (req.)\n";
exit(1);
}
Expand All @@ -25,50 +28,54 @@ void Config::processArgs() {
std::string mergedTraceName{" "};
m_archive_name = "traces";

const char* const short_opts = "f:n:o::m:v:h";
const char *const short_opts = "f:n:o::m:v:h";

const option long_opts[] = {{"traceFile", required_argument, nullptr, 'f'},
{"commGroupPattern", required_argument, nullptr, 'n'},
{"outputPath", required_argument, nullptr, 'o'},
{"mergedTraceName", required_argument, nullptr, 'm'},
{"version", no_argument, nullptr, 'v'},
{"help", no_argument, nullptr, 'h'},
{nullptr, no_argument, nullptr, 0}};
const option long_opts[] = {
{"traceFile", required_argument, nullptr, 'f'},
{"commGroupPattern", required_argument, nullptr, 'n'},
{"outputPath", required_argument, nullptr, 'o'},
{"mergedTraceName", required_argument, nullptr, 'm'},
{"version", no_argument, nullptr, 'v'},
{"help", no_argument, nullptr, 'h'},
{nullptr, no_argument, nullptr, 0}};

while (true) {
const auto opt = getopt_long_only(m_argc, m_argv, short_opts, long_opts, nullptr);
const auto opt =
getopt_long_only(m_argc, m_argv, short_opts, long_opts, nullptr);

if (-1 == opt) break;
if (-1 == opt)
break;

switch (opt) {
case 'f':
m_trace_files.push_back(std::string(optarg));
break;
case 'f':
m_trace_files.push_back(std::string(optarg));
break;

case 'n':
m_comm_group_pattern = std::string(optarg);
break;
case 'n':
m_comm_group_pattern = std::string(optarg);
break;

case 'o':
m_archive_path = std::string(optarg);
break;
case 'o':
m_archive_path = std::string(optarg);
break;

case 'm':
m_archive_name = std::string(optarg);
break;
case 'm':
m_archive_name = std::string(optarg);
break;

case 'v':
std::cout << " OTF2_MERGER v1.0 \n";
exit(0);
break;
case 'v':
std::cout << " OTF2_MERGER v1.0 \n";
exit(0);
break;

case 'h': // -h or --help
case '?': // Unrecognized option
case 'h': // -h or --help
case '?': // Unrecognized option

default:
help();
break;
default:
help();
break;
}
}
if (m_trace_files.size() == 0) help();
if (m_trace_files.size() == 0)
help();
}
Loading

0 comments on commit d20cc02

Please sign in to comment.