mirror of https://github.com/libAthena/athena.git
Merge pull request #53 from lioncash/explicit
General: Make constructors explicit where applicable
This commit is contained in:
commit
b383eedaee
|
@ -15,7 +15,7 @@ struct LZLengthOffset {
|
|||
class LZLookupTable {
|
||||
public:
|
||||
LZLookupTable();
|
||||
LZLookupTable(atInt32 minimumMatch, atInt32 slidingWindow = 4096, atInt32 lookAheadWindow = 18);
|
||||
explicit LZLookupTable(atInt32 minimumMatch, atInt32 slidingWindow = 4096, atInt32 lookAheadWindow = 18);
|
||||
~LZLookupTable();
|
||||
LZLengthOffset search(const atUint8* curPos, const atUint8* dataBegin, const atUint8* dataEnd);
|
||||
void setLookAheadWindow(atInt32 lookAheadWindow);
|
||||
|
|
|
@ -21,8 +21,9 @@ struct PropId {
|
|||
template <class T>
|
||||
constexpr T opget() const;
|
||||
constexpr PropId() = default;
|
||||
constexpr PropId(const char* name, uint32_t rcrc32, uint64_t crc64) : name(name), rcrc32(rcrc32), crc64(crc64) {}
|
||||
constexpr PropId(const char* name)
|
||||
constexpr explicit PropId(const char* name, uint32_t rcrc32, uint64_t crc64)
|
||||
: name(name), rcrc32(rcrc32), crc64(crc64) {}
|
||||
constexpr explicit PropId(const char* name)
|
||||
: name(name)
|
||||
, rcrc32(athena::checksums::literals::rcrc32_rec(0xFFFFFFFF, name))
|
||||
, crc64(athena::checksums::literals::crc64_rec(0xFFFFFFFFFFFFFFFF, name)) {}
|
||||
|
@ -41,7 +42,7 @@ constexpr uint64_t PropId::opget<uint64_t>() const {
|
|||
}
|
||||
|
||||
namespace literals {
|
||||
constexpr PropId operator"" _propid(const char* s, size_t len) { return {s}; }
|
||||
constexpr PropId operator"" _propid(const char* s, size_t len) { return PropId{s}; }
|
||||
} // namespace literals
|
||||
|
||||
#define AT_PROP_CASE(...) case athena::io::PropId(__VA_ARGS__).opget<typename Op::PropT>()
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
namespace athena::io {
|
||||
class FileReader : public IStreamReader {
|
||||
public:
|
||||
FileReader(std::string_view filename, atInt32 cacheSize = (32 * 1024), bool globalErr = true);
|
||||
FileReader(std::wstring_view filename, atInt32 cacheSize = (32 * 1024), bool globalErr = true);
|
||||
explicit FileReader(std::string_view filename, atInt32 cacheSize = (32 * 1024), bool globalErr = true);
|
||||
explicit FileReader(std::wstring_view filename, atInt32 cacheSize = (32 * 1024), bool globalErr = true);
|
||||
~FileReader() override;
|
||||
|
||||
std::string filename() const {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
namespace athena::io {
|
||||
class FileWriter : public IStreamWriter {
|
||||
public:
|
||||
FileWriter(std::string_view filename, bool overwrite = true, bool globalErr = true);
|
||||
FileWriter(std::wstring_view filename, bool overwrite = true, bool globalErr = true);
|
||||
explicit FileWriter(std::string_view filename, bool overwrite = true, bool globalErr = true);
|
||||
explicit FileWriter(std::wstring_view filename, bool overwrite = true, bool globalErr = true);
|
||||
~FileWriter() override;
|
||||
|
||||
std::string filename() const {
|
||||
|
@ -71,7 +71,7 @@ class TransactionalFileWriter : public IStreamWriter {
|
|||
atUint64 m_position = 0;
|
||||
|
||||
public:
|
||||
TransactionalFileWriter(std::string_view filename, bool overwrite = true, bool globalErr = true)
|
||||
explicit TransactionalFileWriter(std::string_view filename, bool overwrite = true, bool globalErr = true)
|
||||
: m_overwrite(overwrite), m_globalErr(globalErr) {
|
||||
#if _WIN32
|
||||
m_filename = utility::utf8ToWide(filename);
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
m_filename = filename;
|
||||
#endif
|
||||
}
|
||||
TransactionalFileWriter(std::wstring_view filename, bool overwrite = true, bool globalErr = true)
|
||||
explicit TransactionalFileWriter(std::wstring_view filename, bool overwrite = true, bool globalErr = true)
|
||||
: m_overwrite(overwrite), m_globalErr(globalErr) {
|
||||
#if _WIN32
|
||||
m_filename = filename;
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
* \param takeOwnership Memory will be freed with the reader if set.
|
||||
* \param globalErr Whether or not global errors are enabled.
|
||||
*/
|
||||
MemoryReader(const void* data, atUint64 length, bool takeOwnership = false, bool globalErr = true);
|
||||
explicit MemoryReader(const void* data, atUint64 length, bool takeOwnership = false, bool globalErr = true);
|
||||
|
||||
/*! \brief Sets the buffers position relative to the specified position.<br />
|
||||
* It seeks relative to the current position by default.
|
||||
|
@ -92,13 +92,13 @@ public:
|
|||
* \param data The existing buffer
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
MemoryCopyReader(const void* data, atUint64 length);
|
||||
explicit MemoryCopyReader(const void* data, atUint64 length);
|
||||
|
||||
/*! \brief This constructor creates an instance from a file on disk.
|
||||
*
|
||||
* \param filename The file to create the stream from
|
||||
*/
|
||||
MemoryCopyReader(const std::string& filename) : m_filepath(filename) { loadData(); }
|
||||
explicit MemoryCopyReader(const std::string& filename) : m_filepath(filename) { loadData(); }
|
||||
|
||||
void setData(const atUint8* data, atUint64 length);
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
*
|
||||
* @param filename The file to create the stream from
|
||||
*/
|
||||
MemoryCopyWriter(std::string_view filename);
|
||||
explicit MemoryCopyWriter(std::string_view filename);
|
||||
|
||||
/*! @brief Sets the buffers position relative to the specified position.<br />
|
||||
* It seeks relative to the current position by default.
|
||||
|
|
|
@ -21,7 +21,7 @@ class IPAddress {
|
|||
void resolve(const std::string& address);
|
||||
|
||||
public:
|
||||
IPAddress(const std::string& address) { resolve(address); }
|
||||
explicit IPAddress(const std::string& address) { resolve(address); }
|
||||
|
||||
uint32_t toInteger() const;
|
||||
operator bool() const { return m_valid; }
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
static EResult LastWSAError();
|
||||
#endif
|
||||
|
||||
Socket(bool blocking) : m_isBlocking(blocking) {}
|
||||
explicit Socket(bool blocking) : m_isBlocking(blocking) {}
|
||||
~Socket() { close(); }
|
||||
|
||||
Socket(const Socket& other) = delete;
|
||||
|
|
|
@ -166,7 +166,7 @@ struct YAMLStdStringViewReaderState {
|
|||
std::string_view::const_iterator begin;
|
||||
std::string_view::const_iterator end;
|
||||
|
||||
YAMLStdStringViewReaderState(std::string_view str) {
|
||||
explicit YAMLStdStringViewReaderState(std::string_view str) {
|
||||
begin = str.begin();
|
||||
end = str.end();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
class RecordRAII {
|
||||
friend class YAMLDocReader;
|
||||
YAMLDocReader* m_r = nullptr;
|
||||
RecordRAII(YAMLDocReader* r) : m_r(r) {}
|
||||
explicit RecordRAII(YAMLDocReader* r) : m_r(r) {}
|
||||
RecordRAII() = default;
|
||||
|
||||
public:
|
||||
|
@ -70,11 +70,11 @@ public:
|
|||
class VectorRAII {
|
||||
friend class YAMLDocReader;
|
||||
YAMLDocReader* m_r = nullptr;
|
||||
VectorRAII(YAMLDocReader* r) : m_r(r) {}
|
||||
explicit VectorRAII(YAMLDocReader* r) : m_r(r) {}
|
||||
VectorRAII() = default;
|
||||
|
||||
public:
|
||||
operator bool() const { return m_r != nullptr; }
|
||||
explicit operator bool() const { return m_r != nullptr; }
|
||||
~VectorRAII() {
|
||||
if (m_r)
|
||||
m_r->_leaveSubVector();
|
||||
|
|
|
@ -20,7 +20,7 @@ class YAMLDocWriter {
|
|||
void _leaveSubVector();
|
||||
|
||||
public:
|
||||
YAMLDocWriter(const char* classType, athena::io::IStreamReader* reader = nullptr);
|
||||
explicit YAMLDocWriter(const char* classType, athena::io::IStreamReader* reader = nullptr);
|
||||
~YAMLDocWriter();
|
||||
|
||||
yaml_emitter_t* getEmitter() { return &m_emitter; }
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
class RecordRAII {
|
||||
friend class YAMLDocWriter;
|
||||
YAMLDocWriter* m_w = nullptr;
|
||||
RecordRAII(YAMLDocWriter* w) : m_w(w) {}
|
||||
explicit RecordRAII(YAMLDocWriter* w) : m_w(w) {}
|
||||
RecordRAII() = default;
|
||||
|
||||
public:
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
class VectorRAII {
|
||||
friend class YAMLDocWriter;
|
||||
YAMLDocWriter* m_w = nullptr;
|
||||
VectorRAII(YAMLDocWriter* w) : m_w(w) {}
|
||||
explicit VectorRAII(YAMLDocWriter* w) : m_w(w) {}
|
||||
VectorRAII() = default;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue