Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
libtools: reformat code, closes #3674
Browse files Browse the repository at this point in the history
  • Loading branch information
flo91 committed Jan 19, 2022
1 parent 99eb63c commit bebb62a
Show file tree
Hide file tree
Showing 18 changed files with 691 additions and 578 deletions.
3 changes: 1 addition & 2 deletions doc/help/kdb-validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ from the key database has issued warnings.
- `-d`,`--debug`:
Give debug information.
- `-f`, `--force`:
Force writing the configuration even on warnings.
Force writing the configuration even on warnings.
- `-H`, `--help`:
Show the man page.
- `-p <name>`, `--profile <name>`:
Expand All @@ -37,4 +37,3 @@ Force writing the configuration even on warnings.
Print version info.
- `-C <when>`, `--color <when>`:
Print `never/auto(default)/always` colored output.

2 changes: 1 addition & 1 deletion doc/tutorials/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,4 @@ kdb validate /tests/range
kdb rm -r /tests/range/
sudo kdb umount /tests/range

```
```
38 changes: 19 additions & 19 deletions src/libs/tools/include/errors/baseNotification.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef ELEKTRA_BASENOTIFICATION_HPP
#define ELEKTRA_BASENOTIFICATION_HPP

#include <string>
#include <kdbtypes.h>
#include <key.hpp>
#include <string>
#include <utility>
#include <kdbtypes.h>

namespace kdb
{
Expand All @@ -21,20 +21,20 @@ class BaseNotification
{
public:
/* constructor */
BaseNotification (std::string reason, std::string module, std::string file, std::string mountPoint,
std::string configFile, kdb::long_t line);
BaseNotification (std::string reason, std::string module, std::string file, std::string mountPoint, std::string configFile,
kdb::long_t line);

/* setters */
void setData (const std::string & reason, const std::string & module, const std::string & file,
const std::string & mountPoint, const std::string & configFile, kdb::long_t line);
void setData (const std::string & reason, const std::string & module, const std::string & file, const std::string & mountPoint,
const std::string & configFile, kdb::long_t line);

/* get references (for setting and getting member values) */
std::string & reason();
std::string & module();
std::string & file();
std::string & mountPoint();
std::string & configFile();
kdb::long_t & line();
std::string & reason ();
std::string & module ();
std::string & file ();
std::string & mountPoint ();
std::string & configFile ();
kdb::long_t & line ();
const std::string & reason () const;
const std::string & module () const;
const std::string & file () const;
Expand All @@ -43,11 +43,11 @@ class BaseNotification
const kdb::long_t & line () const;

/* fixed values per Class, taken from C-makro definitions in /src/include/kdberrors.h */
virtual std::string code() const = 0;
virtual std::string description() const = 0;
virtual std::string code () const = 0;
virtual std::string description () const = 0;

/* string representation */
friend std::ostream& operator<< (std::ostream& outputStream, const BaseNotification& eb);
friend std::ostream & operator<< (std::ostream & outputStream, const BaseNotification & eb);

/**
* @brief Compare fields of notification objects
Expand All @@ -58,8 +58,8 @@ class BaseNotification
*
* @return true if objects are equal
*/
bool operator== (const BaseNotification& other) const;
bool operator!= (const BaseNotification& other) const;
bool operator== (const BaseNotification & other) const;
bool operator!= (const BaseNotification & other) const;

protected:
BaseNotification () = default;
Expand All @@ -75,7 +75,7 @@ class BaseNotification
*
* @return true if objects are equal
*/
virtual bool compare(const BaseNotification& other) const;
virtual bool compare (const BaseNotification & other) const;

/* Can be overwritten by subclasses to change the text representation */

Expand All @@ -90,7 +90,7 @@ class BaseNotification
*
* @return The given stream with additional text appended.
*/
virtual std::ostream& toString (std::ostream& outputStream) const;
virtual std::ostream & toString (std::ostream & outputStream) const;

private:
std::string m_reason;
Expand Down
42 changes: 29 additions & 13 deletions src/libs/tools/include/errors/error.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef ELEKTRA_ERROR_HPP
#define ELEKTRA_ERROR_HPP

#include <vector>
#include "errors/warning.hpp"
#include <vector>

namespace kdb
{
Expand All @@ -15,10 +15,9 @@ namespace errors
class Error : public BaseNotification
{
public:

/* inherit constructors */
using BaseNotification::BaseNotification;
virtual ~Error();
virtual ~Error ();

/**
* @brief Add a warning to an error
Expand All @@ -39,21 +38,38 @@ class Error : public BaseNotification
kdb::long_t warningCount ();

/* iterator functionality */
std::vector<Warning*>::iterator begin() { return warnings.begin(); }
std::vector<Warning*>::iterator end() { return warnings.end(); }
std::vector<Warning*>::const_iterator begin() const { return warnings.begin(); }
std::vector<Warning*>::const_iterator end() const { return warnings.begin(); }
std::vector<Warning*>::const_iterator cbegin() const { return warnings.cbegin(); }
std::vector<Warning*>::const_iterator cend() const { return warnings.cend(); }
std::vector<Warning *>::iterator begin ()
{
return warnings.begin ();
}
std::vector<Warning *>::iterator end ()
{
return warnings.end ();
}
std::vector<Warning *>::const_iterator begin () const
{
return warnings.begin ();
}
std::vector<Warning *>::const_iterator end () const
{
return warnings.begin ();
}
std::vector<Warning *>::const_iterator cbegin () const
{
return warnings.cbegin ();
}
std::vector<Warning *>::const_iterator cend () const
{
return warnings.cend ();
}

/* get warning by index */
Warning& operator[](int index);
Warning & operator[] (int index);

private:
std::vector<Warning*> warnings;
std::vector<Warning *> warnings;

protected:

/**
* @brief Compare errors
*
Expand All @@ -64,7 +80,7 @@ class Error : public BaseNotification
*
* @return true if objects are equal
*/
bool compare(const BaseNotification& other) const override;
bool compare (const BaseNotification & other) const override;

/**
* @brief Create a text representation of the Error
Expand Down
12 changes: 6 additions & 6 deletions src/libs/tools/include/errors/errorFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ class ErrorFactory
public:
/* takes one of the ELEKTRA_ERROR_* constants (e.g. ELEKTRA_ERROR_OUT_OF_MEMORY)
* from /src/include/kdberrors.h as a parameter */
static Error * create (const std::string & type, const std::string & reason, const std::string & module,
const std::string & file, const std::string & mountPoint, const std::string & configFile, kdb::long_t line);
static Error * create (const std::string & type, const std::string & reason, const std::string & module, const std::string & file,
const std::string & mountPoint, const std::string & configFile, kdb::long_t line);

/**
* @brief Create an error from a given key
*
* Reads meta-keys of given key to find error and warnings meta-keys. If no error exists a PureWarningError is created that contains the
* key's warnings.
* Reads meta-keys of given key to find error and warnings meta-keys. If no error exists a PureWarningError is created that contains
* the key's warnings.
*
* @param key the key that has the error and warnings
*
* @return the error with warnings
*/
static Error * fromKey(kdb::Key key);
static Error * fromKey (kdb::Key key);

/* checks if a code and description fit together */
static bool checkErrorCodeDesc(const std::string & code, const std::string & description);
static bool checkErrorCodeDesc (const std::string & code, const std::string & description);
};

} // namespace errors
Expand Down
76 changes: 43 additions & 33 deletions src/libs/tools/include/errors/errorTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ namespace errors
class PureWarningError : public Error
{
public:
PureWarningError ()
: Error { "No error, only warnings.", "", "", "", "", 0} {}
PureWarningError () : Error{ "No error, only warnings.", "", "", "", "", 0 }
{
}

std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};


Expand All @@ -33,91 +34,100 @@ class ResourceError : public Error
{
public:
using Error::Error;
std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};

class OutOfMemoryError : public Error
{
public:
using Error::Error;
std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};

class InstallationError : public Error
{
public:
using Error::Error;
std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};


class InternalError: public Error
class InternalError : public Error
{
public:
using Error::Error;
std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};

class InterfaceError : public Error
{
public:
using Error::Error;
std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};

class PluginMisbehaviorError : public Error
{
public:
using Error::Error;
std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};

class ConflictingStateError : public Error
{
public:
using Error::Error;
std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};

class ValidationSyntacticError : public Error
{
public:
using Error::Error;
std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};

class ValidationSemanticError : public Error
{
public:
using Error::Error;
std::string code() const override;
std::string description() const override;
std::string code () const override;
std::string description () const override;

private:
bool compare(const BaseNotification& other) const final;
bool compare (const BaseNotification & other) const final;
};

} // namespace errors
Expand Down
5 changes: 2 additions & 3 deletions src/libs/tools/include/errors/warning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ class Warning : public BaseNotification
public:
/* inherit constructors */
using BaseNotification::BaseNotification;
virtual Warning* clone() const = 0;
virtual Warning * clone () const = 0;

/* needed for freeing the elements of the Warning-container in Error-class */
virtual ~Warning () = default;

protected:

/**
* @brief Compare warnings
*
Expand All @@ -35,7 +34,7 @@ class Warning : public BaseNotification
*
* @return true if objects are equal
*/
bool compare(const BaseNotification& other) const override;
bool compare (const BaseNotification & other) const override;
};

} // namespace errors
Expand Down
Loading

0 comments on commit bebb62a

Please sign in to comment.