aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Utilities')
-rw-r--r--src/common/Utilities/Optional.h5
-rw-r--r--src/common/Utilities/OptionalFwd.h31
-rw-r--r--src/common/Utilities/StartProcess.cpp2
-rw-r--r--src/common/Utilities/StartProcess.h2
-rw-r--r--src/common/Utilities/StringFormat.h2
-rw-r--r--src/common/Utilities/Util.cpp6
-rw-r--r--src/common/Utilities/Util.h43
7 files changed, 58 insertions, 33 deletions
diff --git a/src/common/Utilities/Optional.h b/src/common/Utilities/Optional.h
index e69d36c5a03..dc5cd970970 100644
--- a/src/common/Utilities/Optional.h
+++ b/src/common/Utilities/Optional.h
@@ -18,11 +18,8 @@
#ifndef TrinityCore_Optional_h__
#define TrinityCore_Optional_h__
+#include "OptionalFwd.h"
#include <boost/optional.hpp>
#include <boost/utility/in_place_factory.hpp>
- //! Optional helper class to wrap optional values within.
-template <typename T>
-using Optional = boost::optional<T>;
-
#endif // TrinityCore_Optional_h__
diff --git a/src/common/Utilities/OptionalFwd.h b/src/common/Utilities/OptionalFwd.h
new file mode 100644
index 00000000000..516ebeb772e
--- /dev/null
+++ b/src/common/Utilities/OptionalFwd.h
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef OptionalFwd_h__
+#define OptionalFwd_h__
+
+namespace boost
+{
+ template <class T>
+ class optional;
+}
+
+//! Optional helper class to wrap optional values within.
+template <class T>
+using Optional = boost::optional<T>;
+
+#endif // OptionalFwd_h__
diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp
index e0c6f714e7e..160c6743a00 100644
--- a/src/common/Utilities/StartProcess.cpp
+++ b/src/common/Utilities/StartProcess.cpp
@@ -44,7 +44,7 @@ public:
TCLogSink(T callback)
: callback_(std::move(callback)) { }
- std::streamsize write(const char* str, std::streamsize size)
+ std::streamsize write(char const* str, std::streamsize size)
{
callback_(std::string(str, size));
return size;
diff --git a/src/common/Utilities/StartProcess.h b/src/common/Utilities/StartProcess.h
index 6baf21e8957..71452315e77 100644
--- a/src/common/Utilities/StartProcess.h
+++ b/src/common/Utilities/StartProcess.h
@@ -62,7 +62,7 @@ TC_COMMON_API std::shared_ptr<AsyncProcessResult>
bool secure = false);
/// Searches for the given executable in the PATH variable
-/// and returns a present optional when it was found.
+/// and returns a non-empty string when it was found.
TC_COMMON_API std::string SearchExecutableInPath(std::string const& filename);
} // namespace Trinity
diff --git a/src/common/Utilities/StringFormat.h b/src/common/Utilities/StringFormat.h
index b7da2800c66..dd990c637e2 100644
--- a/src/common/Utilities/StringFormat.h
+++ b/src/common/Utilities/StringFormat.h
@@ -30,7 +30,7 @@ namespace Trinity
}
/// Returns true if the given char pointer is null.
- inline bool IsFormatEmptyOrNull(const char* fmt)
+ inline bool IsFormatEmptyOrNull(char const* fmt)
{
return fmt == nullptr;
}
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp
index 5a1ed443649..d5c1137cdd7 100644
--- a/src/common/Utilities/Util.cpp
+++ b/src/common/Utilities/Util.cpp
@@ -101,7 +101,7 @@ void stripLineInvisibleChars(std::string &str)
}
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
-struct tm* localtime_r(const time_t* time, struct tm *result)
+struct tm* localtime_r(time_t const* time, struct tm *result)
{
localtime_s(result, time);
return result;
@@ -131,7 +131,7 @@ std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly)
return ss.str();
}
-int64 MoneyStringToMoney(const std::string& moneyString)
+int64 MoneyStringToMoney(std::string const& moneyString)
{
int64 money = 0;
@@ -162,7 +162,7 @@ int64 MoneyStringToMoney(const std::string& moneyString)
return money;
}
-uint32 TimeStringToSecs(const std::string& timestring)
+uint32 TimeStringToSecs(std::string const& timestring)
{
uint32 secs = 0;
uint32 buffer = 0;
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index 9592f36a7b7..308da01335d 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -57,12 +57,12 @@ private:
TC_COMMON_API void stripLineInvisibleChars(std::string &src);
-TC_COMMON_API int64 MoneyStringToMoney(const std::string& moneyString);
+TC_COMMON_API int64 MoneyStringToMoney(std::string const& moneyString);
-TC_COMMON_API struct tm* localtime_r(const time_t* time, struct tm *result);
+TC_COMMON_API struct tm* localtime_r(time_t const* time, struct tm *result);
TC_COMMON_API std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hoursOnly = false);
-TC_COMMON_API uint32 TimeStringToSecs(const std::string& timestring);
+TC_COMMON_API uint32 TimeStringToSecs(std::string const& timestring);
TC_COMMON_API std::string TimeToTimestampStr(time_t t);
// Percentage calculation
@@ -401,7 +401,7 @@ public:
part[3] = p4;
}
- inline bool operator <(const flag128 &right) const
+ inline bool operator<(flag128 const& right) const
{
for (uint8 i = 4; i > 0; --i)
{
@@ -413,7 +413,7 @@ public:
return false;
}
- inline bool operator ==(const flag128 &right) const
+ inline bool operator==(flag128 const& right) const
{
return
(
@@ -424,18 +424,17 @@ public:
);
}
- inline bool operator !=(const flag128 &right) const
+ inline bool operator!=(flag128 const& right) const
{
- return !this->operator ==(right);
+ return !(*this == right);
}
- inline flag128 operator &(const flag128 &right) const
+ inline flag128 operator&(flag128 const& right) const
{
- return flag128(part[0] & right.part[0], part[1] & right.part[1],
- part[2] & right.part[2], part[3] & right.part[3]);
+ return flag128(part[0] & right.part[0], part[1] & right.part[1], part[2] & right.part[2], part[3] & right.part[3]);
}
- inline flag128 & operator &=(const flag128 &right)
+ inline flag128& operator&=(flag128 const& right)
{
part[0] &= right.part[0];
part[1] &= right.part[1];
@@ -444,13 +443,12 @@ public:
return *this;
}
- inline flag128 operator |(const flag128 &right) const
+ inline flag128 operator|(flag128 const& right) const
{
- return flag128(part[0] | right.part[0], part[1] | right.part[1],
- part[2] | right.part[2], part[3] | right.part[3]);
+ return flag128(part[0] | right.part[0], part[1] | right.part[1], part[2] | right.part[2], part[3] | right.part[3]);
}
- inline flag128 & operator |=(const flag128 &right)
+ inline flag128& operator |=(flag128 const& right)
{
part[0] |= right.part[0];
part[1] |= right.part[1];
@@ -459,18 +457,17 @@ public:
return *this;
}
- inline flag128 operator ~() const
+ inline flag128 operator~() const
{
return flag128(~part[0], ~part[1], ~part[2], ~part[3]);
}
- inline flag128 operator ^(const flag128 &right) const
+ inline flag128 operator^(flag128 const& right) const
{
- return flag128(part[0] ^ right.part[0], part[1] ^ right.part[1],
- part[2] ^ right.part[2], part[3] ^ right.part[3]);
+ return flag128(part[0] ^ right.part[0], part[1] ^ right.part[1], part[2] ^ right.part[2], part[3] ^ right.part[3]);
}
- inline flag128 & operator ^=(const flag128 &right)
+ inline flag128& operator^=(flag128 const& right)
{
part[0] ^= right.part[0];
part[1] ^= right.part[1];
@@ -486,15 +483,15 @@ public:
inline bool operator !() const
{
- return !this->operator bool();
+ return !(bool(*this));
}
- inline uint32 & operator [](uint8 el)
+ inline uint32& operator[](uint8 el)
{
return part[el];
}
- inline const uint32 & operator [](uint8 el) const
+ inline uint32 const& operator [](uint8 el) const
{
return part[el];
}