Skip to content

Commit e54b204

Browse files
authored
Standardise use of type aliases and rvalue references in for loops (#32)
We currently use a mixture of type aliases and typedefs in our code. Since type aliasing provides a strict superset of the functionality of typedefs, but is otherwise essentially equivalent, it seems sensible to standardise on only using type aliasing throughout. This also adopts the convention of not using rvalue references in for loops, except for template code, on grounds of readability.
1 parent 09f401c commit e54b204

File tree

400 files changed

+2996
-2997
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

400 files changed

+2996
-2997
lines changed

bin/autoconfig/CCmdLineParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace autoconfig
3636
class CCmdLineParser
3737
{
3838
public:
39-
typedef std::vector<std::string> TStrVec;
39+
using TStrVec = std::vector<std::string>;
4040

4141
public:
4242
//! Parse the arguments and return options if appropriate.

include/api/CAnomalyJob.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,22 @@ class API_EXPORT CAnomalyJob : public CDataProcessor
121121

122122

123123
public:
124-
typedef std::function<void(const CModelSnapshotJsonWriter::SModelSnapshotReport &)> TPersistCompleteFunc;
125-
typedef model::CAnomalyDetector::TAnomalyDetectorPtr TAnomalyDetectorPtr;
126-
typedef std::vector<TAnomalyDetectorPtr> TAnomalyDetectorPtrVec;
127-
typedef std::vector<TAnomalyDetectorPtr>::iterator TAnomalyDetectorPtrVecItr;
128-
typedef std::vector<TAnomalyDetectorPtr>::const_iterator TAnomalyDetectorPtrVecCItr;
129-
typedef std::vector<model::CSearchKey> TKeyVec;
130-
typedef boost::unordered_map<model::CSearchKey::TStrKeyPr,
131-
TAnomalyDetectorPtr,
132-
model::CStrKeyPrHash,
133-
model::CStrKeyPrEqual> TKeyAnomalyDetectorPtrUMap;
134-
typedef std::pair<model::CSearchKey::TStrCRefKeyCRefPr, TAnomalyDetectorPtr> TKeyCRefAnomalyDetectorPtrPr;
135-
typedef std::vector<TKeyCRefAnomalyDetectorPtrPr> TKeyCRefAnomalyDetectorPtrPrVec;
136-
typedef model::CAnomalyDetector::TModelPlotDataVec TModelPlotDataVec;
137-
typedef TModelPlotDataVec::const_iterator TModelPlotDataVecCItr;
138-
typedef model::CBucketQueue<TModelPlotDataVec> TModelPlotDataVecQueue;
124+
using TPersistCompleteFunc = std::function<void(const CModelSnapshotJsonWriter::SModelSnapshotReport &)>;
125+
using TAnomalyDetectorPtr = model::CAnomalyDetector::TAnomalyDetectorPtr;
126+
using TAnomalyDetectorPtrVec = std::vector<TAnomalyDetectorPtr>;
127+
using TAnomalyDetectorPtrVecItr = std::vector<TAnomalyDetectorPtr>::iterator;
128+
using TAnomalyDetectorPtrVecCItr = std::vector<TAnomalyDetectorPtr>::const_iterator;
129+
using TKeyVec = std::vector<model::CSearchKey>;
130+
using TKeyAnomalyDetectorPtrUMap =
131+
boost::unordered_map<model::CSearchKey::TStrKeyPr,
132+
TAnomalyDetectorPtr,
133+
model::CStrKeyPrHash,
134+
model::CStrKeyPrEqual>;
135+
using TKeyCRefAnomalyDetectorPtrPr = std::pair<model::CSearchKey::TStrCRefKeyCRefPr, TAnomalyDetectorPtr>;
136+
using TKeyCRefAnomalyDetectorPtrPrVec = std::vector<TKeyCRefAnomalyDetectorPtrPr>;
137+
using TModelPlotDataVec = model::CAnomalyDetector::TModelPlotDataVec;
138+
using TModelPlotDataVecCItr = TModelPlotDataVec::const_iterator;
139+
using TModelPlotDataVecQueue = model::CBucketQueue<TModelPlotDataVec>;
139140

140141
struct API_EXPORT SRestoredStateDetail
141142
{
@@ -164,7 +165,7 @@ class API_EXPORT CAnomalyJob : public CDataProcessor
164165
TKeyCRefAnomalyDetectorPtrPrVec s_Detectors;
165166
};
166167

167-
typedef boost::shared_ptr<SBackgroundPersistArgs> TBackgroundPersistArgsPtr;
168+
using TBackgroundPersistArgsPtr = boost::shared_ptr<SBackgroundPersistArgs>;
168169

169170
public:
170171
CAnomalyJob(const std::string &jobId,

include/api/CBenchMarker.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,20 @@ class API_EXPORT CBenchMarker
4949
{
5050
public:
5151
//! A count and and example string
52-
typedef std::pair<size_t, std::string> TSizeStrPr;
52+
using TSizeStrPr = std::pair<size_t, std::string>;
5353

5454
//! Used for mapping Ml type to count and example
55-
typedef std::map<int, TSizeStrPr> TIntSizeStrPrMap;
56-
typedef TIntSizeStrPrMap::iterator TIntSizeStrPrMapItr;
57-
typedef TIntSizeStrPrMap::const_iterator TIntSizeStrPrMapCItr;
55+
using TIntSizeStrPrMap = std::map<int, TSizeStrPr>;
56+
using TIntSizeStrPrMapItr = TIntSizeStrPrMap::iterator;
57+
using TIntSizeStrPrMapCItr = TIntSizeStrPrMap::const_iterator;
5858

5959
//! A regex and its corresponding type count map
60-
typedef std::pair<core::CRegex, TIntSizeStrPrMap> TRegexIntSizeStrPrMapPr;
60+
using TRegexIntSizeStrPrMapPr = std::pair<core::CRegex, TIntSizeStrPrMap>;
6161

6262
//! Vector of regexes with corresponding type count maps
63-
typedef std::vector<TRegexIntSizeStrPrMapPr> TRegexIntSizeStrPrMapPrVec;
64-
typedef TRegexIntSizeStrPrMapPrVec::iterator TRegexIntSizeStrPrMapPrVecItr;
65-
typedef TRegexIntSizeStrPrMapPrVec::const_iterator TRegexIntSizeStrPrMapPrVecCItr;
63+
using TRegexIntSizeStrPrMapPrVec = std::vector<TRegexIntSizeStrPrMapPr>;
64+
using TRegexIntSizeStrPrMapPrVecItr = TRegexIntSizeStrPrMapPrVec::iterator;
65+
using TRegexIntSizeStrPrMapPrVecCItr = TRegexIntSizeStrPrMapPrVec::const_iterator;
6666

6767
public:
6868
CBenchMarker(void);

include/api/CCategoryExamplesCollector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ namespace api
4242
class API_EXPORT CCategoryExamplesCollector
4343
{
4444
public:
45-
typedef std::set<std::string> TStrSet;
46-
typedef TStrSet::const_iterator TStrSetCItr;
45+
using TStrSet = std::set<std::string>;
46+
using TStrSetCItr = TStrSet::const_iterator;
4747

4848
//! Truncate examples to be no longer than this
4949
static const size_t MAX_EXAMPLE_LENGTH;

include/api/CCsvOutputWriter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ class API_EXPORT CCsvOutputWriter : public COutputHandler
145145
//! an appropriate level, avoiding regular memory allocations.
146146
std::string m_WorkRecord;
147147

148-
typedef std::pair<std::string, std::string > TStrStrPr;
149-
typedef std::set<TStrStrPr> TStrStrPrSet;
150-
typedef TStrStrPrSet::const_iterator TStrStrPrSetCItr;
148+
using TStrStrPr = std::pair<std::string, std::string>;
149+
using TStrStrPrSet = std::set<TStrStrPr>;
150+
using TStrStrPrSetCItr = TStrStrPrSet::const_iterator;
151151

152152
//! Messages to be printed before the next lot of output
153153
TStrStrPrSet m_Messages;

include/api/CDataProcessor.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ class API_EXPORT CDataProcessor : private core::CNonCopyable
5858
static const std::string CONTROL_FIELD_NAME;
5959

6060
public:
61-
typedef std::vector<std::string> TStrVec;
62-
typedef TStrVec::iterator TStrVecItr;
63-
typedef TStrVec::const_iterator TStrVecCItr;
61+
using TStrVec = std::vector<std::string>;
62+
using TStrVecItr = TStrVec::iterator;
63+
using TStrVecCItr = TStrVec::const_iterator;
6464

65-
typedef boost::unordered_map<std::string, std::string> TStrStrUMap;
66-
typedef TStrStrUMap::iterator TStrStrUMapItr;
67-
typedef TStrStrUMap::const_iterator TStrStrUMapCItr;
65+
using TStrStrUMap = boost::unordered_map<std::string, std::string>;
66+
using TStrStrUMapItr = TStrStrUMap::iterator;
67+
using TStrStrUMapCItr = TStrStrUMap::const_iterator;
6868

6969
public:
7070
CDataProcessor(void);

include/api/CDataTyper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ class API_EXPORT CDataTyper
5353
{
5454
public:
5555
//! Used for storing distinct token IDs
56-
typedef boost::unordered_map<std::string, std::string> TStrStrUMap;
57-
typedef TStrStrUMap::const_iterator TStrStrUMapCItr;
56+
using TStrStrUMap = boost::unordered_map<std::string, std::string>;
57+
using TStrStrUMapCItr = TStrStrUMap::const_iterator;
5858

5959
//! Shared pointer to an instance of this class
60-
typedef boost::shared_ptr<CDataTyper> TDataTyperP;
60+
using TDataTyperP = boost::shared_ptr<CDataTyper>;
6161

6262
//! Shared pointer to an instance of this class
63-
typedef std::function<void(core::CStatePersistInserter &)> TPersistFunc;
63+
using TPersistFunc = std::function<void(core::CStatePersistInserter &)>;
6464

6565
public:
6666
CDataTyper(const std::string &fieldName);

include/api/CDetectionRulesJsonParser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ namespace api
3838
class API_EXPORT CDetectionRulesJsonParser
3939
{
4040
public:
41-
typedef std::vector<model::CDetectionRule> TDetectionRuleVec;
42-
typedef boost::unordered_map<std::string, core::CPatternSet> TStrPatternSetUMap;
41+
using TDetectionRuleVec = std::vector<model::CDetectionRule>;
42+
using TStrPatternSetUMap = boost::unordered_map<std::string, core::CPatternSet>;
4343

4444
public:
4545
//! Default constructor

include/api/CFieldConfig.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ class API_EXPORT CFieldConfig
351351
//! Uniqueness is enforced by config key and also by the combination of
352352
//! function, field name, by field name, over field name and
353353
//! partition field name.
354-
typedef boost::multi_index::multi_index_container<
354+
using TFieldOptionsMIndex = boost::multi_index::multi_index_container<
355355
CFieldOptions,
356356
boost::multi_index::indexed_by<
357357
boost::multi_index::ordered_unique<
@@ -370,28 +370,28 @@ class API_EXPORT CFieldConfig
370370
>
371371
>
372372
>
373-
> TFieldOptionsMIndex;
373+
>;
374374

375-
typedef TFieldOptionsMIndex::iterator TFieldOptionsMIndexItr;
376-
typedef TFieldOptionsMIndex::const_iterator TFieldOptionsMIndexCItr;
375+
using TFieldOptionsMIndexItr = TFieldOptionsMIndex::iterator;
376+
using TFieldOptionsMIndexCItr = TFieldOptionsMIndex::const_iterator;
377377

378378
//! Used to maintain a list of all unique config keys
379-
typedef std::set<int> TIntSet;
379+
using TIntSet = std::set<int>;
380380

381381
//! Used to return the superset of enabled field names
382-
typedef std::set<std::string> TStrSet;
382+
using TStrSet = std::set<std::string>;
383383

384384
//! Used to obtain command line clause tokens
385-
typedef std::vector<std::string> TStrVec;
386-
typedef TStrVec::iterator TStrVecItr;
385+
using TStrVec = std::vector<std::string>;
386+
using TStrVecItr = TStrVec::iterator;
387387

388-
typedef std::vector<model::CDetectionRule> TDetectionRuleVec;
389-
typedef boost::unordered_map<int, TDetectionRuleVec> TIntDetectionRuleVecUMap;
388+
using TDetectionRuleVec = std::vector<model::CDetectionRule>;
389+
using TIntDetectionRuleVecUMap = boost::unordered_map<int, TDetectionRuleVec>;
390390

391-
typedef boost::unordered_map<std::string, core::CPatternSet> TStrPatternSetUMap;
391+
using TStrPatternSetUMap = boost::unordered_map<std::string, core::CPatternSet>;
392392

393-
typedef std::pair<std::string, model::CDetectionRule> TStrDetectionRulePr;
394-
typedef std::vector<TStrDetectionRulePr> TStrDetectionRulePrVec;
393+
using TStrDetectionRulePr = std::pair<std::string, model::CDetectionRule>;
394+
using TStrDetectionRulePrVec = std::vector<TStrDetectionRulePr>;
395395

396396
public:
397397
//! Construct empty. This call should generally be followed by a call to

include/api/CFieldDataTyper.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ class API_EXPORT CFieldDataTyper : public CDataProcessor
7777
public:
7878
// A type of token list data typer that DOESN'T exclude fields from its
7979
// analysis
80-
typedef CTokenListDataTyper<true, // Warping
81-
true, // Underscores
82-
true, // Dots
83-
true, // Dashes
84-
true, // Ignore leading digit
85-
true, // Ignore hex
86-
true, // Ignore date words
87-
false, // Ignore field names
88-
2, // Min dictionary word length
89-
core::CWordDictionary::TWeightVerbs5Other2>
90-
TTokenListDataTyperKeepsFields;
80+
using TTokenListDataTyperKeepsFields =
81+
CTokenListDataTyper<true, // Warping
82+
true, // Underscores
83+
true, // Dots
84+
true, // Dashes
85+
true, // Ignore leading digit
86+
true, // Ignore hex
87+
true, // Ignore date words
88+
false, // Ignore field names
89+
2, // Min dictionary word length
90+
core::CWordDictionary::TWeightVerbs5Other2>;
9191

9292
public:
9393
//! Construct without persistence capability
@@ -160,7 +160,7 @@ class API_EXPORT CFieldDataTyper : public CDataProcessor
160160
void acknowledgeFlush(const std::string &flushId);
161161

162162
private:
163-
typedef CCategoryExamplesCollector::TStrSet TStrSet;
163+
using TStrSet = CCategoryExamplesCollector::TStrSet;
164164

165165
private:
166166
//! The job ID

0 commit comments

Comments
 (0)