diff --git a/include/json/config.h b/include/json/config.h index cbb5950e2..cf787ca46 100644 --- a/include/json/config.h +++ b/include/json/config.h @@ -135,23 +135,23 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size, #endif // if !defined(JSON_IS_AMALGAMATION) namespace Json { -typedef int Int; -typedef unsigned int UInt; +using Int = int; +using UInt = unsigned int; #if defined(JSON_NO_INT64) -typedef int LargestInt; -typedef unsigned int LargestUInt; +using LargestInt = int; +using LargestUInt = unsigned int; #undef JSON_HAS_INT64 #else // if defined(JSON_NO_INT64) // For Microsoft Visual use specific types as long long is not supported #if defined(_MSC_VER) // Microsoft Visual Studio -typedef __int64 Int64; -typedef unsigned __int64 UInt64; +using Int64 = __int64; +using UInt64 = unsigned __int64; #else // if defined(_MSC_VER) // Other platforms, use long long -typedef int64_t Int64; -typedef uint64_t UInt64; +using Int64 = int64_t; +using UInt64 = uint64_t; #endif // if defined(_MSC_VER) -typedef Int64 LargestInt; -typedef UInt64 LargestUInt; +using LargestInt = Int64; +using LargestUInt = UInt64; #define JSON_HAS_INT64 #endif // if defined(JSON_NO_INT64) diff --git a/include/json/forwards.h b/include/json/forwards.h index b0d981be0..affe33a7f 100644 --- a/include/json/forwards.h +++ b/include/json/forwards.h @@ -29,7 +29,7 @@ class CharReaderBuilder; class Features; // value.h -typedef unsigned int ArrayIndex; +using ArrayIndex = unsigned int; class StaticString; class Path; class PathArgument; diff --git a/include/json/reader.h b/include/json/reader.h index 359c1eb89..4618feac1 100644 --- a/include/json/reader.h +++ b/include/json/reader.h @@ -36,8 +36,8 @@ namespace Json { class JSONCPP_DEPRECATED( "Use CharReader and CharReaderBuilder instead.") JSON_API Reader { public: - typedef char Char; - typedef const Char* Location; + using Char = char; + using Location = const Char*; /** \brief An error tagged with where in the JSON text it was encountered. * @@ -187,7 +187,7 @@ class JSONCPP_DEPRECATED( Location extra_; }; - typedef std::deque Errors; + using Errors = std::deque; bool readToken(Token& token); void skipSpaces(); @@ -226,7 +226,7 @@ class JSONCPP_DEPRECATED( static bool containsNewLine(Location begin, Location end); static String normalizeEOL(Location begin, Location end); - typedef std::stack Nodes; + using Nodes = std::stack; Nodes nodes_; Errors errors_; String document_; diff --git a/include/json/value.h b/include/json/value.h index d0af7116b..b8f30386b 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -121,8 +121,8 @@ enum PrecisionType { }; //# ifdef JSON_USE_CPPTL -// typedef CppTL::AnyEnumerator EnumMemberNames; -// typedef CppTL::AnyEnumerator EnumValues; +// using EnumMemberNames = CppTL::AnyEnumerator; +// using EnumValues = CppTL::AnyEnumerator; //# endif /** \brief Lightweight wrapper to tag static string. @@ -189,21 +189,21 @@ class JSON_API Value { friend class ValueIteratorBase; public: - typedef std::vector Members; - typedef ValueIterator iterator; - typedef ValueConstIterator const_iterator; - typedef Json::UInt UInt; - typedef Json::Int Int; + using Members = std::vector; + using iterator = ValueIterator; + using const_iterator = ValueConstIterator; + using UInt = Json::UInt; + using Int = Json::Int; #if defined(JSON_HAS_INT64) - typedef Json::UInt64 UInt64; - typedef Json::Int64 Int64; + using UInt64 = Json::UInt64; + using Int64 = Json::Int64; #endif // defined(JSON_HAS_INT64) - typedef Json::LargestInt LargestInt; - typedef Json::LargestUInt LargestUInt; - typedef Json::ArrayIndex ArrayIndex; + using LargestInt = Json::LargestInt; + using LargestUInt = Json::LargestUInt; + using ArrayIndex = Json::ArrayIndex; // Required for boost integration, e. g. BOOST_TEST - typedef std::string value_type; + using value_type = std::string; #if JSON_USE_NULLREF // Binary compatibility kludges, do not use. @@ -288,9 +288,9 @@ class JSON_API Value { public: #ifndef JSON_USE_CPPTL_SMALLMAP - typedef std::map ObjectValues; + using ObjectValues = std::map; #else - typedef CppTL::SmallMap ObjectValues; + using ObjectValues = CppTL::SmallMap; #endif // ifndef JSON_USE_CPPTL_SMALLMAP #endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION @@ -627,7 +627,7 @@ class JSON_API Value { // struct MemberNamesTransform //{ - // typedef const char *result_type; + // using result_type = const char*; // const char *operator()( const CZString &name ) const // { // return name.c_str(); @@ -718,8 +718,8 @@ class JSON_API Path { Value& make(Value& root) const; private: - typedef std::vector InArgs; - typedef std::vector Args; + using InArgs = std::vector; + using Args = std::vector; void makePath(const String& path, const InArgs& in); void addPathInArg(const String& path, const InArgs& in, @@ -734,10 +734,9 @@ class JSON_API Path { */ class JSON_API ValueIteratorBase { public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef unsigned int size_t; - typedef int difference_type; - typedef ValueIteratorBase SelfType; + using iterator_category = std::bidirectional_iterator_tag; + using difference_type = int; + using SelfType = ValueIteratorBase; bool operator==(const SelfType& other) const { return isEqual(other); } @@ -810,12 +809,11 @@ class JSON_API ValueConstIterator : public ValueIteratorBase { friend class Value; public: - typedef const Value value_type; - // typedef unsigned int size_t; - // typedef int difference_type; - typedef const Value& reference; - typedef const Value* pointer; - typedef ValueConstIterator SelfType; + using value_type = const Value; + // using difference_type = int; + using reference = const Value&; + using pointer = const Value*; + using SelfType = ValueConstIterator; ValueConstIterator(); ValueConstIterator(ValueIterator const& other); @@ -861,12 +859,11 @@ class JSON_API ValueIterator : public ValueIteratorBase { friend class Value; public: - typedef Value value_type; - typedef unsigned int size_t; - typedef int difference_type; - typedef Value& reference; - typedef Value* pointer; - typedef ValueIterator SelfType; + using value_type = Value; + using difference_type = int; + using reference = Value&; + using pointer = Value*; + using SelfType = ValueIterator; ValueIterator(); explicit ValueIterator(const ValueConstIterator& other); diff --git a/include/json/writer.h b/include/json/writer.h index a72c06a40..fb0852a0c 100644 --- a/include/json/writer.h +++ b/include/json/writer.h @@ -252,7 +252,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API static bool hasCommentForValue(const Value& value); static String normalizeEOL(const String& text); - typedef std::vector ChildValues; + using ChildValues = std::vector; ChildValues childValues_; String document_; @@ -326,7 +326,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API static bool hasCommentForValue(const Value& value); static String normalizeEOL(const String& text); - typedef std::vector ChildValues; + using ChildValues = std::vector; ChildValues childValues_; OStream* document_; diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index 0c1e88d21..341434d0f 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -51,10 +51,10 @@ static size_t const stackLimit_g = namespace Json { -#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520) +#if (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520) using CharReaderPtr = std::unique_ptr; #else -typedef std::auto_ptr CharReaderPtr; +using CharReaderPtr = std::auto_ptr; #endif // Implementation of class Features diff --git a/src/lib_json/json_tool.h b/src/lib_json/json_tool.h index 5c13f1fed..2d7b7d9a0 100644 --- a/src/lib_json/json_tool.h +++ b/src/lib_json/json_tool.h @@ -71,7 +71,7 @@ enum { }; // Defines a char buffer for use with uintToString(). -typedef char UIntToStringBuffer[uintToStringBufferSize]; +using UIntToStringBuffer = char[uintToStringBufferSize]; /** Converts an unsigned integer to string. * @param value Unsigned integer to convert to string diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 519ce23ad..9300d6d05 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -83,10 +83,10 @@ namespace Json { -#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520) +#if (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520) using StreamWriterPtr = std::unique_ptr; #else -typedef std::auto_ptr StreamWriterPtr; +using StreamWriterPtr = std::auto_ptr; #endif String valueToString(LargestInt value) { diff --git a/src/test_lib_json/jsontest.cpp b/src/test_lib_json/jsontest.cpp index 0cc500a88..b09f0bcaa 100644 --- a/src/test_lib_json/jsontest.cpp +++ b/src/test_lib_json/jsontest.cpp @@ -301,7 +301,7 @@ void Runner::listTests() const { } int Runner::runCommandLine(int argc, const char* argv[]) const { - // typedef std::deque TestNames; + // using TestNames = std::deque; Runner subrunner; for (int index = 1; index < argc; ++index) { Json::String opt = argv[index]; diff --git a/src/test_lib_json/jsontest.h b/src/test_lib_json/jsontest.h index e076f7c2b..8c3aa5e32 100644 --- a/src/test_lib_json/jsontest.h +++ b/src/test_lib_json/jsontest.h @@ -42,7 +42,7 @@ class Failure { /// Must be a POD to allow inline initialisation without stepping /// into the debugger. struct PredicateContext { - typedef unsigned int Id; + using Id = unsigned int; Id id_; const char* file_; unsigned int line_; @@ -102,7 +102,7 @@ class TestResult { static Json::String indentText(const Json::String& text, const Json::String& indent); - typedef std::deque Failures; + using Failures = std::deque; Failures failures_; Json::String name_; PredicateContext rootPredicateNode_; @@ -129,7 +129,7 @@ class TestCase { }; /// Function pointer type for TestCase factory -typedef TestCase* (*TestCaseFactory)(); +using TestCaseFactory = TestCase* (*)(); class Runner { public: @@ -168,7 +168,7 @@ class Runner { static void preventDialogOnCrash(); private: - typedef std::deque Factories; + using Factories = std::deque; Factories tests_; };