Skip to content

Commit

Permalink
run astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
asartori86 committed Mar 21, 2018
1 parent 7582457 commit 8d762ff
Show file tree
Hide file tree
Showing 103 changed files with 39,726 additions and 28,510 deletions.
95 changes: 95 additions & 0 deletions .clang-format
@@ -0,0 +1,95 @@
---
Language: Cpp
# BasedOnStyle: Chromium
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

201 changes: 112 additions & 89 deletions src/apps/test/testInputKeywords/testInputKeywords.cc
Expand Up @@ -26,123 +26,146 @@
using namespace boost::assign;

template <typename T>
inline bool is_any(const boost::any& op)
inline bool is_any(const boost::any &op)
{
return (op.type() == typeid(T));
return (op.type() == typeid(T));
}

int main(int argc, char *argv[])
{

boost::program_options::options_description usage("Usage"); // name of help function
usage.add_options() //detailed specification of command line interface
("help,h", "this help") // this option return boolean variable and is used to print command line help
("file,f", boost::program_options::value<std::string>(), "input file path");

// map for options/value
boost::program_options::variables_map vm;

// option parsing statements.
try{
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(usage).run(), vm);
boost::program_options::notify(vm);
boost::program_options::options_description usage(
"Usage"); // name of help function
usage.add_options() // detailed specification of command line interface
("help,h", "this help") // this option return boolean variable and is used
// to print command line help
("file,f", boost::program_options::value<std::string>(), "input file path");

// map for options/value
boost::program_options::variables_map vm;

// option parsing statements.
try
{
boost::program_options::store(
boost::program_options::command_line_parser(argc, argv)
.options(usage)
.run(),
vm);
boost::program_options::notify(vm);
}
catch ( boost::program_options::unknown_option &u ){
std::cerr << "Option parsing error: " << u.what() << ": please use only valid flags"<< std::endl;
return 10 ;
catch (boost::program_options::unknown_option &u)
{
std::cerr << "Option parsing error: " << u.what()
<< ": please use only valid flags" << std::endl;
return 10;
}
catch ( boost::program_options::invalid_command_line_syntax &u ){
std::cerr << "Option parsing error: " << u.what() << ": please specificy a valid value for this option "<< std::endl;
return 11 ;
catch (boost::program_options::invalid_command_line_syntax &u)
{
std::cerr << "Option parsing error: " << u.what()
<< ": please specificy a valid value for this option "
<< std::endl;
return 11;
}
catch ( boost::program_options::error &u ){
std::cout << "Option parsing error: " << u.what() << std::endl;
return 12 ;
catch (boost::program_options::error &u)
{
std::cout << "Option parsing error: " << u.what() << std::endl;
return 12;
}
// if no options or --help or -h print help and exit.
if(argc <= 1 || vm.count("help"))

// if no options or --help or -h print help and exit.
if (argc <= 1 || vm.count("help"))
{
std::cout << usage << std::endl;
return 13 ;
std::cout << usage << std::endl;
return 13;
}

std::string lInputFile ;
if (vm.count("file"))
std::string lInputFile;
if (vm.count("file"))
{
lInputFile = vm["file"].as<std::string>();
} else {
std::cerr << "The input file mut be specified, see --file option" << std::endl ;
return 20 ;
lInputFile = vm["file"].as<std::string>();
}
else
{
std::cerr << "The input file mut be specified, see --file option"
<< std::endl;
return 20;
}

boost::filesystem::path lInputFilePath (lInputFile.c_str());
if(not boost::filesystem::exists(lInputFile))
boost::filesystem::path lInputFilePath(lInputFile.c_str());
if (not boost::filesystem::exists(lInputFile))
{
std::cerr << "Input file not found: " << lInputFilePath.string() << std::endl ;
return 21 ;
std::cerr << "Input file not found: " << lInputFilePath.string()
<< std::endl;
return 21;
}

geotop::input::ConfigStore lConfigStore ;
bool lParse = lConfigStore.parse(lInputFilePath.string()) ;
if(not lParse) {
std::cerr << "Error parsing file for: " << lInputFilePath.string() << std::endl ;
return 22 ;
geotop::input::ConfigStore lConfigStore;
bool lParse = lConfigStore.parse(lInputFilePath.string());
if (not lParse)
{
std::cerr << "Error parsing file for: " << lInputFilePath.string()
<< std::endl;
return 22;
}

std::vector<std::string> lVOfKeys = lConfigStore.getKeys() ;
for(size_t i = 0 ; i < lVOfKeys.size(); i++)
std::vector<std::string> lVOfKeys = lConfigStore.getKeys();
for (size_t i = 0; i < lVOfKeys.size(); i++)
{
std::string lName = lVOfKeys[i] ;
boost::any lValue ;
bool lStatus = lConfigStore.getAny(lName, lValue) ;
if (not lStatus) {
std::cerr << "Error getting value for: " << lName << std::endl ;
continue ;
std::string lName = lVOfKeys[i];
boost::any lValue;
bool lStatus = lConfigStore.getAny(lName, lValue);
if (not lStatus)
{
std::cerr << "Error getting value for: " << lName << std::endl;
continue;
}

if(is_any<double>(lValue))
if (is_any<double>(lValue))
{
double lV = boost::any_cast<double>(lValue);
std::cout << lName << ":" << lV << std::endl;
}
else if (is_any<std::string>(lValue))
{
std::string lV = boost::any_cast<std::string>(lValue);
std::cout << lName << ":" << lV << std::endl;
}
else if (is_any<std::vector<double>>(lValue))
{
double lV = boost::any_cast<double>(lValue);
std::cout << lName << ":" << lV << std::endl ;
} else if (is_any<std::string>(lValue)) {
std::string lV = boost::any_cast<std::string>(lValue);
std::cout << lName << ":" << lV << std::endl ;
} else if (is_any<std::vector<double> >(lValue)) {
std::vector<double> lV = boost::any_cast<std::vector<double> >(lValue);
std::cout << lName << ":" ;
for(size_t i = 0; i < lV.size() ; i++){
std::cout << lV[i] ;
if(i < lV.size()-1)
std::cout << "," ;
std::vector<double> lV = boost::any_cast<std::vector<double>>(lValue);
std::cout << lName << ":";
for (size_t i = 0; i < lV.size(); i++)
{
std::cout << lV[i];
if (i < lV.size() - 1) std::cout << ",";
}
std::cout << std::endl ;
std::cout << std::endl;
}

}

/*
std::vector<double> lDecayCoeffCanopyOrig ;
lDecayCoeffCanopyOrig += 1.2,3.4,5.6,7.8,9,10,11,12,13.14 ;
lConfigStore.set("DecayCoeffCanopy", lDecayCoeffCanopyOrig) ;
std::vector<double> lDecayCoeffCanopy ;
lConfigStore.get("DecayCoeffCanopy", lDecayCoeffCanopy) ;
if(not std::equal ( lDecayCoeffCanopyOrig.begin(), lDecayCoeffCanopyOrig.end(), lDecayCoeffCanopy.begin() )) {
std::cerr << "Error: DecayCoeffCanopy : FAILED" << std::endl ;
} else {
std::cout << "Info: DecayCoeffCanopy : OK" << std::endl ;
}
/*
std::vector<double> lDecayCoeffCanopyOrig ;
lDecayCoeffCanopyOrig += 1.2,3.4,5.6,7.8,9,10,11,12,13.14 ;
lConfigStore.set("DecayCoeffCanopy", lDecayCoeffCanopyOrig) ;
std::vector<double> lDecayCoeffCanopy ;
lConfigStore.get("DecayCoeffCanopy", lDecayCoeffCanopy) ;
if(not std::equal ( lDecayCoeffCanopyOrig.begin(),
lDecayCoeffCanopyOrig.end(), lDecayCoeffCanopy.begin() )) { std::cerr <<
"Error: DecayCoeffCanopy : FAILED" << std::endl ; } else { std::cout << "Info:
DecayCoeffCanopy : OK" << std::endl ;
}
std::vector<double> lInitDateDDMMYYYYhhmm ;
lConfigStore.get("InitDateDDMMYYYYhhmm", lInitDateDDMMYYYYhhmm) ;
std::cout << "InitDateDDMMYYYYhhmm: " << std::setprecision(12) <<
lInitDateDDMMYYYYhhmm[0] << std::endl ;
std::vector<double> lInitDateDDMMYYYYhhmm ;
lConfigStore.get("InitDateDDMMYYYYhhmm", lInitDateDDMMYYYYhhmm) ;
std::cout << "InitDateDDMMYYYYhhmm: " << std::setprecision(12) << lInitDateDDMMYYYYhhmm[0] << std::endl ;
std::string lDemFile ;
lConfigStore.get("DemFile", lDemFile) ;
std::cout << "DemFile: " << lDemFile << std::endl ;
*/

std::string lDemFile ;
lConfigStore.get("DemFile", lDemFile) ;
std::cout << "DemFile: " << lDemFile << std::endl ;
*/

return 0 ;
return 0;
}

0 comments on commit 8d762ff

Please sign in to comment.