Skip to content

Change all typedefs into using decls #1092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions include/json/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion include/json/forwards.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CharReaderBuilder;
class Features;

// value.h
typedef unsigned int ArrayIndex;
using ArrayIndex = unsigned int;
class StaticString;
class Path;
class PathArgument;
Expand Down
8 changes: 4 additions & 4 deletions include/json/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -187,7 +187,7 @@ class JSONCPP_DEPRECATED(
Location extra_;
};

typedef std::deque<ErrorInfo> Errors;
using Errors = std::deque<ErrorInfo>;

bool readToken(Token& token);
void skipSpaces();
Expand Down Expand Up @@ -226,7 +226,7 @@ class JSONCPP_DEPRECATED(
static bool containsNewLine(Location begin, Location end);
static String normalizeEOL(Location begin, Location end);

typedef std::stack<Value*> Nodes;
using Nodes = std::stack<Value*>;
Nodes nodes_;
Errors errors_;
String document_;
Expand Down
65 changes: 31 additions & 34 deletions include/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ enum PrecisionType {
};

//# ifdef JSON_USE_CPPTL
// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
// typedef CppTL::AnyEnumerator<const Value &> EnumValues;
// using EnumMemberNames = CppTL::AnyEnumerator<const char *>;
// using EnumValues = CppTL::AnyEnumerator<const Value &>;
//# endif

/** \brief Lightweight wrapper to tag static string.
Expand Down Expand Up @@ -189,21 +189,21 @@ class JSON_API Value {
friend class ValueIteratorBase;

public:
typedef std::vector<String> Members;
typedef ValueIterator iterator;
typedef ValueConstIterator const_iterator;
typedef Json::UInt UInt;
typedef Json::Int Int;
using Members = std::vector<String>;
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.
Expand Down Expand Up @@ -288,9 +288,9 @@ class JSON_API Value {

public:
#ifndef JSON_USE_CPPTL_SMALLMAP
typedef std::map<CZString, Value> ObjectValues;
using ObjectValues = std::map<CZString, Value>;
#else
typedef CppTL::SmallMap<CZString, Value> ObjectValues;
using ObjectValues = CppTL::SmallMap<CZString, Value>;
#endif // ifndef JSON_USE_CPPTL_SMALLMAP
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -718,8 +718,8 @@ class JSON_API Path {
Value& make(Value& root) const;

private:
typedef std::vector<const PathArgument*> InArgs;
typedef std::vector<PathArgument> Args;
using InArgs = std::vector<const PathArgument*>;
using Args = std::vector<PathArgument>;

void makePath(const String& path, const InArgs& in);
void addPathInArg(const String& path, const InArgs& in,
Expand All @@ -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); }

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions include/json/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> ChildValues;
using ChildValues = std::vector<String>;

ChildValues childValues_;
String document_;
Expand Down Expand Up @@ -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<String> ChildValues;
using ChildValues = std::vector<String>;

ChildValues childValues_;
OStream* document_;
Expand Down
4 changes: 2 additions & 2 deletions src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CharReader>;
#else
typedef std::auto_ptr<CharReader> CharReaderPtr;
using CharReaderPtr = std::auto_ptr<CharReader>;
#endif

// Implementation of class Features
Expand Down
2 changes: 1 addition & 1 deletion src/lib_json/json_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/lib_json/json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<StreamWriter>;
#else
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
using StreamWriterPtr = std::auto_ptr<StreamWriter>;
#endif

String valueToString(LargestInt value) {
Expand Down
2 changes: 1 addition & 1 deletion src/test_lib_json/jsontest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void Runner::listTests() const {
}

int Runner::runCommandLine(int argc, const char* argv[]) const {
// typedef std::deque<String> TestNames;
// using TestNames = std::deque<String>;
Runner subrunner;
for (int index = 1; index < argc; ++index) {
Json::String opt = argv[index];
Expand Down
8 changes: 4 additions & 4 deletions src/test_lib_json/jsontest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -102,7 +102,7 @@ class TestResult {
static Json::String indentText(const Json::String& text,
const Json::String& indent);

typedef std::deque<Failure> Failures;
using Failures = std::deque<Failure>;
Failures failures_;
Json::String name_;
PredicateContext rootPredicateNode_;
Expand All @@ -129,7 +129,7 @@ class TestCase {
};

/// Function pointer type for TestCase factory
typedef TestCase* (*TestCaseFactory)();
using TestCaseFactory = TestCase* (*)();

class Runner {
public:
Expand Down Expand Up @@ -168,7 +168,7 @@ class Runner {
static void preventDialogOnCrash();

private:
typedef std::deque<TestCaseFactory> Factories;
using Factories = std::deque<TestCaseFactory>;
Factories tests_;
};

Expand Down