clang-format: update c/cc coding style
Update all cc code using .clang-format; please do so as well for future PRs etc.; emacs has a handy 'clang-format' mode to make this automatic. For comparing old changes with git blame, we can disregard this one using --ignore-rev (see https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame )
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
|
||||
#include <utils//mu-utils.hh>
|
||||
#include <utils/mu-utils.hh>
|
||||
|
||||
namespace Mu {
|
||||
|
||||
@ -34,17 +34,18 @@ struct Data {
|
||||
enum class Type { Value, Range };
|
||||
virtual ~Data() = default;
|
||||
|
||||
Type type; /**< type of data */
|
||||
std::string field; /**< full name of the field */
|
||||
std::string prefix; /**< Xapian prefix for thef field */
|
||||
unsigned id; /**< Xapian value no for the field */
|
||||
Type type; /**< type of data */
|
||||
std::string field; /**< full name of the field */
|
||||
std::string prefix; /**< Xapian prefix for thef field */
|
||||
unsigned id; /**< Xapian value no for the field */
|
||||
|
||||
protected:
|
||||
Data (Type _type, const std::string& _field, const std::string& _prefix,
|
||||
unsigned _id): type(_type), field(_field), prefix(_prefix), id(_id) {}
|
||||
protected:
|
||||
Data(Type _type, const std::string& _field, const std::string& _prefix, unsigned _id)
|
||||
: type(_type), field(_field), prefix(_prefix), id(_id)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* operator<<
|
||||
*
|
||||
@ -54,7 +55,7 @@ protected:
|
||||
* @return the updated output stream
|
||||
*/
|
||||
inline std::ostream&
|
||||
operator<< (std::ostream& os, Data::Type t)
|
||||
operator<<(std::ostream& os, Data::Type t)
|
||||
{
|
||||
switch (t) {
|
||||
case Data::Type::Value: os << "value"; break;
|
||||
@ -64,11 +65,10 @@ operator<< (std::ostream& os, Data::Type t)
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Range type -- [a..b]
|
||||
*/
|
||||
struct Range: public Data {
|
||||
struct Range : public Data {
|
||||
/**
|
||||
* Construct a range
|
||||
*
|
||||
@ -78,23 +78,26 @@ struct Range: public Data {
|
||||
* @param _lower lower bound
|
||||
* @param _upper upper bound
|
||||
*/
|
||||
Range (const std::string& _field, const std::string& _prefix,
|
||||
unsigned _id,
|
||||
const std::string& _lower,const std::string& _upper):
|
||||
Range(const std::string& _field,
|
||||
const std::string& _prefix,
|
||||
unsigned _id,
|
||||
const std::string& _lower,
|
||||
const std::string& _upper)
|
||||
:
|
||||
|
||||
Data(Data::Type::Range, _field, _prefix, _id),
|
||||
lower(_lower), upper(_upper) {}
|
||||
Data(Data::Type::Range, _field, _prefix, _id), lower(_lower), upper(_upper)
|
||||
{
|
||||
}
|
||||
|
||||
std::string lower; /**< lower bound */
|
||||
std::string upper; /**< upper bound */
|
||||
std::string lower; /**< lower bound */
|
||||
std::string upper; /**< upper bound */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Basic value
|
||||
*
|
||||
*/
|
||||
struct Value: public Data {
|
||||
struct Value : public Data {
|
||||
/**
|
||||
* Construct a Value
|
||||
*
|
||||
@ -103,16 +106,19 @@ struct Value: public Data {
|
||||
* @param _id xapian value number
|
||||
* @param _value the value
|
||||
*/
|
||||
Value (const std::string& _field, const std::string& _prefix,
|
||||
unsigned _id, const std::string& _value, bool _phrase = false):
|
||||
Data(Value::Type::Value, _field, _prefix, _id),
|
||||
value(_value), phrase(_phrase) {}
|
||||
Value(const std::string& _field,
|
||||
const std::string& _prefix,
|
||||
unsigned _id,
|
||||
const std::string& _value,
|
||||
bool _phrase = false)
|
||||
: Data(Value::Type::Value, _field, _prefix, _id), value(_value), phrase(_phrase)
|
||||
{
|
||||
}
|
||||
|
||||
std::string value; /**< the value */
|
||||
bool phrase;
|
||||
std::string value; /**< the value */
|
||||
bool phrase;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* operator<<
|
||||
*
|
||||
@ -122,28 +128,24 @@ struct Value: public Data {
|
||||
* @return the updated output stream
|
||||
*/
|
||||
inline std::ostream&
|
||||
operator<< (std::ostream& os, const std::unique_ptr<Data>& v)
|
||||
operator<<(std::ostream& os, const std::unique_ptr<Data>& v)
|
||||
{
|
||||
switch (v->type) {
|
||||
case Data::Type::Value: {
|
||||
const auto bval = dynamic_cast<Value*> (v.get());
|
||||
os << ' ' << quote(v->field) << ' '
|
||||
<< quote(utf8_flatten(bval->value));
|
||||
const auto bval = dynamic_cast<Value*>(v.get());
|
||||
os << ' ' << quote(v->field) << ' ' << quote(utf8_flatten(bval->value));
|
||||
if (bval->phrase)
|
||||
os << " (ph)";
|
||||
|
||||
break;
|
||||
}
|
||||
case Data::Type::Range: {
|
||||
const auto rval = dynamic_cast<Range*> (v.get());
|
||||
os << ' ' << quote(v->field) << ' '
|
||||
<< quote(rval->lower) << ' '
|
||||
const auto rval = dynamic_cast<Range*>(v.get());
|
||||
os << ' ' << quote(v->field) << ' ' << quote(rval->lower) << ' '
|
||||
<< quote(rval->upper);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
os << "unexpected type";
|
||||
break;
|
||||
default: os << "unexpected type"; break;
|
||||
}
|
||||
|
||||
return os;
|
||||
@ -151,5 +153,4 @@ operator<< (std::ostream& os, const std::unique_ptr<Data>& v)
|
||||
|
||||
} // namespace Mu
|
||||
|
||||
|
||||
#endif /* __DATA_HH__ */
|
||||
|
||||
Reference in New Issue
Block a user