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