Skip to content

Commit ec28abd

Browse files
committed
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 f26b907 commit ec28abd

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
@@ -27,7 +27,7 @@ namespace autoconfig
2727
class CCmdLineParser
2828
{
2929
public:
30-
typedef std::vector<std::string> TStrVec;
30+
using TStrVec = std::vector<std::string>;
3131

3232
public:
3333
//! 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
@@ -112,21 +112,22 @@ class API_EXPORT CAnomalyJob : public CDataProcessor
112112

113113

114114
public:
115-
typedef std::function<void(const CModelSnapshotJsonWriter::SModelSnapshotReport &)> TPersistCompleteFunc;
116-
typedef model::CAnomalyDetector::TAnomalyDetectorPtr TAnomalyDetectorPtr;
117-
typedef std::vector<TAnomalyDetectorPtr> TAnomalyDetectorPtrVec;
118-
typedef std::vector<TAnomalyDetectorPtr>::iterator TAnomalyDetectorPtrVecItr;
119-
typedef std::vector<TAnomalyDetectorPtr>::const_iterator TAnomalyDetectorPtrVecCItr;
120-
typedef std::vector<model::CSearchKey> TKeyVec;
121-
typedef boost::unordered_map<model::CSearchKey::TStrKeyPr,
122-
TAnomalyDetectorPtr,
123-
model::CStrKeyPrHash,
124-
model::CStrKeyPrEqual> TKeyAnomalyDetectorPtrUMap;
125-
typedef std::pair<model::CSearchKey::TStrCRefKeyCRefPr, TAnomalyDetectorPtr> TKeyCRefAnomalyDetectorPtrPr;
126-
typedef std::vector<TKeyCRefAnomalyDetectorPtrPr> TKeyCRefAnomalyDetectorPtrPrVec;
127-
typedef model::CAnomalyDetector::TModelPlotDataVec TModelPlotDataVec;
128-
typedef TModelPlotDataVec::const_iterator TModelPlotDataVecCItr;
129-
typedef model::CBucketQueue<TModelPlotDataVec> TModelPlotDataVecQueue;
115+
using TPersistCompleteFunc = std::function<void(const CModelSnapshotJsonWriter::SModelSnapshotReport &)>;
116+
using TAnomalyDetectorPtr = model::CAnomalyDetector::TAnomalyDetectorPtr;
117+
using TAnomalyDetectorPtrVec = std::vector<TAnomalyDetectorPtr>;
118+
using TAnomalyDetectorPtrVecItr = std::vector<TAnomalyDetectorPtr>::iterator;
119+
using TAnomalyDetectorPtrVecCItr = std::vector<TAnomalyDetectorPtr>::const_iterator;
120+
using TKeyVec = std::vector<model::CSearchKey>;
121+
using TKeyAnomalyDetectorPtrUMap =
122+
boost::unordered_map<model::CSearchKey::TStrKeyPr,
123+
TAnomalyDetectorPtr,
124+
model::CStrKeyPrHash,
125+
model::CStrKeyPrEqual>;
126+
using TKeyCRefAnomalyDetectorPtrPr = std::pair<model::CSearchKey::TStrCRefKeyCRefPr, TAnomalyDetectorPtr>;
127+
using TKeyCRefAnomalyDetectorPtrPrVec = std::vector<TKeyCRefAnomalyDetectorPtrPr>;
128+
using TModelPlotDataVec = model::CAnomalyDetector::TModelPlotDataVec;
129+
using TModelPlotDataVecCItr = TModelPlotDataVec::const_iterator;
130+
using TModelPlotDataVecQueue = model::CBucketQueue<TModelPlotDataVec>;
130131

131132
struct API_EXPORT SRestoredStateDetail
132133
{
@@ -155,7 +156,7 @@ class API_EXPORT CAnomalyJob : public CDataProcessor
155156
TKeyCRefAnomalyDetectorPtrPrVec s_Detectors;
156157
};
157158

158-
typedef boost::shared_ptr<SBackgroundPersistArgs> TBackgroundPersistArgsPtr;
159+
using TBackgroundPersistArgsPtr = boost::shared_ptr<SBackgroundPersistArgs>;
159160

160161
public:
161162
CAnomalyJob(const std::string &jobId,

include/api/CBenchMarker.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ class API_EXPORT CBenchMarker
4040
{
4141
public:
4242
//! A count and and example string
43-
typedef std::pair<size_t, std::string> TSizeStrPr;
43+
using TSizeStrPr = std::pair<size_t, std::string>;
4444

4545
//! Used for mapping Ml type to count and example
46-
typedef std::map<int, TSizeStrPr> TIntSizeStrPrMap;
47-
typedef TIntSizeStrPrMap::iterator TIntSizeStrPrMapItr;
48-
typedef TIntSizeStrPrMap::const_iterator TIntSizeStrPrMapCItr;
46+
using TIntSizeStrPrMap = std::map<int, TSizeStrPr>;
47+
using TIntSizeStrPrMapItr = TIntSizeStrPrMap::iterator;
48+
using TIntSizeStrPrMapCItr = TIntSizeStrPrMap::const_iterator;
4949

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

5353
//! Vector of regexes with corresponding type count maps
54-
typedef std::vector<TRegexIntSizeStrPrMapPr> TRegexIntSizeStrPrMapPrVec;
55-
typedef TRegexIntSizeStrPrMapPrVec::iterator TRegexIntSizeStrPrMapPrVecItr;
56-
typedef TRegexIntSizeStrPrMapPrVec::const_iterator TRegexIntSizeStrPrMapPrVecCItr;
54+
using TRegexIntSizeStrPrMapPrVec = std::vector<TRegexIntSizeStrPrMapPr>;
55+
using TRegexIntSizeStrPrMapPrVecItr = TRegexIntSizeStrPrMapPrVec::iterator;
56+
using TRegexIntSizeStrPrMapPrVecCItr = TRegexIntSizeStrPrMapPrVec::const_iterator;
5757

5858
public:
5959
CBenchMarker(void);

include/api/CCategoryExamplesCollector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ namespace api
3333
class API_EXPORT CCategoryExamplesCollector
3434
{
3535
public:
36-
typedef std::set<std::string> TStrSet;
37-
typedef TStrSet::const_iterator TStrSetCItr;
36+
using TStrSet = std::set<std::string>;
37+
using TStrSetCItr = TStrSet::const_iterator;
3838

3939
//! Truncate examples to be no longer than this
4040
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
@@ -136,9 +136,9 @@ class API_EXPORT CCsvOutputWriter : public COutputHandler
136136
//! an appropriate level, avoiding regular memory allocations.
137137
std::string m_WorkRecord;
138138

139-
typedef std::pair<std::string, std::string > TStrStrPr;
140-
typedef std::set<TStrStrPr> TStrStrPrSet;
141-
typedef TStrStrPrSet::const_iterator TStrStrPrSetCItr;
139+
using TStrStrPr = std::pair<std::string, std::string>;
140+
using TStrStrPrSet = std::set<TStrStrPr>;
141+
using TStrStrPrSetCItr = TStrStrPrSet::const_iterator;
142142

143143
//! Messages to be printed before the next lot of output
144144
TStrStrPrSet m_Messages;

include/api/CDataProcessor.h

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

5151
public:
52-
typedef std::vector<std::string> TStrVec;
53-
typedef TStrVec::iterator TStrVecItr;
54-
typedef TStrVec::const_iterator TStrVecCItr;
52+
using TStrVec = std::vector<std::string>;
53+
using TStrVecItr = TStrVec::iterator;
54+
using TStrVecCItr = TStrVec::const_iterator;
5555

56-
typedef boost::unordered_map<std::string, std::string> TStrStrUMap;
57-
typedef TStrStrUMap::iterator TStrStrUMapItr;
58-
typedef TStrStrUMap::const_iterator TStrStrUMapCItr;
56+
using TStrStrUMap = boost::unordered_map<std::string, std::string>;
57+
using TStrStrUMapItr = TStrStrUMap::iterator;
58+
using TStrStrUMapCItr = TStrStrUMap::const_iterator;
5959

6060
public:
6161
CDataProcessor(void);

include/api/CDataTyper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class API_EXPORT CDataTyper
4444
{
4545
public:
4646
//! Used for storing distinct token IDs
47-
typedef boost::unordered_map<std::string, std::string> TStrStrUMap;
48-
typedef TStrStrUMap::const_iterator TStrStrUMapCItr;
47+
using TStrStrUMap = boost::unordered_map<std::string, std::string>;
48+
using TStrStrUMapCItr = TStrStrUMap::const_iterator;
4949

5050
//! Shared pointer to an instance of this class
51-
typedef boost::shared_ptr<CDataTyper> TDataTyperP;
51+
using TDataTyperP = boost::shared_ptr<CDataTyper>;
5252

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

5656
public:
5757
CDataTyper(const std::string &fieldName);

include/api/CDetectionRulesJsonParser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ namespace api
2929
class API_EXPORT CDetectionRulesJsonParser
3030
{
3131
public:
32-
typedef std::vector<model::CDetectionRule> TDetectionRuleVec;
33-
typedef boost::unordered_map<std::string, core::CPatternSet> TStrPatternSetUMap;
32+
using TDetectionRuleVec = std::vector<model::CDetectionRule>;
33+
using TStrPatternSetUMap = boost::unordered_map<std::string, core::CPatternSet>;
3434

3535
public:
3636
//! Default constructor

include/api/CFieldConfig.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ class API_EXPORT CFieldConfig
342342
//! Uniqueness is enforced by config key and also by the combination of
343343
//! function, field name, by field name, over field name and
344344
//! partition field name.
345-
typedef boost::multi_index::multi_index_container<
345+
using TFieldOptionsMIndex = boost::multi_index::multi_index_container<
346346
CFieldOptions,
347347
boost::multi_index::indexed_by<
348348
boost::multi_index::ordered_unique<
@@ -361,28 +361,28 @@ class API_EXPORT CFieldConfig
361361
>
362362
>
363363
>
364-
> TFieldOptionsMIndex;
364+
>;
365365

366-
typedef TFieldOptionsMIndex::iterator TFieldOptionsMIndexItr;
367-
typedef TFieldOptionsMIndex::const_iterator TFieldOptionsMIndexCItr;
366+
using TFieldOptionsMIndexItr = TFieldOptionsMIndex::iterator;
367+
using TFieldOptionsMIndexCItr = TFieldOptionsMIndex::const_iterator;
368368

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

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

375375
//! Used to obtain command line clause tokens
376-
typedef std::vector<std::string> TStrVec;
377-
typedef TStrVec::iterator TStrVecItr;
376+
using TStrVec = std::vector<std::string>;
377+
using TStrVecItr = TStrVec::iterator;
378378

379-
typedef std::vector<model::CDetectionRule> TDetectionRuleVec;
380-
typedef boost::unordered_map<int, TDetectionRuleVec> TIntDetectionRuleVecUMap;
379+
using TDetectionRuleVec = std::vector<model::CDetectionRule>;
380+
using TIntDetectionRuleVecUMap = boost::unordered_map<int, TDetectionRuleVec>;
381381

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

384-
typedef std::pair<std::string, model::CDetectionRule> TStrDetectionRulePr;
385-
typedef std::vector<TStrDetectionRulePr> TStrDetectionRulePrVec;
384+
using TStrDetectionRulePr = std::pair<std::string, model::CDetectionRule>;
385+
using TStrDetectionRulePrVec = std::vector<TStrDetectionRulePr>;
386386

387387
public:
388388
//! 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
@@ -68,17 +68,17 @@ class API_EXPORT CFieldDataTyper : public CDataProcessor
6868
public:
6969
// A type of token list data typer that DOESN'T exclude fields from its
7070
// analysis
71-
typedef CTokenListDataTyper<true, // Warping
72-
true, // Underscores
73-
true, // Dots
74-
true, // Dashes
75-
true, // Ignore leading digit
76-
true, // Ignore hex
77-
true, // Ignore date words
78-
false, // Ignore field names
79-
2, // Min dictionary word length
80-
core::CWordDictionary::TWeightVerbs5Other2>
81-
TTokenListDataTyperKeepsFields;
71+
using TTokenListDataTyperKeepsFields =
72+
CTokenListDataTyper<true, // Warping
73+
true, // Underscores
74+
true, // Dots
75+
true, // Dashes
76+
true, // Ignore leading digit
77+
true, // Ignore hex
78+
true, // Ignore date words
79+
false, // Ignore field names
80+
2, // Min dictionary word length
81+
core::CWordDictionary::TWeightVerbs5Other2>;
8282

8383
public:
8484
//! Construct without persistence capability
@@ -151,7 +151,7 @@ class API_EXPORT CFieldDataTyper : public CDataProcessor
151151
void acknowledgeFlush(const std::string &flushId);
152152

153153
private:
154-
typedef CCategoryExamplesCollector::TStrSet TStrSet;
154+
using TStrSet = CCategoryExamplesCollector::TStrSet;
155155

156156
private:
157157
//! The job ID

include/api/CHierarchicalResultsWriter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ class API_EXPORT CHierarchicalResultsWriter : public model::CHierarchicalResults
139139
};
140140

141141
public:
142-
typedef SResults TResults;
143-
typedef std::function<bool(TResults)> TResultWriterFunc;
144-
typedef std::function<bool(core_t::TTime, TNode, bool)> TPivotWriterFunc;
142+
using TResults = SResults;
143+
using TResultWriterFunc = std::function<bool(TResults)>;
144+
using TPivotWriterFunc = std::function<bool(core_t::TTime, TNode, bool)>;
145145

146146
public:
147147
CHierarchicalResultsWriter(const model::CLimits &limits,

include/api/CInputParser.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@ namespace api
3838
class API_EXPORT CInputParser : private core::CNonCopyable
3939
{
4040
public:
41-
typedef std::vector<std::string> TStrVec;
42-
typedef TStrVec::iterator TStrVecItr;
43-
typedef TStrVec::const_iterator TStrVecCItr;
41+
using TStrVec = std::vector<std::string>;
42+
using TStrVecItr = TStrVec::iterator;
43+
using TStrVecCItr = TStrVec::const_iterator;
4444

45-
typedef boost::unordered_map<std::string, std::string> TStrStrUMap;
46-
typedef TStrStrUMap::iterator TStrStrUMapItr;
47-
typedef TStrStrUMap::const_iterator TStrStrUMapCItr;
45+
using TStrStrUMap = boost::unordered_map<std::string, std::string>;
46+
using TStrStrUMapItr = TStrStrUMap::iterator;
47+
using TStrStrUMapCItr = TStrStrUMap::const_iterator;
4848

4949
//! For fast access to the field values without repeatedly computing the
5050
//! hash, we maintain references to the values in the hash map
51-
typedef boost::reference_wrapper<std::string> TStrRef;
52-
typedef std::vector<TStrRef> TStrRefVec;
53-
typedef TStrRefVec::iterator TStrRefVecItr;
54-
typedef TStrRefVec::const_iterator TStrRefVecCItr;
51+
using TStrRef = boost::reference_wrapper<std::string>;
52+
using TStrRefVec = std::vector<TStrRef>;
53+
using TStrRefVecItr = TStrRefVec::iterator;
54+
using TStrRefVecCItr = TStrRefVec::const_iterator;
5555

5656
//! Callback function prototype that gets called for each record
5757
//! read from the input stream. Return false to exit reader loop.
5858
//! Arguments are:
5959
//! 1) Header row fields
6060
//! 2) Data row fields
61-
typedef std::function<bool(const TStrStrUMap &)> TReaderFunc;
61+
using TReaderFunc = std::function<bool(const TStrStrUMap &)>;
6262

6363
public:
6464
CInputParser(void);

include/api/CJsonOutputWriter.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -102,29 +102,29 @@ namespace api
102102
class API_EXPORT CJsonOutputWriter : public COutputHandler
103103
{
104104
public:
105-
typedef boost::shared_ptr<rapidjson::Document> TDocumentPtr;
106-
typedef boost::weak_ptr<rapidjson::Document> TDocumentWeakPtr;
107-
typedef std::vector<TDocumentWeakPtr> TDocumentWeakPtrVec;
108-
typedef TDocumentWeakPtrVec::iterator TDocumentWeakPtrVecItr;
109-
typedef TDocumentWeakPtrVec::const_iterator TDocumentWeakPtrVecCItr;
110-
111-
typedef std::pair<TDocumentWeakPtr, int> TDocumentWeakPtrIntPr;
112-
typedef std::vector<TDocumentWeakPtrIntPr> TDocumentWeakPtrIntPrVec;
113-
typedef TDocumentWeakPtrIntPrVec::iterator TDocumentWeakPtrIntPrVecItr;
114-
typedef std::map<std::string, TDocumentWeakPtrVec> TStrDocumentPtrVecMap;
115-
116-
typedef std::vector<std::string> TStrVec;
117-
typedef core::CSmallVector<std::string, 1> TStr1Vec;
118-
typedef std::vector<core_t::TTime> TTimeVec;
119-
typedef std::vector<double> TDoubleVec;
120-
typedef std::pair<double, double> TDoubleDoublePr;
121-
typedef std::vector<TDoubleDoublePr> TDoubleDoublePrVec;
122-
typedef std::pair<double, TDoubleDoublePr> TDoubleDoubleDoublePrPr;
123-
typedef std::vector<TDoubleDoubleDoublePrPr> TDoubleDoubleDoublePrPrVec;
124-
typedef std::pair<std::string, double> TStringDoublePr;
125-
typedef std::vector<TStringDoublePr> TStringDoublePrVec;
126-
127-
typedef boost::shared_ptr<rapidjson::Value> TValuePtr;
105+
using TDocumentPtr = boost::shared_ptr<rapidjson::Document>;
106+
using TDocumentWeakPtr = boost::weak_ptr<rapidjson::Document>;
107+
using TDocumentWeakPtrVec = std::vector<TDocumentWeakPtr>;
108+
using TDocumentWeakPtrVecItr = TDocumentWeakPtrVec::iterator;
109+
using TDocumentWeakPtrVecCItr = TDocumentWeakPtrVec::const_iterator;
110+
111+
using TDocumentWeakPtrIntPr = std::pair<TDocumentWeakPtr, int>;
112+
using TDocumentWeakPtrIntPrVec = std::vector<TDocumentWeakPtrIntPr>;
113+
using TDocumentWeakPtrIntPrVecItr = TDocumentWeakPtrIntPrVec::iterator;
114+
using TStrDocumentPtrVecMap = std::map<std::string, TDocumentWeakPtrVec>;
115+
116+
using TStrVec = std::vector<std::string>;
117+
using TStr1Vec = core::CSmallVector<std::string, 1>;
118+
using TTimeVec = std::vector<core_t::TTime>;
119+
using TDoubleVec = std::vector<double>;
120+
using TDoubleDoublePr = std::pair<double, double>;
121+
using TDoubleDoublePrVec = std::vector<TDoubleDoublePr>;
122+
using TDoubleDoubleDoublePrPr = std::pair<double, TDoubleDoublePr>;
123+
using TDoubleDoubleDoublePrPrVec = std::vector<TDoubleDoubleDoublePrPr>;
124+
using TStringDoublePr = std::pair<std::string, double>;
125+
using TStringDoublePrVec = std::vector<TStringDoublePr>;
126+
127+
using TValuePtr = boost::shared_ptr<rapidjson::Value>;
128128

129129
//! Structure to buffer up information about each bucket that we have
130130
//! unwritten results for
@@ -175,13 +175,13 @@ class API_EXPORT CJsonOutputWriter : public COutputHandler
175175
TStr1Vec s_ScheduledEventDescriptions;
176176
};
177177

178-
typedef std::map<core_t::TTime, SBucketData> TTimeBucketDataMap;
179-
typedef TTimeBucketDataMap::iterator TTimeBucketDataMapItr;
180-
typedef TTimeBucketDataMap::const_iterator TTimeBucketDataMapCItr;
178+
using TTimeBucketDataMap = std::map<core_t::TTime, SBucketData>;
179+
using TTimeBucketDataMapItr = TTimeBucketDataMap::iterator;
180+
using TTimeBucketDataMapCItr = TTimeBucketDataMap::const_iterator;
181181

182182
private:
183-
typedef CCategoryExamplesCollector::TStrSet TStrSet;
184-
typedef TStrSet::const_iterator TStrSetCItr;
183+
using TStrSet = CCategoryExamplesCollector::TStrSet;
184+
using TStrSetCItr = TStrSet::const_iterator;
185185

186186
public:
187187
//! Constructor that causes output to be written to the specified wrapped stream

include/api/CLengthEncodedInputParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class API_EXPORT CLengthEncodedInputParser : public CInputParser
129129
//! Reference to the stream we're going to read from
130130
std::istream &m_StrmIn;
131131

132-
typedef boost::scoped_array<char> TScopedCharArray;
132+
using TScopedCharArray = boost::scoped_array<char>;
133133

134134
//! The working buffer is also held as a member to avoid constantly
135135
//! reallocating it. It is a raw character array rather than a string

0 commit comments

Comments
 (0)