Apply clang-tidy fix 'modernize-use-auto'

This commit is contained in:
Gunnar Beutner 2018-01-04 09:07:03 +01:00
parent d6062eefbf
commit e3ad0be769
42 changed files with 87 additions and 87 deletions

View File

@ -56,7 +56,7 @@ public:
pUrl = new Url(argv[1].ToStdString());
}
MainForm *m = new MainForm(nullptr, pUrl);
auto *m = new MainForm(nullptr, pUrl);
m->Show();
return true;

View File

@ -51,7 +51,7 @@ String Base64::Decode(const String& input)
BIO_push(bio64, biomem);
BIO_set_flags(bio64, BIO_FLAGS_BASE64_NO_NL);
char *outbuf = new char[input.GetLength()];
auto *outbuf = new char[input.GetLength()];
size_t len = 0;
int rc;

View File

@ -97,7 +97,7 @@ public:
bool ValidateName(const String& type, const String& name) const override
{
Type::Ptr ptype = Type::GetByName(type);
ConfigType *dtype = dynamic_cast<ConfigType *>(ptype.get());
auto *dtype = dynamic_cast<ConfigType *>(ptype.get());
if (!dtype)
return false;
@ -503,7 +503,7 @@ void ConfigObject::DumpObjects(const String& filename, int attributeTypes)
StdioStream::Ptr sfp = new StdioStream(&fp, false);
for (const Type::Ptr& type : Type::GetAllTypes()) {
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
auto *dtype = dynamic_cast<ConfigType *>(type.get());
if (!dtype)
continue;
@ -605,7 +605,7 @@ void ConfigObject::RestoreObjects(const String& filename, int attributeTypes)
unsigned long no_state = 0;
for (const Type::Ptr& type : Type::GetAllTypes()) {
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
auto *dtype = dynamic_cast<ConfigType *>(type.get());
if (!dtype)
continue;
@ -627,7 +627,7 @@ void ConfigObject::RestoreObjects(const String& filename, int attributeTypes)
void ConfigObject::StopObjects()
{
for (const Type::Ptr& type : Type::GetAllTypes()) {
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
auto *dtype = dynamic_cast<ConfigType *>(type.get());
if (!dtype)
continue;
@ -641,7 +641,7 @@ void ConfigObject::StopObjects()
void ConfigObject::DumpModifiedAttributes(const std::function<void(const ConfigObject::Ptr&, const String&, const Value&)>& callback)
{
for (const Type::Ptr& type : Type::GetAllTypes()) {
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
auto *dtype = dynamic_cast<ConfigType *>(type.get());
if (!dtype)
continue;
@ -703,7 +703,7 @@ void ConfigObject::DumpModifiedAttributes(const std::function<void(const ConfigO
ConfigObject::Ptr ConfigObject::GetObject(const String& type, const String& name)
{
Type::Ptr ptype = Type::GetByName(type);
ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
if (!ctype)
return nullptr;

View File

@ -82,7 +82,7 @@ public:
static intrusive_ptr<T> GetObject(const String& name)
{
typedef TypeImpl<T> ObjType;
ObjType *ptype = static_cast<ObjType *>(T::TypeInstance.get());
auto *ptype = static_cast<ObjType *>(T::TypeInstance.get());
return static_pointer_cast<T>(ptype->GetObject(name));
}

View File

@ -51,7 +51,7 @@ void ConfigType::RegisterObject(const ConfigObject::Ptr& object)
if (it->second == object)
return;
Type *type = dynamic_cast<Type *>(this);
auto *type = dynamic_cast<Type *>(this);
BOOST_THROW_EXCEPTION(ScriptError("An object with type '" + type->GetName() + "' and name '" + name + "' already exists (" +
Convert::ToString(it->second->GetDebugInfo()) + "), new declaration: " + Convert::ToString(object->GetDebugInfo()),

View File

@ -58,8 +58,8 @@ inline void *cast_exception(void *obj, const std::type_info *src, const std::typ
else
return nullptr;
#else /* __GLIBCXX__ */
const libcxx_type_info *srcInfo = static_cast<const libcxx_type_info *>(src);
const libcxx_type_info *dstInfo = static_cast<const libcxx_type_info *>(dst);
const auto *srcInfo = static_cast<const libcxx_type_info *>(src);
const auto *dstInfo = static_cast<const libcxx_type_info *>(dst);
void *adj = obj;
@ -104,7 +104,7 @@ void icinga::RethrowUncaughtException()
extern "C"
void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *))
{
std::type_info *tinfo = static_cast<std::type_info *>(pvtinfo);
auto *tinfo = static_cast<std::type_info *>(pvtinfo);
typedef void (*cxa_throw_fn)(void *, std::type_info *, void (*)(void *)) __attribute__((noreturn));
static cxa_throw_fn real_cxa_throw;
@ -120,7 +120,7 @@ void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *))
#ifndef NO_CAST_EXCEPTION
void *uex = cast_exception(obj, tinfo, &typeid(user_error));
boost::exception *ex = reinterpret_cast<boost::exception *>(cast_exception(obj, tinfo, &typeid(boost::exception)));
auto *ex = reinterpret_cast<boost::exception *>(cast_exception(obj, tinfo, &typeid(boost::exception)));
if (!uex) {
#endif /* NO_CAST_EXCEPTION */
@ -171,14 +171,14 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta
String message = ex.what();
const ValidationError *vex = dynamic_cast<const ValidationError *>(&ex);
const auto *vex = dynamic_cast<const ValidationError *>(&ex);
if (message.IsEmpty())
result << boost::diagnostic_information(ex) << "\n";
else
result << "Error: " << message << "\n";
const ScriptError *dex = dynamic_cast<const ScriptError *>(&ex);
const auto *dex = dynamic_cast<const ScriptError *>(&ex);
if (dex && !dex->GetDebugInfo().Path.IsEmpty())
ShowCodeLocation(result, dex->GetDebugInfo());
@ -223,8 +223,8 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta
ShowCodeLocation(result, di);
}
const user_error *uex = dynamic_cast<const user_error *>(&ex);
const posix_error *pex = dynamic_cast<const posix_error *>(&ex);
const auto *uex = dynamic_cast<const user_error *>(&ex);
const auto *pex = dynamic_cast<const posix_error *>(&ex);
if (!uex && !pex && verbose) {
const StackTrace *st = boost::get_error_info<StackTraceErrorInfo>(ex);

View File

@ -51,7 +51,7 @@ void FIFO::ResizeBuffer(size_t newSize, bool decrease)
if (newSize == m_AllocSize)
return;
char *newBuffer = static_cast<char *>(realloc(m_Buffer, newSize));
auto *newBuffer = static_cast<char *>(realloc(m_Buffer, newSize));
if (!newBuffer)
BOOST_THROW_EXCEPTION(std::bad_alloc());

View File

@ -55,7 +55,7 @@ void FileLogger::Start(bool runtimeCreated)
void FileLogger::ReopenLogFile()
{
std::ofstream *stream = new std::ofstream();
auto *stream = new std::ofstream();
String path = GetPath();

View File

@ -205,7 +205,7 @@ private:
static int DecodeNull(void *ctx)
{
JsonContext *context = static_cast<JsonContext *>(ctx);
auto *context = static_cast<JsonContext *>(ctx);
try {
context->AddValue(Empty);
@ -219,7 +219,7 @@ static int DecodeNull(void *ctx)
static int DecodeBoolean(void *ctx, int value)
{
JsonContext *context = static_cast<JsonContext *>(ctx);
auto *context = static_cast<JsonContext *>(ctx);
try {
context->AddValue(static_cast<bool>(value));
@ -233,7 +233,7 @@ static int DecodeBoolean(void *ctx, int value)
static int DecodeNumber(void *ctx, const char *str, yajl_size len)
{
JsonContext *context = static_cast<JsonContext *>(ctx);
auto *context = static_cast<JsonContext *>(ctx);
try {
String jstr = String(str, str + len);
@ -248,7 +248,7 @@ static int DecodeNumber(void *ctx, const char *str, yajl_size len)
static int DecodeString(void *ctx, const unsigned char *str, yajl_size len)
{
JsonContext *context = static_cast<JsonContext *>(ctx);
auto *context = static_cast<JsonContext *>(ctx);
try {
context->AddValue(String(str, str + len));
@ -262,7 +262,7 @@ static int DecodeString(void *ctx, const unsigned char *str, yajl_size len)
static int DecodeStartMap(void *ctx)
{
JsonContext *context = static_cast<JsonContext *>(ctx);
auto *context = static_cast<JsonContext *>(ctx);
try {
context->Push(new Dictionary());
@ -276,7 +276,7 @@ static int DecodeStartMap(void *ctx)
static int DecodeEndMapOrArray(void *ctx)
{
JsonContext *context = static_cast<JsonContext *>(ctx);
auto *context = static_cast<JsonContext *>(ctx);
try {
context->AddValue(context->Pop().EValue);
@ -290,7 +290,7 @@ static int DecodeEndMapOrArray(void *ctx)
static int DecodeStartArray(void *ctx)
{
JsonContext *context = static_cast<JsonContext *>(ctx);
auto *context = static_cast<JsonContext *>(ctx);
try {
context->Push(new Array());

View File

@ -62,7 +62,7 @@ void ObjectLock::LockMutex(const Object *object)
while (likely(!__sync_bool_compare_and_swap(&object->m_Mutex, I2MUTEX_UNLOCKED, I2MUTEX_LOCKED))) {
#endif /* _WIN32 */
if (likely(object->m_Mutex > I2MUTEX_LOCKED)) {
boost::recursive_mutex *mtx = reinterpret_cast<boost::recursive_mutex *>(object->m_Mutex);
auto *mtx = reinterpret_cast<boost::recursive_mutex *>(object->m_Mutex);
mtx->lock();
return;
@ -72,7 +72,7 @@ void ObjectLock::LockMutex(const Object *object)
it++;
}
boost::recursive_mutex *mtx = new boost::recursive_mutex();
auto *mtx = new boost::recursive_mutex();
mtx->lock();
#ifdef _WIN32
# ifdef _WIN64

View File

@ -93,14 +93,14 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
return Empty;
}
int *fds = (int *)CMSG_DATA(cmsg);
auto *fds = (int *)CMSG_DATA(cmsg);
Array::Ptr arguments = request->Get("arguments");
Dictionary::Ptr extraEnvironment = request->Get("extraEnvironment");
bool adjustPriority = request->Get("adjustPriority");
// build argv
char **argv = new char *[arguments->GetLength() + 1];
auto **argv = new char *[arguments->GetLength() + 1];
for (unsigned int i = 0; i < arguments->GetLength(); i++) {
String arg = arguments->Get(i);
@ -116,7 +116,7 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
while (environ[envc])
envc++;
char **envp = new char *[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 2];
auto **envp = new char *[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 2];
for (int i = 0; i < envc; i++)
envp[i] = strdup(environ[i]);
@ -281,7 +281,7 @@ static void ProcessHandler()
break;
}
char *mbuf = new char[length];
auto *mbuf = new char[length];
size_t count = 0;
while (count < length) {

View File

@ -310,7 +310,7 @@ Array::Ptr ScriptUtils::Intersection(const std::vector<Value>& arguments)
Array::SizeType len;
{
ObjectLock olock(arr1), xlock(arr2), ylock(result);
Array::Iterator it = std::set_intersection(arr1->Begin(), arr1->End(), arr2->Begin(), arr2->End(), result->Begin());
auto it = std::set_intersection(arr1->Begin(), arr1->End(), arr2->Begin(), arr2->End(), result->Begin());
len = it - result->Begin();
}
result->Resize(len);
@ -334,7 +334,7 @@ void ScriptUtils::Log(const std::vector<Value>& arguments)
facility = "config";
message = arguments[0];
} else {
int sval = static_cast<int>(arguments[0]);
auto sval = static_cast<int>(arguments[0]);
severity = static_cast<LogSeverity>(sval);
facility = arguments[1];
message = arguments[2];
@ -410,7 +410,7 @@ ConfigObject::Ptr ScriptUtils::GetObject(const Value& vtype, const String& name)
else
ptype = Type::GetByName(vtype);
ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
if (!ctype)
return nullptr;
@ -423,7 +423,7 @@ Array::Ptr ScriptUtils::GetObjects(const Type::Ptr& type)
if (!type)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type: Must not be null"));
ConfigType *ctype = dynamic_cast<ConfigType *>(type.get());
auto *ctype = dynamic_cast<ConfigType *>(type.get());
if (!ctype)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type: Type must inherit from 'ConfigObject'"));

View File

@ -89,8 +89,8 @@ TlsStream::~TlsStream()
int TlsStream::ValidateCertificate(int preverify_ok, X509_STORE_CTX *ctx)
{
SSL *ssl = static_cast<SSL *>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()));
TlsStream *stream = static_cast<TlsStream *>(SSL_get_ex_data(ssl, m_SSLIndex));
auto *ssl = static_cast<SSL *>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()));
auto *stream = static_cast<TlsStream *>(SSL_get_ex_data(ssl, m_SSLIndex));
if (!preverify_ok) {
stream->m_VerifyOK = false;

View File

@ -737,7 +737,7 @@ String SHA256(const String& s)
String RandomString(int length)
{
unsigned char *bytes = new unsigned char[length];
auto *bytes = new unsigned char[length];
if (!RAND_bytes(bytes, length)) {
delete [] bytes;
@ -751,7 +751,7 @@ String RandomString(int length)
<< errinfo_openssl_error(ERR_peek_error()));
}
char *output = new char[length * 2 + 1];
auto *output = new char[length * 2 + 1];
for (int i = 0; i < length; i++)
sprintf(output + 2 * i, "%02x", bytes[i]);

View File

@ -1012,7 +1012,7 @@ String Utility::FormatDuration(double duration)
String Utility::FormatDateTime(const char *format, double ts)
{
char timestamp[128];
time_t tempts = (time_t)ts; /* We don't handle sub-second timestamps here just yet. */
auto tempts = (time_t)ts; /* We don't handle sub-second timestamps here just yet. */
tm tmthen;
#ifdef _MSC_VER

View File

@ -114,7 +114,7 @@ public:
if (!IsObject())
BOOST_THROW_EXCEPTION(std::runtime_error("Cannot convert value of type '" + GetTypeName() + "' to an object."));
const Object::Ptr& object = Get<Object::Ptr>();
const auto& object = Get<Object::Ptr>();
ASSERT(object);

View File

@ -69,7 +69,7 @@ public:
#endif /*_WIN32*/
}
else {
std::ofstream *ofs = new std::ofstream();
auto *ofs = new std::ofstream();
ofs->open(path.CStr(), std::ios::out | std::ios::trunc);
m_Stream = ofs;
}
@ -550,7 +550,7 @@ void TroubleshootCommand::CheckObjectFile(const String& objectfile, InfoLog& log
bool TroubleshootCommand::PrintVarsFile(const String& path, const bool console) {
if (!console) {
std::ofstream *ofs = new std::ofstream();
auto *ofs = new std::ofstream();
ofs->open((path+"-vars").CStr(), std::ios::out | std::ios::trunc);
if (!ofs->is_open())
return false;

View File

@ -533,7 +533,7 @@ void CompatLogger::ReopenFile(bool rotate)
void CompatLogger::ScheduleNextRotation()
{
time_t now = (time_t)Utility::GetTime();
auto now = (time_t)Utility::GetTime();
String method = GetRotationMethod();
tm tmthen;

View File

@ -39,7 +39,7 @@ void ConfigCompilerContext::OpenObjectsFile(const String& filename)
{
m_ObjectsPath = filename;
std::fstream *fp = new std::fstream();
auto *fp = new std::fstream();
try {
m_ObjectsTempFile = Utility::CreateTempFile(filename + ".XXXXXX", 0600, *fp);
} catch (const std::exception& ex) {

View File

@ -231,7 +231,7 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
String name = item_name;
NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
auto *nc = dynamic_cast<NameComposer *>(type.get());
if (nc) {
if (name.IsEmpty())

View File

@ -96,7 +96,7 @@ ConfigItem::Ptr ConfigItemBuilder::Compile()
BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo));
}
ConfigType *ctype = dynamic_cast<ConfigType *>(m_Type.get());
auto *ctype = dynamic_cast<ConfigType *>(m_Type.get());
if (!ctype) {
std::ostringstream msgbuf;
@ -133,7 +133,7 @@ ConfigItem::Ptr ConfigItemBuilder::Compile()
}
#endif /* I2_DEBUG */
DictExpression *dexpr = new DictExpression(std::move(m_Expressions), m_DebugInfo);
auto *dexpr = new DictExpression(std::move(m_Expressions), m_DebugInfo);
dexpr->MakeInline();
exprs.emplace_back(dexpr);

View File

@ -685,7 +685,7 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
void icinga::BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec)
{
DictExpression *dexpr = dynamic_cast<DictExpression *>(expr.get());
auto *dexpr = dynamic_cast<DictExpression *>(expr.get());
if (dexpr) {
for (auto& expr : dexpr->m_Expressions)
@ -694,7 +694,7 @@ void icinga::BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scope
return;
}
SetExpression *aexpr = dynamic_cast<SetExpression *>(expr.get());
auto *aexpr = dynamic_cast<SetExpression *>(expr.get());
if (aexpr) {
BindToScope(aexpr->m_Operand1, scopeSpec);
@ -702,21 +702,21 @@ void icinga::BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scope
return;
}
IndexerExpression *iexpr = dynamic_cast<IndexerExpression *>(expr.get());
auto *iexpr = dynamic_cast<IndexerExpression *>(expr.get());
if (iexpr) {
BindToScope(iexpr->m_Operand1, scopeSpec);
return;
}
LiteralExpression *lexpr = dynamic_cast<LiteralExpression *>(expr.get());
auto *lexpr = dynamic_cast<LiteralExpression *>(expr.get());
if (lexpr && lexpr->GetValue().IsString()) {
std::unique_ptr<Expression> scope{new GetScopeExpression(scopeSpec)};
expr.reset(new IndexerExpression(std::move(scope), std::move(expr), lexpr->GetDebugInfo()));
}
VariableExpression *vexpr = dynamic_cast<VariableExpression *>(expr.get());
auto *vexpr = dynamic_cast<VariableExpression *>(expr.get());
if (vexpr) {
std::unique_ptr<Expression> scope{new GetScopeExpression(scopeSpec)};

View File

@ -151,7 +151,7 @@ public:
String checkName = name;
if (!abstract) {
NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
auto *nc = dynamic_cast<NameComposer *>(type.get());
if (nc)
checkName = nc->MakeName(name, nullptr);

View File

@ -206,7 +206,7 @@ void DbConnection::UpdateProgramStatus()
void DbConnection::CleanUpHandler()
{
long now = static_cast<long>(Utility::GetTime());
auto now = static_cast<long>(Utility::GetTime());
struct {
String name;
@ -426,7 +426,7 @@ void DbConnection::UpdateObject(const ConfigObject::Ptr& object)
void DbConnection::UpdateAllObjects()
{
for (const Type::Ptr& type : Type::GetAllTypes()) {
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
auto *dtype = dynamic_cast<ConfigType *>(type.get());
if (!dtype)
continue;

View File

@ -83,7 +83,7 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
return;
}
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
auto *dtype = dynamic_cast<ConfigType *>(type.get());
VERIFY(dtype);
DbConnection::Ptr conn = static_pointer_cast<DbConnection>(dtype->GetObject(idoName));

View File

@ -671,7 +671,7 @@ String IdoMysqlConnection::Escape(const String& s)
String utf8s = Utility::ValidateUTF8(s);
size_t length = utf8s.GetLength();
char *to = new char[utf8s.GetLength() * 2 + 1];
auto *to = new char[utf8s.GetLength() * 2 + 1];
m_Mysql->real_escape_string(&m_Connection, to, utf8s.CStr(), length);
@ -838,7 +838,7 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
} else if (DbValue::IsTimestampNow(value)) {
*result = "NOW()";
} else if (DbValue::IsObjectInsertID(value)) {
long id = static_cast<long>(rawvalue);
auto id = static_cast<long>(rawvalue);
if (id <= 0)
return false;

View File

@ -515,7 +515,7 @@ String IdoPgsqlConnection::Escape(const String& s)
String utf8s = Utility::ValidateUTF8(s);
size_t length = utf8s.GetLength();
char *to = new char[utf8s.GetLength() * 2 + 1];
auto *to = new char[utf8s.GetLength() * 2 + 1];
m_Pgsql->escapeStringConn(m_Connection, to, utf8s.CStr(), length, nullptr);
@ -660,7 +660,7 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va
} else if (DbValue::IsTimestampNow(value)) {
*result = "NOW()";
} else if (DbValue::IsObjectInsertID(value)) {
long id = static_cast<long>(rawvalue);
auto id = static_cast<long>(rawvalue);
if (id <= 0)
return false;

View File

@ -74,7 +74,7 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency
}
/* implicit dependency on host if this is a service */
const Service *service = dynamic_cast<const Service *>(this);
const auto *service = dynamic_cast<const Service *>(this);
if (service && (dt == DependencyState || dt == DependencyNotification)) {
Host::Ptr host = service->GetHost();

View File

@ -85,7 +85,7 @@ void Checkable::AddGroup(const String& name)
boost::mutex::scoped_lock lock(m_CheckableMutex);
Array::Ptr groups;
Host *host = dynamic_cast<Host *>(this);
auto *host = dynamic_cast<Host *>(this);
if (host)
groups = host->GetGroups();
@ -103,7 +103,7 @@ void Checkable::AddGroup(const String& name)
AcknowledgementType Checkable::GetAcknowledgement()
{
AcknowledgementType avalue = static_cast<AcknowledgementType>(GetAcknowledgementRaw());
auto avalue = static_cast<AcknowledgementType>(GetAcknowledgementRaw());
if (avalue != AcknowledgementNone) {
double expiry = GetAcknowledgementExpiry();

View File

@ -121,7 +121,7 @@ bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resol
}
}
MacroResolver *mresolver = dynamic_cast<MacroResolver *>(resolver.second.get());
auto *mresolver = dynamic_cast<MacroResolver *>(resolver.second.get());
if (mresolver && mresolver->ResolveMacro(boost::algorithm::join(tokens, "."), cr, result))
return true;

View File

@ -132,25 +132,25 @@ Value StatusTable::ConnectionsRateAccessor(const Value&)
Value StatusTable::HostChecksAccessor(const Value&)
{
long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
auto timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
return CIB::GetActiveHostChecksStatistics(timespan);
}
Value StatusTable::HostChecksRateAccessor(const Value&)
{
long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
auto timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
return (CIB::GetActiveHostChecksStatistics(timespan) / (Utility::GetTime() - Application::GetStartTime()));
}
Value StatusTable::ServiceChecksAccessor(const Value&)
{
long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
auto timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
return CIB::GetActiveServiceChecksStatistics(timespan);
}
Value StatusTable::ServiceChecksRateAccessor(const Value&)
{
long timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
auto timespan = static_cast<long>(Utility::GetTime() - Application::GetStartTime());
return (CIB::GetActiveServiceChecksStatistics(timespan) / (Utility::GetTime() - Application::GetStartTime()));
}

View File

@ -41,7 +41,7 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
{
NotificationCommand::Ptr commandObj = notification->GetCommand();
NotificationType type = static_cast<NotificationType>(itype);
auto type = static_cast<NotificationType>(itype);
Checkable::Ptr checkable = notification->GetCheckable();

View File

@ -592,7 +592,7 @@ String ElasticsearchWriter::FormatTimestamp(double ts)
* https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html
* https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html
*/
int milliSeconds = static_cast<int>((ts - static_cast<int>(ts)) * 1000);
auto milliSeconds = static_cast<int>((ts - static_cast<int>(ts)) * 1000);
return Utility::FormatDateTime("%Y-%m-%dT%H:%M:%S", ts) + "." + Convert::ToString(milliSeconds) + Utility::FormatDateTime("%z", ts);
}

View File

@ -98,7 +98,7 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin
double objVersion = params->Get("version");
Type::Ptr ptype = Type::GetByName(objType);
ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
if (!ctype) {
Log(LogCritical, "ApiListener")
@ -234,7 +234,7 @@ Value ApiListener::ConfigDeleteObjectAPIHandler(const MessageOrigin::Ptr& origin
/* delete the object */
Type::Ptr ptype = Type::GetByName(params->Get("type"));
ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
if (!ctype) {
Log(LogCritical, "ApiListener")
@ -414,7 +414,7 @@ void ApiListener::SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient
<< "Syncing runtime objects to endpoint '" << endpoint->GetName() << "'.";
for (const Type::Ptr& type : Type::GetAllTypes()) {
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
auto *dtype = dynamic_cast<ConfigType *>(type.get());
if (!dtype)
continue;

View File

@ -992,7 +992,7 @@ void ApiListener::OpenLogFile()
Utility::MkDirP(Utility::DirName(path), 0750);
std::fstream *fp = new std::fstream(path.CStr(), std::fstream::out | std::ofstream::app);
auto *fp = new std::fstream(path.CStr(), std::fstream::out | std::ofstream::app);
if (!fp->good()) {
Log(LogWarning, "ApiListener")
@ -1102,7 +1102,7 @@ void ApiListener::ReplayLog(const JsonRpcConnection::Ptr& client)
Log(LogNotice, "ApiListener")
<< "Replaying log: " << path;
std::fstream *fp = new std::fstream(path.CStr(), std::fstream::in | std::fstream::binary);
auto *fp = new std::fstream(path.CStr(), std::fstream::in | std::fstream::binary);
StdioStream::Ptr logStream = new StdioStream(fp, true);
String message;

View File

@ -58,7 +58,7 @@ void ApiListener::UpdateObjectAuthority()
}
for (const Type::Ptr& type : Type::GetAllTypes()) {
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
auto *dtype = dynamic_cast<ConfigType *>(type.get());
if (!dtype)
continue;

View File

@ -55,7 +55,7 @@ String ConfigObjectUtility::EscapeName(const String& name)
String ConfigObjectUtility::CreateObjectConfig(const Type::Ptr& type, const String& fullName,
bool ignoreOnError, const Array::Ptr& templates, const Dictionary::Ptr& attrs)
{
NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
auto *nc = dynamic_cast<NameComposer *>(type.get());
Dictionary::Ptr nameParts;
String name;

View File

@ -114,7 +114,7 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
return true;
}
ConfigType *ctype = dynamic_cast<ConfigType *>(type.get());
auto *ctype = dynamic_cast<ConfigType *>(type.get());
ConfigObject::Ptr obj = ctype->GetObject(name);
result1->Set("code", 200);

View File

@ -47,7 +47,7 @@ Type::Ptr FilterUtility::TypeFromPluralName(const String& pluralName)
void ConfigObjectTargetProvider::FindTargets(const String& type, const std::function<void (const Value&)>& addTarget) const
{
Type::Ptr ptype = Type::GetByName(type);
ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
if (ctype) {
for (const ConfigObject::Ptr& object : ctype->GetObjects()) {

View File

@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(remove)
{
ObjectLock olock(array);
Array::Iterator it = array->Begin();
auto it = array->Begin();
array->Remove(it);
}

View File

@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(remove)
{
ObjectLock olock(dictionary);
Dictionary::Iterator it = dictionary->Begin();
auto it = dictionary->Begin();
dictionary->Remove(it);
}

View File

@ -289,7 +289,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
collisions = 0;
for (const Field& field : klass.Fields) {
int hash = static_cast<int>(SDBM(field.Name, hlen));
auto hash = static_cast<int>(SDBM(field.Name, hlen));
jumptable[hash].push_back(std::make_pair(num, field.Name));
num++;
@ -846,7 +846,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
if (field.Type.IsName || !field.TrackAccessor.empty()) {
if (field.Name != "active") {
m_Impl << "\t" << "ConfigObject *dobj = dynamic_cast<ConfigObject *>(this);" << std::endl
m_Impl << "\t" << "auto *dobj = dynamic_cast<ConfigObject *>(this);" << std::endl
<< "\t" << "if (!dobj || dobj->IsActive())" << std::endl
<< "\t";
}
@ -1009,7 +1009,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
<< "{" << std::endl;
if (field.Name != "active") {
m_Impl << "\t" << "ConfigObject *dobj = dynamic_cast<ConfigObject *>(this);" << std::endl
m_Impl << "\t" << "auto *dobj = dynamic_cast<ConfigObject *>(this);" << std::endl
<< "\t" << "if (!dobj || dobj->IsActive())" << std::endl
<< "\t";
}