Skip to content

Commit 2961ac5

Browse files
committed
Minor cleanup
1 parent 747668f commit 2961ac5

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

NppJSONViewer/NppJsonViewer/NppJsonPlugin.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ void NppJsonPlugin::ProcessNotification(const SCNotification* notifyCode)
5353
break;
5454
}
5555

56-
case NPPN_BUFFERACTIVATED:
57-
{
58-
PluginCleanup();
59-
break;
60-
}
61-
6256
default:
6357
return;
6458
}

NppJSONViewer/NppJsonViewer/RapidJsonHandler.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ bool RapidJsonHandler::Null()
1111
if (!m_NodeStack.size())
1212
return false;
1313

14-
TreeNode2* parent = m_NodeStack.top();
14+
TreeNode* parent = m_NodeStack.top();
1515
parent->node.type = JsonNodeType::BOOL;
1616
parent->node.key = m_strLastKey;
1717
parent->node.value = STR_NULL;
@@ -27,7 +27,7 @@ bool RapidJsonHandler::Bool(bool b)
2727
if (!m_NodeStack.size())
2828
return false;
2929

30-
TreeNode2* parent = m_NodeStack.top();
30+
TreeNode* parent = m_NodeStack.top();
3131
parent->node.type = JsonNodeType::BOOL;
3232
parent->node.key = m_strLastKey;
3333
parent->node.value = b ? STR_TRUE : STR_FALSE;
@@ -68,7 +68,7 @@ bool RapidJsonHandler::RawNumber(const Ch* str, unsigned /*length*/, bool /*copy
6868
if (!m_NodeStack.size())
6969
return false;
7070

71-
TreeNode2* parent = m_NodeStack.top();
71+
TreeNode* parent = m_NodeStack.top();
7272
parent->node.type = JsonNodeType::NUMBER;
7373
parent->node.key = m_strLastKey;
7474
parent->node.value = str;
@@ -91,7 +91,7 @@ bool RapidJsonHandler::String(const Ch* str, unsigned /*length*/, bool /*copy*/)
9191
return true;
9292
}
9393

94-
TreeNode2* parent = m_NodeStack.top();
94+
TreeNode* parent = m_NodeStack.top();
9595

9696
if (parent->node.type != JsonNodeType::ARRAY)
9797
{
@@ -101,11 +101,6 @@ bool RapidJsonHandler::String(const Ch* str, unsigned /*length*/, bool /*copy*/)
101101
}
102102
else
103103
{
104-
/*std::string strCount = std::to_string(parent->counter);
105-
len = strCount.size() + 3 + length + 1;
106-
value = new char[len];
107-
snprintf(value, len, "%s : %s", strCount.c_str(), str);
108-
value[len - 1] = '\0';*/
109104
parent->counter++;
110105
}
111106

@@ -125,10 +120,10 @@ bool RapidJsonHandler::Key(const Ch* str, unsigned /*length*/, bool /*copy*/)
125120

126121
bool RapidJsonHandler::StartObject()
127122
{
128-
TreeNode2* parent = nullptr;
123+
TreeNode* parent = nullptr;
129124
if (m_NodeStack.empty())
130125
{
131-
parent = new TreeNode2;
126+
parent = new TreeNode;
132127
parent->node.type = JsonNodeType::OBJECT;
133128
parent->subRoot = m_treeRoot;
134129
parent->counter = 0;
@@ -155,7 +150,7 @@ bool RapidJsonHandler::StartObject()
155150
}
156151

157152
parent->counter++;
158-
TreeNode2* newTreeNode = new TreeNode2;
153+
TreeNode* newTreeNode = new TreeNode;
159154
newTreeNode->node.type = JsonNodeType::OBJECT;
160155
newTreeNode->subRoot = newNode;
161156
newTreeNode->counter = 0;
@@ -169,7 +164,7 @@ bool RapidJsonHandler::EndObject(unsigned /*memberCount*/)
169164
{
170165
if (!m_NodeStack.empty())
171166
{
172-
TreeNode2* node = m_NodeStack.top();
167+
TreeNode* node = m_NodeStack.top();
173168
m_NodeStack.pop();
174169
delete node;
175170
}
@@ -178,10 +173,10 @@ bool RapidJsonHandler::EndObject(unsigned /*memberCount*/)
178173

179174
bool RapidJsonHandler::StartArray()
180175
{
181-
TreeNode2* parent = nullptr;
176+
TreeNode* parent = nullptr;
182177
if (m_NodeStack.empty())
183178
{
184-
parent = new TreeNode2;
179+
parent = new TreeNode;
185180
parent->node.type = JsonNodeType::ARRAY;
186181
parent->subRoot = m_treeRoot;
187182
parent->counter = 0;
@@ -209,7 +204,7 @@ bool RapidJsonHandler::StartArray()
209204
}
210205

211206
parent->counter++;
212-
TreeNode2* newTreeNode = new TreeNode2;
207+
TreeNode* newTreeNode = new TreeNode;
213208
newTreeNode->node.type = JsonNodeType::ARRAY;
214209
newTreeNode->subRoot = newNode;
215210
newTreeNode->counter = 0;
@@ -222,7 +217,7 @@ bool RapidJsonHandler::EndArray(unsigned /*elementCount*/)
222217
{
223218
if (!m_NodeStack.empty())
224219
{
225-
TreeNode2* node = m_NodeStack.top();
220+
TreeNode* node = m_NodeStack.top();
226221
m_NodeStack.pop();
227222
delete node;
228223
}

NppJSONViewer/NppJsonViewer/RapidJsonHandler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class JsonViewDlg;
1010

11-
struct TreeNode2
11+
struct TreeNode
1212
{
1313
HTREEITEM subRoot;
1414
JsonNode node;
@@ -18,7 +18,7 @@ struct TreeNode2
1818
class RapidJsonHandler :public rapidjson::BaseReaderHandler<rapidjson::UTF8<>, RapidJsonHandler>
1919
{
2020
std::string m_strLastKey;
21-
std::stack<TreeNode2*> m_NodeStack;
21+
std::stack<TreeNode*> m_NodeStack;
2222

2323
JsonViewDlg* m_dlg = nullptr;
2424
HTREEITEM m_treeRoot = nullptr;

0 commit comments

Comments
 (0)