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 <map>
using namespace std;
// JSON
#include <json/json.h>
typedef Json::Value JsonValue;
using namespace std;
// Typedef some common templates
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;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -11,10 +11,10 @@ public:
ThemeConfig();
~ThemeConfig();
bool SetTheme(const string &theme_name);
JsonValue GetTheme();
JsonValue GetThemeValue(const string &type, const string &key);
Json::Value GetTheme();
Json::Value GetThemeValue(const string &type, const string &key);
wxColor GetThemeColor(const string &type, const string &key);
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
JsonValue lexer_map = Glob_lang_config->GetLexerMap(lang);
JsonValue keywords_array = Glob_lang_config->GetKeywordList(lang);
Json::Value lexer_map = Glob_lang_config->GetLexerMap(lang);
Json::Value keywords_array = Glob_lang_config->GetKeywordList(lang);
if (keywords_array.isArray())
{
@ -318,10 +318,10 @@ void EditorPane::BindEvents()
/**
* 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
*/
void EditorPane::_ApplyTheme(JsonValue &lexer_map)
void EditorPane::_ApplyTheme(Json::Value &lexer_map)
{
// Make sure to have a default font, especially for Linux
wxFont globalFont = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT);

View File

@ -28,5 +28,5 @@ protected:
bool FileReadable();
bool FileWritable();
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,
// then only use the first dir segment
fileName.MakeRelativeTo(this->base_path);
auto dir = std::string(fileName.GetPath());
auto dir = string(fileName.GetPath());
if (dir.empty())
{
@ -136,7 +136,7 @@ void FileTreePane::AddDirToTree(wxTreeListItem &root, const wxString &path, cons
wxString wFullPath(fullPath);
// 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())
{
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,
// then only use the first dir segment
fileName.MakeRelativeTo(fullPath);
auto dir = std::string(fileName.GetPath());
auto dir = string(fileName.GetPath());
if (dir.empty())
{
@ -223,7 +223,7 @@ void FileTreePane::AddDirFiles(wxTreeListItem &root, const wxString &path, wxArr
wxFileName fileName(item);
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())
{
continue;
@ -235,7 +235,7 @@ void FileTreePane::AddDirFiles(wxTreeListItem &root, const wxString &path, wxArr
auto fileLabel = BaseName(fileName.GetFullName());
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:
wxString base_path = "";
wxImageList *img_list = nullptr;
unordered_set<std::string> file_set;
unordered_set<std::string> dir_set;
unordered_set<string> file_set;
unordered_set<string> dir_set;
void BindEvents();
void OpenFolder(wxTreeListEvent& event);
void OpenFileInEditor(wxTreeListEvent& event);

View File

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

View File

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