1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #ifndef SYSTEM_EXTRAS_PERFPROFD_CONFIGREADER_H_
- #define SYSTEM_EXTRAS_PERFPROFD_CONFIGREADER_H_
- #include <memory>
- #include <string>
- #include "config.h"
- namespace android {
- namespace perfprofd {
- class ProfilingConfig;
- }
- }
- class ConfigReader {
- public:
- ConfigReader();
- ~ConfigReader();
-
- unsigned getUnsignedValue(const char *key) const;
- bool getBoolValue(const char *key) const;
- std::string getStringValue(const char *key) const;
-
-
- bool readFile();
- bool Read(const std::string& data, bool fail_on_error, std::string* error_msg);
-
- static void setConfigFilePath(const char *path);
- static const char *getConfigFilePath();
-
- void overrideUnsignedEntry(const char *key, unsigned new_value);
- void FillConfig(Config* config);
- static std::string ConfigToString(const Config& config);
- static void ProtoToConfig(const android::perfprofd::ProfilingConfig& in, Config* out);
- private:
- void addUnsignedEntry(const char *key,
- unsigned default_value,
- unsigned min_value,
- unsigned max_value);
- void addStringEntry(const char *key, const char *default_value);
- void addDefaultEntries();
- bool parseLine(const std::string& key,
- const std::string& value,
- unsigned linecount,
- std::string* error_msg);
- struct Data;
- std::unique_ptr<Data> data_;
- };
- #endif
|