diff options
author | Yi Jin <jinyithu@google.com> | 2018-03-30 14:04:52 -0700 |
---|---|---|
committer | Yi Jin <jinyithu@google.com> | 2018-03-30 17:36:49 -0700 |
commit | 6cacbcbf436be744a34f7ea0d4f838ff97757446 (patch) | |
tree | 776d8808c385eff13b39097a1b64585df88959e3 /cmds/incident_helper | |
parent | 6a8ea4fe24dc0116de74a19b3d2a5fe89d0d1736 (diff) |
Use modern c++ code style for incidentd.
This cl does not contain code logic changes.
Bug: 77333635
Test: manual and incidentd_test
Change-Id: Iea0a402b1051defd45159ca267e6dd705f9ffa49
Diffstat (limited to 'cmds/incident_helper')
-rw-r--r-- | cmds/incident_helper/src/TextParserBase.cpp | 1 | ||||
-rw-r--r-- | cmds/incident_helper/src/TextParserBase.h | 1 | ||||
-rw-r--r-- | cmds/incident_helper/src/ih_util.cpp | 18 | ||||
-rw-r--r-- | cmds/incident_helper/src/ih_util.h | 12 |
4 files changed, 16 insertions, 16 deletions
diff --git a/cmds/incident_helper/src/TextParserBase.cpp b/cmds/incident_helper/src/TextParserBase.cpp index a8f9968ee8f6..e9bc70f37026 100644 --- a/cmds/incident_helper/src/TextParserBase.cpp +++ b/cmds/incident_helper/src/TextParserBase.cpp @@ -21,7 +21,6 @@ #include <android-base/file.h> using namespace android::base; -using namespace std; // ================================================================================ status_t NoopParser::Parse(const int in, const int out) const diff --git a/cmds/incident_helper/src/TextParserBase.h b/cmds/incident_helper/src/TextParserBase.h index 166796673e25..784c181d9741 100644 --- a/cmds/incident_helper/src/TextParserBase.h +++ b/cmds/incident_helper/src/TextParserBase.h @@ -21,6 +21,7 @@ #include <utils/String8.h> using namespace android; +using namespace std; /** * Base class for text parser diff --git a/cmds/incident_helper/src/ih_util.cpp b/cmds/incident_helper/src/ih_util.cpp index 5b413e99cc3b..4c4d1b992ba8 100644 --- a/cmds/incident_helper/src/ih_util.cpp +++ b/cmds/incident_helper/src/ih_util.cpp @@ -98,9 +98,9 @@ bool getColumnIndices(std::vector<int>& indices, const char** headerNames, const size_t lastIndex = 0; int i = 0; while (headerNames[i] != NULL) { - string s = headerNames[i]; + std::string s = headerNames[i]; lastIndex = line.find(s, lastIndex); - if (lastIndex == string::npos) { + if (lastIndex == std::string::npos) { fprintf(stderr, "Bad Task Header: %s\n", line.c_str()); return false; } @@ -271,7 +271,7 @@ Table::Table(const char* names[], const uint64_t ids[], const int count) :mEnums(), mEnumValuesByName() { - map<std::string, uint64_t> fields; + std::map<std::string, uint64_t> fields; for (int i = 0; i < count; i++) { fields[names[i]] = ids[i]; } @@ -286,11 +286,11 @@ void Table::addEnumTypeMap(const char* field, const char* enumNames[], const int enumValues[], const int enumSize) { if (mFields.find(field) == mFields.end()) { - fprintf(stderr, "Field '%s' not found", string(field).c_str()); + fprintf(stderr, "Field '%s' not found", field); return; } - map<std::string, int> enu; + std::map<std::string, int> enu; for (int i = 0; i < enumSize; i++) { enu[enumNames[i]] = enumValues[i]; } @@ -420,10 +420,10 @@ Message::insertField(ProtoOutputStream* proto, const std::string& name, const st // Try to find the message field which is the prefix of name, so the value would be inserted // recursively into the submessage. - string mutableName = name; + std::string mutableName = name; for (auto iter = mSubMessages.begin(); iter != mSubMessages.end(); iter++) { - string fieldName = iter->first; - string prefix = fieldName + "_"; // underscore is the delimiter in the name + std::string fieldName = iter->first; + std::string prefix = fieldName + "_"; // underscore is the delimiter in the name if (stripPrefix(&mutableName, prefix.c_str())) { if (mPreviousField != fieldName) { endSession(proto); @@ -437,7 +437,7 @@ Message::insertField(ProtoOutputStream* proto, const std::string& name, const st } void -Message::startSession(ProtoOutputStream* proto, const string& name) +Message::startSession(ProtoOutputStream* proto, const std::string& name) { uint64_t fieldId = mTable->mFields[name]; uint64_t token = proto->start(fieldId); diff --git a/cmds/incident_helper/src/ih_util.h b/cmds/incident_helper/src/ih_util.h index c4eda4af4333..c02a3493724a 100644 --- a/cmds/incident_helper/src/ih_util.h +++ b/cmds/incident_helper/src/ih_util.h @@ -150,9 +150,9 @@ public: // Return false if the given name can't be found. bool insertField(ProtoOutputStream* proto, const std::string& name, const std::string& value); private: - map<std::string, uint64_t> mFields; - map<std::string, map<std::string, int>> mEnums; - map<std::string, int> mEnumValuesByName; + std::map<std::string, uint64_t> mFields; + std::map<std::string, std::map<std::string, int>> mEnums; + std::map<std::string, int> mEnumValuesByName; }; /** @@ -187,15 +187,15 @@ public: bool insertField(ProtoOutputStream* proto, const std::string& name, const std::string& value); // Starts a new message field proto session. - void startSession(ProtoOutputStream* proto, const string& name); + void startSession(ProtoOutputStream* proto, const std::string& name); // Ends the previous message field proto session. void endSession(ProtoOutputStream* proto); private: Table* mTable; std::string mPreviousField; - stack<uint64_t> mTokens; - map<std::string, Message*> mSubMessages; + std::stack<uint64_t> mTokens; + std::map<std::string, Message*> mSubMessages; }; #endif // INCIDENT_HELPER_UTIL_H |