Skip to content

Commit

Permalink
Clang format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
jfantinhardesty committed Jun 11, 2024
1 parent 53114db commit 38f460c
Show file tree
Hide file tree
Showing 138 changed files with 4,338 additions and 3,493 deletions.
38 changes: 22 additions & 16 deletions nx_kit/src/ini_config_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,48 @@
*/

#if !defined(__cplusplus)
#include <stdbool.h>
#include <stdbool.h>
#endif // !defined(__cplusplus)

#if defined(__cplusplus)
extern "C" {
extern "C"
{
#endif

#define NX_INI_FLAG(DEFAULT, PARAM, DESCR) bool PARAM
#define NX_INI_INT(DEFAULT, PARAM, DESCR) int PARAM
#define NX_INI_STRING(DEFAULT, PARAM, DESCR) const char* PARAM
#define NX_INI_STRING(DEFAULT, PARAM, DESCR) const char *PARAM
#define NX_INI_FLOAT(DEFAULT, PARAM, DESCR) float PARAM

struct Ini NX_INI_STRUCT; //< Ini struct definition: expands using the macros defined above.
struct Ini NX_INI_STRUCT; //< Ini struct definition: expands using the macros defined above.

#undef NX_INI_FLAG
#undef NX_INI_INT
#undef NX_INI_STRING
#undef NX_INI_FLOAT

enum NxIniOutput { NX_INI_OUTPUT_NONE, NX_INI_OUTPUT_STDOUT, NX_INI_OUTPUT_STDERR };
enum NxIniOutput
{
NX_INI_OUTPUT_NONE,
NX_INI_OUTPUT_STDOUT,
NX_INI_OUTPUT_STDERR
};

#if !defined(NX_KIT_C_API)
#define NX_KIT_C_API
#define NX_KIT_C_API
#endif

NX_KIT_C_API extern struct Ini ini; //< Declaration of Ini instance global variable.
NX_KIT_C_API extern struct Ini ini; //< Declaration of Ini instance global variable.

// See the documentation of the respective methods of class IniConfig in "ini_config.h".
NX_KIT_C_API bool nx_ini_isEnabled(void);
NX_KIT_C_API void nx_ini_setOutput(enum NxIniOutput output);
NX_KIT_C_API void nx_ini_reload(void);
NX_KIT_C_API const char* nx_ini_iniFile(void);
NX_KIT_C_API void nx_ini_setIniFilesDir(const char* value);
NX_KIT_C_API const char* nx_ini_iniFilesDir(void);
NX_KIT_C_API const char* nx_ini_iniFilePath(void);
// See the documentation of the respective methods of class IniConfig in "ini_config.h".
NX_KIT_C_API bool nx_ini_isEnabled(void);
NX_KIT_C_API void nx_ini_setOutput(enum NxIniOutput output);
NX_KIT_C_API void nx_ini_reload(void);
NX_KIT_C_API const char *nx_ini_iniFile(void);
NX_KIT_C_API void nx_ini_setIniFilesDir(const char *value);
NX_KIT_C_API const char *nx_ini_iniFilesDir(void);
NX_KIT_C_API const char *nx_ini_iniFilePath(void);

#if defined(__cplusplus)
} // extern "C"
} // extern "C"
#endif
56 changes: 29 additions & 27 deletions nx_kit/src/ini_config_c_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,24 @@ using nx::kit::IniConfig;

struct Ini ini; //< Definition of Ini instance global variable.

namespace {
namespace
{

struct CppIni: public IniConfig
struct CppIni : public IniConfig
{
CppIni(): IniConfig(NX_INI_FILE)
{
// Call reg...Param() for each param, and assign default values.

#undef NX_INI_FLAG
#undef NX_INI_INT
#undef NX_INI_STRING
#undef NX_INI_FLOAT

#define NX_INI_FLAG(DEFAULT, PARAM, DESCR) \
pIni->PARAM = regBoolParam(&pIni->PARAM, (DEFAULT), #PARAM, (DESCR))
#define NX_INI_INT(DEFAULT, PARAM, DESCR) \
pIni->PARAM = regIntParam(&pIni->PARAM, (DEFAULT), #PARAM, (DESCR))
#define NX_INI_STRING(DEFAULT, PARAM, DESCR) \
pIni->PARAM = regStringParam(&pIni->PARAM, (DEFAULT), #PARAM, (DESCR))
#define NX_INI_FLOAT(DEFAULT, PARAM, DESCR) \
pIni->PARAM = regFloatParam(&pIni->PARAM, (DEFAULT), #PARAM, (DESCR))
// Call reg...Param() for each param, and assign default values.

#undef NX_INI_FLAG
#undef NX_INI_INT
#undef NX_INI_STRING
#undef NX_INI_FLOAT

#define NX_INI_FLAG(DEFAULT, PARAM, DESCR) pIni->PARAM = regBoolParam(&pIni->PARAM, (DEFAULT), #PARAM, (DESCR))
#define NX_INI_INT(DEFAULT, PARAM, DESCR) pIni->PARAM = regIntParam(&pIni->PARAM, (DEFAULT), #PARAM, (DESCR))
#define NX_INI_STRING(DEFAULT, PARAM, DESCR) pIni->PARAM = regStringParam(&pIni->PARAM, (DEFAULT), #PARAM, (DESCR))
#define NX_INI_FLOAT(DEFAULT, PARAM, DESCR) pIni->PARAM = regFloatParam(&pIni->PARAM, (DEFAULT), #PARAM, (DESCR))

NX_INI_STRUCT //< Fields initialization: expands using the macros defined above.
}
Expand All @@ -51,12 +48,17 @@ void nx_ini_setOutput(NxIniOutput output)
{
switch (output)
{
case NX_INI_OUTPUT_NONE: IniConfig::setOutput(nullptr); break;
case NX_INI_OUTPUT_STDOUT: IniConfig::setOutput(&std::cout); break;
case NX_INI_OUTPUT_STDERR: IniConfig::setOutput(&std::cerr); break;
default:
std::cerr << "nx_ini_setOutput(): INTERNAL ERROR: Invalid NxIniOutput: "
<< output << std::endl;
case NX_INI_OUTPUT_NONE:
IniConfig::setOutput(nullptr);
break;
case NX_INI_OUTPUT_STDOUT:
IniConfig::setOutput(&std::cout);
break;
case NX_INI_OUTPUT_STDERR:
IniConfig::setOutput(&std::cerr);
break;
default:
std::cerr << "nx_ini_setOutput(): INTERNAL ERROR: Invalid NxIniOutput: " << output << std::endl;
}
}

Expand All @@ -65,22 +67,22 @@ void nx_ini_reload()
cppIni.reload();
}

const char* nx_ini_iniFile()
const char *nx_ini_iniFile()
{
return cppIni.iniFile();
}

void nx_ini_setIniFilesDir(const char* value)
void nx_ini_setIniFilesDir(const char *value)
{
IniConfig::setIniFilesDir(value);
}

const char* nx_ini_iniFilesDir()
const char *nx_ini_iniFilesDir()
{
return IniConfig::iniFilesDir();
}

const char* nx_ini_iniFilePath()
const char *nx_ini_iniFilePath()
{
return cppIni.iniFilePath();
}
Loading

0 comments on commit 38f460c

Please sign in to comment.