Uncrustify maxscale

See script directory for method. The script to run in the top level
MaxScale directory is called maxscale-uncrustify.sh, which uses
another script, list-src, from the same directory (so you need to set
your PATH). The uncrustify version was 0.66.
This commit is contained in:
Niclas Antti
2018-09-09 22:26:19 +03:00
parent fa7ec95069
commit c447e5cf15
849 changed files with 35002 additions and 27238 deletions

View File

@ -23,25 +23,29 @@ namespace base
class AppException : public std::runtime_error
{
public:
AppException(const std::string& msg, const std::string& file,
int line) :
std::runtime_error(msg), m_file(file), m_line(line)
{}
AppException(const std::string& msg,
const std::string& file,
int line)
: std::runtime_error(msg)
, m_file(file)
, m_line(line)
{
}
private:
std::string m_file;
int m_line;
int m_line;
};
} //base
} // base
#define DEFINE_EXCEPTION(Type) \
struct Type : public base::AppException { \
Type(const std::string& msg, const char* file, \
int line) : \
AppException(msg, file, line) {}}
Type(const std::string& msg, \
const char* file, \
int line) \
: AppException(msg, file, line) {} }
#define THROW(Type, msg_str) do {\
#define THROW(Type, msg_str) \
do { \
std::ostringstream os; \
os << __FILE__ << ':' << __LINE__ << '\n' << msg_str; \
throw Type(os.str(), __FILE__, __LINE__);} while(false)
throw Type(os.str(), __FILE__, __LINE__);} while (false)

View File

@ -42,5 +42,4 @@ public:
private:
bool m_is_defined;
};
} // base
} // base

View File

@ -38,7 +38,7 @@ Duration StopWatch::restart()
m_start = now;
return lap;
}
} // base
} // base
/********** OUTPUT ***********/
namespace
@ -46,21 +46,20 @@ namespace
using namespace base;
struct TimeConvert
{
double div; // divide the value of the previous unit by this
std::string suffix; // milliseconds, hours etc.
double max_visual; // threashold to switch to the next unit
double div; // divide the value of the previous unit by this
std::string suffix; // milliseconds, hours etc.
double max_visual; // threashold to switch to the next unit
};
// Will never get to centuries because the duration is a long carrying nanoseconds
TimeConvert convert[]
{
{1, "ns", 1000}, {1000, "us", 1000}, {1000, "ms", 1000},
{1, "ns", 1000}, {1000, "us", 1000}, {1000, "ms", 1000},
{1000, "s", 60}, {60, "min", 60}, {60, "hours", 24},
{24, "days", 365.25}, {365.25, "years", 10000},
{100, "centuries", std::numeric_limits<double>::max()}
};
int convert_size = sizeof(convert) / sizeof(convert[0]);
}
namespace base
@ -87,7 +86,7 @@ std::pair<double, std::string> dur_to_human_readable(Duration dur)
}
}
abort(); // should never get here
abort(); // should never get here
}
std::ostream& operator<<(std::ostream& os, Duration dur)
@ -101,12 +100,12 @@ std::ostream& operator<<(std::ostream& os, Duration dur)
// TODO: this will require some thought. time_point_to_string() for a system_clock is
// obvious, but not so for a steady_clock. Maybe TimePoint belongs to a system clock
// and sould be called something else here, and live in a time_measuring namespace.
std::string time_point_to_string(TimePoint tp, const std::string &fmt)
std::string time_point_to_string(TimePoint tp, const std::string& fmt)
{
using namespace std::chrono;
std::time_t timet = system_clock::to_time_t(system_clock::now()
+ (tp - Clock::now()));
struct tm * ptm;
struct tm* ptm;
ptm = gmtime(&timet);
const int sz = 1024;
char buf[sz];
@ -114,30 +113,30 @@ std::string time_point_to_string(TimePoint tp, const std::string &fmt)
return buf;
}
std::ostream & operator<<(std::ostream & os, TimePoint tp)
std::ostream& operator<<(std::ostream& os, TimePoint tp)
{
os << time_point_to_string(tp);
return os;
}
void test_stopwatch_output(std::ostream & os)
void test_stopwatch_output(std::ostream& os)
{
long long dur[] =
{
400, // 400ns
5 * 1000, // 5us
500 * 1000, // 500us
1 * 1000000, // 1ms
700 * 1000000LL, // 700ms
5 * 1000000000LL, // 5s
200 * 1000000000LL, // 200s
5 * 60 * 1000000000LL, // 5m
45 * 60 * 1000000000LL, // 45m
130 * 60 * 1000000000LL, // 130m
24 * 60 * 60 * 1000000000LL, // 24 hours
3 * 24 * 60 * 60 * 1000000000LL, // 72 hours
180 * 24 * 60 * 60 * 1000000000LL, // 180 days
1000 * 24 * 60 * 60 * 1000000000LL // 1000 days
400, // 400ns
5 * 1000, // 5us
500 * 1000, // 500us
1 * 1000000, // 1ms
700 * 1000000LL, // 700ms
5 * 1000000000LL, // 5s
200 * 1000000000LL, // 200s
5 * 60 * 1000000000LL, // 5m
45 * 60 * 1000000000LL, // 45m
130 * 60 * 1000000000LL, // 130m
24 * 60 * 60 * 1000000000LL, // 24 hours
3 * 24 * 60 * 60 * 1000000000LL, // 72 hours
180 * 24 * 60 * 60 * 1000000000LL, // 180 days
1000 * 24 * 60 * 60 * 1000000000LL // 1000 days
};
for (unsigned i = 0; i < sizeof(dur) / sizeof(dur[0]); ++i)
@ -145,4 +144,4 @@ void test_stopwatch_output(std::ostream & os)
os << Duration(dur[i]) << std::endl;
}
}
} // base
} // base

View File

@ -21,11 +21,13 @@ namespace base
{
using Clock = std::chrono::steady_clock;
struct Duration : public Clock::duration // for ADL
struct Duration : public Clock::duration // for ADL
{
using Clock::duration::duration;
Duration() = default;
Duration(Clock::duration d) : Clock::duration(d) {}
Duration(Clock::duration d) : Clock::duration(d)
{
}
};
using TimePoint = std::chrono::time_point<Clock, Duration>;
@ -50,7 +52,6 @@ std::pair<double, std::string> dur_to_human_readable(Duration dur);
std::ostream& operator<<(std::ostream&, Duration dur);
// TimePoint
std::string time_point_to_string(TimePoint tp, const std::string& fmt = "%F %T");
std::string time_point_to_string(TimePoint tp, const std::string& fmt = "%F %T");
std::ostream& operator<<(std::ostream&, TimePoint tp);
} // base
} // base