Skip to content

Commit d13d942

Browse files
committed
Change typedef => to using decls
Remove the `size_t` typedefs from the Iterator classes.
1 parent 2703c30 commit d13d942

File tree

10 files changed

+58
-61
lines changed

10 files changed

+58
-61
lines changed

include/json/config.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,23 @@ extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
135135
#endif // if !defined(JSON_IS_AMALGAMATION)
136136

137137
namespace Json {
138-
typedef int Int;
139-
typedef unsigned int UInt;
138+
using Int = int;
139+
using UInt = unsigned int;
140140
#if defined(JSON_NO_INT64)
141-
typedef int LargestInt;
142-
typedef unsigned int LargestUInt;
141+
using LargestInt = int;
142+
using LargestUInt = unsigned int;
143143
#undef JSON_HAS_INT64
144144
#else // if defined(JSON_NO_INT64)
145145
// For Microsoft Visual use specific types as long long is not supported
146146
#if defined(_MSC_VER) // Microsoft Visual Studio
147-
typedef __int64 Int64;
148-
typedef unsigned __int64 UInt64;
147+
using Int64 = __int64;
148+
using UInt64 = unsigned __int64;
149149
#else // if defined(_MSC_VER) // Other platforms, use long long
150-
typedef int64_t Int64;
151-
typedef uint64_t UInt64;
150+
using Int64 = int64_t;
151+
using UInt64 = uint64_t;
152152
#endif // if defined(_MSC_VER)
153-
typedef Int64 LargestInt;
154-
typedef UInt64 LargestUInt;
153+
using LargestInt = Int64;
154+
using LargestUInt = UInt64;
155155
#define JSON_HAS_INT64
156156
#endif // if defined(JSON_NO_INT64)
157157

include/json/forwards.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CharReaderBuilder;
2929
class Features;
3030

3131
// value.h
32-
typedef unsigned int ArrayIndex;
32+
using ArrayIndex = unsigned int;
3333
class StaticString;
3434
class Path;
3535
class PathArgument;

include/json/reader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace Json {
3636
class JSONCPP_DEPRECATED(
3737
"Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
3838
public:
39-
typedef char Char;
40-
typedef const Char* Location;
39+
using Char = char;
40+
using Location = const Char*;
4141

4242
/** \brief An error tagged with where in the JSON text it was encountered.
4343
*
@@ -187,7 +187,7 @@ class JSONCPP_DEPRECATED(
187187
Location extra_;
188188
};
189189

190-
typedef std::deque<ErrorInfo> Errors;
190+
using Errors = std::deque<ErrorInfo>;
191191

192192
bool readToken(Token& token);
193193
void skipSpaces();
@@ -226,7 +226,7 @@ class JSONCPP_DEPRECATED(
226226
static bool containsNewLine(Location begin, Location end);
227227
static String normalizeEOL(Location begin, Location end);
228228

229-
typedef std::stack<Value*> Nodes;
229+
using Nodes = std::stack<Value*>;
230230
Nodes nodes_;
231231
Errors errors_;
232232
String document_;

include/json/value.h

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ enum PrecisionType {
121121
};
122122

123123
//# ifdef JSON_USE_CPPTL
124-
// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
125-
// typedef CppTL::AnyEnumerator<const Value &> EnumValues;
124+
// using EnumMemberNames = CppTL::AnyEnumerator<const char *>;
125+
// using EnumValues = CppTL::AnyEnumerator<const Value &>;
126126
//# endif
127127

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

191191
public:
192-
typedef std::vector<String> Members;
193-
typedef ValueIterator iterator;
194-
typedef ValueConstIterator const_iterator;
195-
typedef Json::UInt UInt;
196-
typedef Json::Int Int;
192+
using Members = std::vector<String>;
193+
using iterator = ValueIterator;
194+
using const_iterator = ValueConstIterator;
195+
using UInt = Json::UInt;
196+
using Int = Json::Int;
197197
#if defined(JSON_HAS_INT64)
198-
typedef Json::UInt64 UInt64;
199-
typedef Json::Int64 Int64;
198+
using UInt64 = Json::UInt64;
199+
using Int64 = Json::Int64;
200200
#endif // defined(JSON_HAS_INT64)
201-
typedef Json::LargestInt LargestInt;
202-
typedef Json::LargestUInt LargestUInt;
203-
typedef Json::ArrayIndex ArrayIndex;
201+
using LargestInt = Json::LargestInt;
202+
using LargestUInt = Json::LargestUInt;
203+
using ArrayIndex = Json::ArrayIndex;
204204

205205
// Required for boost integration, e. g. BOOST_TEST
206-
typedef std::string value_type;
206+
using value_type = std::string;
207207

208208
#if JSON_USE_NULLREF
209209
// Binary compatibility kludges, do not use.
@@ -288,9 +288,9 @@ class JSON_API Value {
288288

289289
public:
290290
#ifndef JSON_USE_CPPTL_SMALLMAP
291-
typedef std::map<CZString, Value> ObjectValues;
291+
using ObjectValues = std::map<CZString, Value>;
292292
#else
293-
typedef CppTL::SmallMap<CZString, Value> ObjectValues;
293+
using ObjectValues = CppTL::SmallMap<CZString, Value>;
294294
#endif // ifndef JSON_USE_CPPTL_SMALLMAP
295295
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
296296

@@ -627,7 +627,7 @@ class JSON_API Value {
627627

628628
// struct MemberNamesTransform
629629
//{
630-
// typedef const char *result_type;
630+
// using result_type = const char*;
631631
// const char *operator()( const CZString &name ) const
632632
// {
633633
// return name.c_str();
@@ -718,8 +718,8 @@ class JSON_API Path {
718718
Value& make(Value& root) const;
719719

720720
private:
721-
typedef std::vector<const PathArgument*> InArgs;
722-
typedef std::vector<PathArgument> Args;
721+
using InArgs = std::vector<const PathArgument*>;
722+
using Args = std::vector<PathArgument>;
723723

724724
void makePath(const String& path, const InArgs& in);
725725
void addPathInArg(const String& path, const InArgs& in,
@@ -734,10 +734,9 @@ class JSON_API Path {
734734
*/
735735
class JSON_API ValueIteratorBase {
736736
public:
737-
typedef std::bidirectional_iterator_tag iterator_category;
738-
typedef unsigned int size_t;
739-
typedef int difference_type;
740-
typedef ValueIteratorBase SelfType;
737+
using iterator_category = std::bidirectional_iterator_tag;
738+
using difference_type = int;
739+
using SelfType = ValueIteratorBase;
741740

742741
bool operator==(const SelfType& other) const { return isEqual(other); }
743742

@@ -810,12 +809,11 @@ class JSON_API ValueConstIterator : public ValueIteratorBase {
810809
friend class Value;
811810

812811
public:
813-
typedef const Value value_type;
814-
// typedef unsigned int size_t;
815-
// typedef int difference_type;
816-
typedef const Value& reference;
817-
typedef const Value* pointer;
818-
typedef ValueConstIterator SelfType;
812+
using value_type = const Value;
813+
// using difference_type = int;
814+
using reference = const Value&;
815+
using pointer = const Value*;
816+
using SelfType = ValueConstIterator;
819817

820818
ValueConstIterator();
821819
ValueConstIterator(ValueIterator const& other);
@@ -861,12 +859,11 @@ class JSON_API ValueIterator : public ValueIteratorBase {
861859
friend class Value;
862860

863861
public:
864-
typedef Value value_type;
865-
typedef unsigned int size_t;
866-
typedef int difference_type;
867-
typedef Value& reference;
868-
typedef Value* pointer;
869-
typedef ValueIterator SelfType;
862+
using value_type = Value;
863+
using difference_type = int;
864+
using reference = Value&;
865+
using pointer = Value*;
866+
using SelfType = ValueIterator;
870867

871868
ValueIterator();
872869
explicit ValueIterator(const ValueConstIterator& other);

include/json/writer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
252252
static bool hasCommentForValue(const Value& value);
253253
static String normalizeEOL(const String& text);
254254

255-
typedef std::vector<String> ChildValues;
255+
using ChildValues = std::vector<String>;
256256

257257
ChildValues childValues_;
258258
String document_;
@@ -326,7 +326,7 @@ class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
326326
static bool hasCommentForValue(const Value& value);
327327
static String normalizeEOL(const String& text);
328328

329-
typedef std::vector<String> ChildValues;
329+
using ChildValues = std::vector<String>;
330330

331331
ChildValues childValues_;
332332
OStream* document_;

src/lib_json/json_reader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ static size_t const stackLimit_g =
5151

5252
namespace Json {
5353

54-
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
54+
#if (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
5555
using CharReaderPtr = std::unique_ptr<CharReader>;
5656
#else
57-
typedef std::auto_ptr<CharReader> CharReaderPtr;
57+
using CharReaderPtr = std::auto_ptr<CharReader>;
5858
#endif
5959

6060
// Implementation of class Features

src/lib_json/json_tool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ enum {
7171
};
7272

7373
// Defines a char buffer for use with uintToString().
74-
typedef char UIntToStringBuffer[uintToStringBufferSize];
74+
using UIntToStringBuffer = char[uintToStringBufferSize];
7575

7676
/** Converts an unsigned integer to string.
7777
* @param value Unsigned integer to convert to string

src/lib_json/json_writer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@
8383

8484
namespace Json {
8585

86-
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
86+
#if (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
8787
using StreamWriterPtr = std::unique_ptr<StreamWriter>;
8888
#else
89-
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
89+
using StreamWriterPtr = std::auto_ptr<StreamWriter>;
9090
#endif
9191

9292
String valueToString(LargestInt value) {

src/test_lib_json/jsontest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void Runner::listTests() const {
301301
}
302302

303303
int Runner::runCommandLine(int argc, const char* argv[]) const {
304-
// typedef std::deque<String> TestNames;
304+
// using TestNames = std::deque<String>;
305305
Runner subrunner;
306306
for (int index = 1; index < argc; ++index) {
307307
Json::String opt = argv[index];

src/test_lib_json/jsontest.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Failure {
4141
/// Must be a POD to allow inline initialisation without stepping
4242
/// into the debugger.
4343
struct PredicateContext {
44-
typedef unsigned int Id;
44+
using Id = unsigned int;
4545
Id id_;
4646
const char* file_;
4747
unsigned int line_;
@@ -103,7 +103,7 @@ class TestResult {
103103
static Json::String indentText(const Json::String& text,
104104
const Json::String& indent);
105105

106-
typedef std::deque<Failure> Failures;
106+
using Failures = std::deque<Failure>;
107107
Failures failures_;
108108
Json::String name_;
109109
PredicateContext rootPredicateNode_;
@@ -130,7 +130,7 @@ class TestCase {
130130
};
131131

132132
/// Function pointer type for TestCase factory
133-
typedef TestCase* (*TestCaseFactory)();
133+
using TestCaseFactory = TestCase* (*)();
134134

135135
class Runner {
136136
public:
@@ -169,7 +169,7 @@ class Runner {
169169
static void preventDialogOnCrash();
170170

171171
private:
172-
typedef std::deque<TestCaseFactory> Factories;
172+
using Factories = std::deque<TestCaseFactory>;
173173
Factories tests_;
174174
};
175175

0 commit comments

Comments
 (0)