Cleanup old typedef, remove redundant std:: namespace operators

This commit is contained in:
Timothy Warren 2019-06-24 16:08:22 -04:00
parent 80245660d6
commit 1dc90d9d59
13 changed files with 49 additions and 51 deletions

View File

@ -12,12 +12,10 @@
#include <vector> #include <vector>
#include <map> #include <map>
using namespace std;
// JSON // JSON
#include <json/json.h> #include <json/json.h>
typedef Json::Value JsonValue; using namespace std;
// Typedef some common templates // Typedef some common templates
typedef map<string, int> StringConstMap; typedef map<string, int> StringConstMap;

View File

@ -17,7 +17,7 @@ void TyroConfig::LoadJson(const char json[])
} }
} }
JsonValue TyroConfig::GetRoot() Json::Value TyroConfig::GetRoot()
{ {
return default_root; return default_root;
} }

View File

@ -6,9 +6,9 @@ class TyroConfig {
public: public:
TyroConfig(); TyroConfig();
~TyroConfig(); ~TyroConfig();
JsonValue GetRoot(); Json::Value GetRoot();
void LoadJson(const char json[]); void LoadJson(const char json[]);
private: private:
JsonValue default_root; Json::Value default_root;
Json::Reader reader; Json::Reader reader;
}; };

View File

@ -10,16 +10,16 @@ LangConfig::LangConfig()
this->language = ""; this->language = "";
// "cache" reverse map of languages to their keys // "cache" reverse map of languages to their keys
JsonValue langList = this->GetRoot(); Json::Value langList = this->GetRoot();
JsonValue::iterator it; Json::Value::iterator it;
// Special case for non-recognized language // Special case for non-recognized language
reverseMap["Plain Text"] = ""; reverseMap["Plain Text"] = "";
for (it = langList.begin(); it != langList.end(); ++it) for (it = langList.begin(); it != langList.end(); ++it)
{ {
JsonValue langObj = *it; Json::Value langObj = *it;
reverseMap[langObj.get("name", JsonValue()).asString()] = it.key().asString(); reverseMap[langObj.get("name", Json::Value()).asString()] = it.key().asString();
} }
} }
@ -40,8 +40,8 @@ LangConfig::~LangConfig()
*/ */
string LangConfig::GetLangByFile(wxFileName &fileName) string LangConfig::GetLangByFile(wxFileName &fileName)
{ {
JsonValue langList = this->GetRoot(); Json::Value langList = this->GetRoot();
JsonValue::iterator it; Json::Value::iterator it;
wxString curr_file = fileName.GetFullName(); wxString curr_file = fileName.GetFullName();
@ -81,30 +81,30 @@ string LangConfig::GetLangByFile(wxFileName &fileName)
* Get the list of keywords for the selected language * Get the list of keywords for the selected language
* *
* @param string lang * @param string lang
* @return JsonValue * @return Json::Value
*/ */
JsonValue LangConfig::GetKeywordList(string lang) Json::Value LangConfig::GetKeywordList(string lang)
{ {
if (lang == "none") lang = this->language; if (lang == "none") lang = this->language;
return this->GetRoot() return this->GetRoot()
.get(lang, JsonValue()) .get(lang, Json::Value())
.get("keywords", JsonValue()); .get("keywords", Json::Value());
} }
/** /**
* Get the lexer theme map for the current language * Get the lexer theme map for the current language
* *
* @param string lang * @param string lang
* @return JsonValue * @return Json::Value
*/ */
JsonValue LangConfig::GetLexerMap(string lang) Json::Value LangConfig::GetLexerMap(string lang)
{ {
if (lang == "none") lang = this->language; if (lang == "none") lang = this->language;
return this->GetRoot() return this->GetRoot()
.get(lang, JsonValue()) .get(lang, Json::Value())
.get("lexer_map", JsonValue()); .get("lexer_map", Json::Value());
} }
/** /**
@ -134,8 +134,8 @@ string LangConfig::GetLang()
string LangConfig::GetCurrentLangName() string LangConfig::GetCurrentLangName()
{ {
return this->GetRoot() return this->GetRoot()
.get(this->language, JsonValue()) .get(this->language, Json::Value())
.get("name", JsonValue()) .get("name", Json::Value())
.asString(); .asString();
} }

View File

@ -10,8 +10,8 @@ public:
void SetLang(const string &lang); void SetLang(const string &lang);
string GetLang(); string GetLang();
string GetLangByFile(wxFileName &fileName); string GetLangByFile(wxFileName &fileName);
JsonValue GetKeywordList(string lang="none"); Json::Value GetKeywordList(string lang="none");
JsonValue GetLexerMap(string lang="none"); Json::Value GetLexerMap(string lang="none");
StringMap GetLangList(); StringMap GetLangList();
string GetCurrentLangName(); string GetCurrentLangName();
string GetLangByName(const string &name); string GetLangByName(const string &name);

View File

@ -30,8 +30,8 @@ ThemeConfig::~ThemeConfig()
*/ */
bool ThemeConfig::SetTheme(const string &theme_name) bool ThemeConfig::SetTheme(const string &theme_name)
{ {
JsonValue theme_list = this->GetRoot(); Json::Value theme_list = this->GetRoot();
JsonValue selected_theme = theme_list.get(theme_name, JsonValue()); Json::Value selected_theme = theme_list.get(theme_name, Json::Value());
if (selected_theme.isNull()) return FALSE; if (selected_theme.isNull()) return FALSE;
@ -49,7 +49,7 @@ bool ThemeConfig::SetTheme(const string &theme_name)
* *
* @return string * @return string
*/ */
JsonValue ThemeConfig::GetTheme() Json::Value ThemeConfig::GetTheme()
{ {
return this->current_theme; return this->current_theme;
} }
@ -59,13 +59,13 @@ JsonValue ThemeConfig::GetTheme()
* *
* @param string type * @param string type
* @param string key * @param string key
* @return JsonValue * @return Json::Value
*/ */
JsonValue ThemeConfig::GetThemeValue(const string &type, const string &key) Json::Value ThemeConfig::GetThemeValue(const string &type, const string &key)
{ {
JsonValue value = this->current_theme Json::Value value = this->current_theme
.get(type, JsonValue()) .get(type, Json::Value())
.get(key, JsonValue()); .get(key, Json::Value());
return value; return value;
} }
@ -78,7 +78,7 @@ JsonValue ThemeConfig::GetThemeValue(const string &type, const string &key)
*/ */
wxColor ThemeConfig::GetThemeColor(const string &type, const string &key) wxColor ThemeConfig::GetThemeColor(const string &type, const string &key)
{ {
JsonValue color_value = this->GetThemeValue(type, key); Json::Value color_value = this->GetThemeValue(type, key);
if (color_value.isArray()) if (color_value.isArray())
{ {

View File

@ -11,10 +11,10 @@ public:
ThemeConfig(); ThemeConfig();
~ThemeConfig(); ~ThemeConfig();
bool SetTheme(const string &theme_name); bool SetTheme(const string &theme_name);
JsonValue GetTheme(); Json::Value GetTheme();
JsonValue GetThemeValue(const string &type, const string &key); Json::Value GetThemeValue(const string &type, const string &key);
wxColor GetThemeColor(const string &type, const string &key); wxColor GetThemeColor(const string &type, const string &key);
private: private:
JsonValue current_theme; Json::Value current_theme;
}; };

View File

@ -100,8 +100,8 @@ void EditorPane::ApplyTheme(const string &lang, const string &theme)
} }
// Get the keywords and mapping for the selected language // Get the keywords and mapping for the selected language
JsonValue lexer_map = Glob_lang_config->GetLexerMap(lang); Json::Value lexer_map = Glob_lang_config->GetLexerMap(lang);
JsonValue keywords_array = Glob_lang_config->GetKeywordList(lang); Json::Value keywords_array = Glob_lang_config->GetKeywordList(lang);
if (keywords_array.isArray()) if (keywords_array.isArray())
{ {
@ -318,10 +318,10 @@ void EditorPane::BindEvents()
/** /**
* Iterate through the theme settings and apply them * Iterate through the theme settings and apply them
* *
* @param JsonValue lexer_map - Maps token types to theme colors * @param Json::Value lexer_map - Maps token types to theme colors
* @return void * @return void
*/ */
void EditorPane::_ApplyTheme(JsonValue &lexer_map) void EditorPane::_ApplyTheme(Json::Value &lexer_map)
{ {
// Make sure to have a default font, especially for Linux // Make sure to have a default font, especially for Linux
wxFont globalFont = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT); wxFont globalFont = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);

View File

@ -28,5 +28,5 @@ protected:
bool FileReadable(); bool FileReadable();
bool FileWritable(); bool FileWritable();
void BindEvents(); void BindEvents();
void _ApplyTheme(JsonValue &lexer_map); void _ApplyTheme(Json::Value &lexer_map);
}; };

View File

@ -89,7 +89,7 @@ void FileTreePane::CreateTree(const wxString &path)
// Make the dir relative to the base path, // Make the dir relative to the base path,
// then only use the first dir segment // then only use the first dir segment
fileName.MakeRelativeTo(this->base_path); fileName.MakeRelativeTo(this->base_path);
auto dir = std::string(fileName.GetPath()); auto dir = string(fileName.GetPath());
if (dir.empty()) if (dir.empty())
{ {
@ -136,7 +136,7 @@ void FileTreePane::AddDirToTree(wxTreeListItem &root, const wxString &path, cons
wxString wFullPath(fullPath); wxString wFullPath(fullPath);
// Stop early if folder exists // Stop early if folder exists
auto it = this->dir_set.find(std::string(fullPath)); auto it = this->dir_set.find(string(fullPath));
if (it != this->dir_set.end()) if (it != this->dir_set.end())
{ {
wxLogInfo("Redundant call to AddDirToTree for: %s, %s", path, parent); wxLogInfo("Redundant call to AddDirToTree for: %s, %s", path, parent);
@ -172,7 +172,7 @@ void FileTreePane::AddDirToTree(wxTreeListItem &root, const wxString &path, cons
// Make the dir relative to the search path, // Make the dir relative to the search path,
// then only use the first dir segment // then only use the first dir segment
fileName.MakeRelativeTo(fullPath); fileName.MakeRelativeTo(fullPath);
auto dir = std::string(fileName.GetPath()); auto dir = string(fileName.GetPath());
if (dir.empty()) if (dir.empty())
{ {
@ -223,7 +223,7 @@ void FileTreePane::AddDirFiles(wxTreeListItem &root, const wxString &path, wxArr
wxFileName fileName(item); wxFileName fileName(item);
fileName.MakeAbsolute(); fileName.MakeAbsolute();
auto it = this->file_set.find(std::string(fileName.GetFullPath())); auto it = this->file_set.find(string(fileName.GetFullPath()));
if (it != this->file_set.end()) if (it != this->file_set.end())
{ {
continue; continue;
@ -235,7 +235,7 @@ void FileTreePane::AddDirFiles(wxTreeListItem &root, const wxString &path, wxArr
auto fileLabel = BaseName(fileName.GetFullName()); auto fileLabel = BaseName(fileName.GetFullName());
this->AppendItem(root, fileLabel, Icon_File, Icon_File, fileData); this->AppendItem(root, fileLabel, Icon_File, Icon_File, fileData);
this->file_set.insert(std::string(fileName.GetFullPath())); this->file_set.insert(string(fileName.GetFullPath()));
} }
} }

View File

@ -18,8 +18,8 @@ public:
private: private:
wxString base_path = ""; wxString base_path = "";
wxImageList *img_list = nullptr; wxImageList *img_list = nullptr;
unordered_set<std::string> file_set; unordered_set<string> file_set;
unordered_set<std::string> dir_set; unordered_set<string> dir_set;
void BindEvents(); void BindEvents();
void OpenFolder(wxTreeListEvent& event); void OpenFolder(wxTreeListEvent& event);
void OpenFileInEditor(wxTreeListEvent& event); void OpenFileInEditor(wxTreeListEvent& event);

View File

@ -47,7 +47,7 @@ TEST_CASE("Language Config Library")
SECTION("GetLexerMap()") SECTION("GetLexerMap()")
{ {
JsonValue lexer_map = config->GetLexerMap("none"); Json::Value lexer_map = config->GetLexerMap("none");
REQUIRE(lexer_map.isNull()); REQUIRE(lexer_map.isNull());
lexer_map = config->GetLexerMap("cpp"); lexer_map = config->GetLexerMap("cpp");
@ -56,7 +56,7 @@ TEST_CASE("Language Config Library")
SECTION("GetKeywordList()") SECTION("GetKeywordList()")
{ {
JsonValue keyword_list = config->GetKeywordList("none"); Json::Value keyword_list = config->GetKeywordList("none");
REQUIRE(keyword_list.isNull()); REQUIRE(keyword_list.isNull());
keyword_list = config->GetKeywordList("cpp"); keyword_list = config->GetKeywordList("cpp");

View File

@ -7,7 +7,7 @@ TEST_CASE("Theme Config Library")
SECTION("GetTheme()") SECTION("GetTheme()")
{ {
JsonValue theme = config->GetTheme(); Json::Value theme = config->GetTheme();
REQUIRE(theme.isObject()); REQUIRE(theme.isObject());
} }