diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-07 12:03:40 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-07 12:03:40 +0000 |
commit | 67d3752f3e59e7f5af163f3521f2c2011392d1f9 (patch) | |
tree | c164096e73a9a639c42067408ece61f73658bcde | |
parent | 7ebf1a9591590e96b8660826175d2d86be12a56a (diff) |
- JSONROOT added to handle json parser more conveniently;
- TCHAR* is returned everywhere instead of char*;
git-svn-id: http://svn.miranda-ng.org/main/trunk@6393 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/m_json.h | 108 | ||||
-rw-r--r-- | src/mir_core/json/JSONNode.cpp | 2 | ||||
-rw-r--r-- | src/mir_core/json/JSONNode.h | 4 | ||||
-rw-r--r-- | src/mir_core/json/internalJSONNode.cpp | 2 | ||||
-rw-r--r-- | src/mir_core/json/internalJSONNode.h | 2 | ||||
-rw-r--r-- | src/mir_core/json/libJSON.cpp | 114 | ||||
-rw-r--r-- | src/mir_core/miranda.h | 2 | ||||
-rw-r--r-- | src/mir_core/modules.cpp | 12 | ||||
-rw-r--r-- | src/mir_core/utf.cpp | 8 | ||||
-rw-r--r-- | src/mir_core/utils.cpp | 2 |
10 files changed, 132 insertions, 124 deletions
diff --git a/include/m_json.h b/include/m_json.h index 299111d3cd..9556becc00 100644 --- a/include/m_json.h +++ b/include/m_json.h @@ -38,88 +38,100 @@ extern "C" typedef void JSONNODE;
#endif
-MIR_CORE_DLL(void) json_free(void * str);
-MIR_CORE_DLL(void) json_delete(JSONNODE * node);
+MIR_CORE_DLL(void) json_free(void *str);
+MIR_CORE_DLL(void) json_delete(JSONNODE *node);
-MIR_CORE_DLL(JSONNODE*) json_parse(const char * json);
-MIR_CORE_DLL(char*) json_strip_white_space(const char * json);
+MIR_CORE_DLL(JSONNODE*) json_parse(const char *json);
+MIR_CORE_DLL(TCHAR*) json_strip_white_space(const char *json);
#ifdef JSON_VALIDATE
- MIR_CORE_DLL(JSONNODE*) json_validate(const char * json);
+ MIR_CORE_DLL(JSONNODE*) json_validate(const char *json);
#endif
/*
stuff that's in class JSONNode
*/
//ctors
-MIR_CORE_DLL(JSONNODE*) json_new_a(const char * name, const char * value);
-MIR_CORE_DLL(JSONNODE*) json_new_i(const char * name, long value);
-MIR_CORE_DLL(JSONNODE*) json_new_f(const char * name, double value);
-MIR_CORE_DLL(JSONNODE*) json_new_b(const char * name, int value); //because C bools are ints and C++ will implicitly cast it
+MIR_CORE_DLL(JSONNODE*) json_new_a(const char *name, const char *value);
+MIR_CORE_DLL(JSONNODE*) json_new_i(const char *name, long value);
+MIR_CORE_DLL(JSONNODE*) json_new_f(const char *name, double value);
+MIR_CORE_DLL(JSONNODE*) json_new_b(const char *name, int value); //because C bools are ints and C++ will implicitly cast it
MIR_CORE_DLL(JSONNODE*) json_new(char type);
-MIR_CORE_DLL(JSONNODE*) json_copy(const JSONNODE * orig);
-MIR_CORE_DLL(JSONNODE*) json_duplicate(const JSONNODE * orig);
+MIR_CORE_DLL(JSONNODE*) json_copy(const JSONNODE *orig);
+MIR_CORE_DLL(JSONNODE*) json_duplicate(const JSONNODE *orig);
//assignment
-MIR_CORE_DLL(void) json_set_a(JSONNODE * node, const char * value);
-MIR_CORE_DLL(void) json_set_i(JSONNODE * node, long value);
-MIR_CORE_DLL(void) json_set_f(JSONNODE * node, double value);
-MIR_CORE_DLL(void) json_set_b(JSONNODE * node, int value); //because C bools are ints ane C++ will implicit
-MIR_CORE_DLL(void) json_set_n(JSONNODE * node, const JSONNODE * orig);
+MIR_CORE_DLL(void) json_set_a(JSONNODE *node, const char *value);
+MIR_CORE_DLL(void) json_set_i(JSONNODE *node, long value);
+MIR_CORE_DLL(void) json_set_f(JSONNODE *node, double value);
+MIR_CORE_DLL(void) json_set_b(JSONNODE *node, int value); //because C bools are ints ane C++ will implicit
+MIR_CORE_DLL(void) json_set_n(JSONNODE *node, const JSONNODE *orig);
//inspectors
-MIR_CORE_DLL(char) json_type(const JSONNODE * node);
-MIR_CORE_DLL(size_t) json_size(const JSONNODE * node);
-MIR_CORE_DLL(int) json_empty(const JSONNODE * node);
-MIR_CORE_DLL(const char*) json_name(const JSONNODE * node);
+MIR_CORE_DLL(char) json_type(const JSONNODE *node);
+MIR_CORE_DLL(size_t) json_size(const JSONNODE *node);
+MIR_CORE_DLL(int) json_empty(const JSONNODE *node);
+MIR_CORE_DLL(const char*) json_name(const JSONNODE *node);
#ifdef JSON_COMMENTS
- MIR_CORE_DLL(char * json_get_comment(const JSONNODE * node);
+ MIR_CORE_DLL(char * json_get_comment(const JSONNODE *node);
#endif
-MIR_CORE_DLL(char*) json_as_string(const JSONNODE * node);
-MIR_CORE_DLL(long) json_as_int(const JSONNODE * node);
-MIR_CORE_DLL(double) json_as_float(const JSONNODE * node);
-MIR_CORE_DLL(int) json_as_bool(const JSONNODE * node);
-MIR_CORE_DLL(JSONNODE*) json_as_node(const JSONNODE * node);
-MIR_CORE_DLL(JSONNODE*) json_as_array(const JSONNODE * node);
+MIR_CORE_DLL(TCHAR*) json_as_string(const JSONNODE *node);
+MIR_CORE_DLL(long) json_as_int(const JSONNODE *node);
+MIR_CORE_DLL(double) json_as_float(const JSONNODE *node);
+MIR_CORE_DLL(int) json_as_bool(const JSONNODE *node);
+MIR_CORE_DLL(JSONNODE*) json_as_node(const JSONNODE *node);
+MIR_CORE_DLL(JSONNODE*) json_as_array(const JSONNODE *node);
-MIR_CORE_DLL(char*) json_write(const JSONNODE * node);
-MIR_CORE_DLL(char*) json_write_formatted(const JSONNODE * node);
+MIR_CORE_DLL(TCHAR*) json_write(const JSONNODE *node);
+MIR_CORE_DLL(TCHAR*) json_write_formatted(const JSONNODE *node);
//modifiers
-MIR_CORE_DLL(void) json_set_name(JSONNODE * node, const char * name);
+MIR_CORE_DLL(void) json_set_name(JSONNODE *node, const char *name);
#ifdef JSON_COMMENTS
- MIR_CORE_DLL(void) json_set_comment(JSONNODE * node, const char * comment);
+ MIR_CORE_DLL(void) json_set_comment(JSONNODE *node, const char * comment);
#endif
-MIR_CORE_DLL(void) json_clear(JSONNODE * node);
-MIR_CORE_DLL(void) json_nullify(JSONNODE * node);
-MIR_CORE_DLL(void) json_swap(JSONNODE * node, JSONNODE * node2);
-MIR_CORE_DLL(void) json_merge(JSONNODE * node, JSONNODE * node2);
+MIR_CORE_DLL(void) json_clear(JSONNODE *node);
+MIR_CORE_DLL(void) json_nullify(JSONNODE *node);
+MIR_CORE_DLL(void) json_swap(JSONNODE *node, JSONNODE *node2);
+MIR_CORE_DLL(void) json_merge(JSONNODE *node, JSONNODE *node2);
#ifndef JSON_PREPARSE
- MIR_CORE_DLL(void) json_preparse(JSONNODE * node);
+ MIR_CORE_DLL(void) json_preparse(JSONNODE *node);
#endif
#ifdef JSON_BINARY
- MIR_CORE_DLL(void) json_set_binary(JSONNODE * node, const void * data, unsigned long length);
+ MIR_CORE_DLL(void) json_set_binary(JSONNODE *node, const void * data, unsigned long length);
#endif
-MIR_CORE_DLL(void) json_cast(JSONNODE * node, char type);
+MIR_CORE_DLL(void) json_cast(JSONNODE *node, char type);
//children access
-MIR_CORE_DLL(void) json_reserve(JSONNODE * node, size_t siz);
-MIR_CORE_DLL(JSONNODE*) json_at(JSONNODE * node, size_t pos);
-MIR_CORE_DLL(JSONNODE*) json_get(JSONNODE * node, const char * name);
+MIR_CORE_DLL(void) json_reserve(JSONNODE *node, size_t siz);
+MIR_CORE_DLL(JSONNODE*) json_at(JSONNODE *node, size_t pos);
+MIR_CORE_DLL(JSONNODE*) json_get(JSONNODE *node, const char *name);
#ifdef JSON_CASE_INSENSITIVE_FUNCTIONS
- MIR_CORE_DLL(JSONNODE*) json_get_nocase(JSONNODE * node, const char * name);
- MIR_CORE_DLL(JSONNODE*) json_pop_back_nocase(JSONNODE * node, const char * name);
+ MIR_CORE_DLL(JSONNODE*) json_get_nocase(JSONNODE *node, const char *name);
+ MIR_CORE_DLL(JSONNODE*) json_pop_back_nocase(JSONNODE *node, const char *name);
#endif
-MIR_CORE_DLL(void) json_push_back(JSONNODE * node, JSONNODE * node2);
-MIR_CORE_DLL(JSONNODE*) json_pop_back_at(JSONNODE * node, size_t pos);
-MIR_CORE_DLL(JSONNODE*) json_pop_back(JSONNODE * node, const char * name);
+MIR_CORE_DLL(void) json_push_back(JSONNODE *node, JSONNODE *node2);
+MIR_CORE_DLL(JSONNODE*) json_pop_back_at(JSONNODE *node, size_t pos);
+MIR_CORE_DLL(JSONNODE*) json_pop_back(JSONNODE *node, const char *name);
//comparison
-MIR_CORE_DLL(int) json_equal(JSONNODE * node, JSONNODE * node2);
+MIR_CORE_DLL(int) json_equal(JSONNODE *node, JSONNODE *node2);
#ifdef __cplusplus
+
+class JSONROOT
+{
+ JSONNODE *m_node;
+
+public:
+ __forceinline JSONROOT(LPCSTR text) { m_node = json_parse(text); }
+ __forceinline ~JSONROOT() { json_delete(m_node); }
+
+ __forceinline operator JSONNODE*() const { return m_node; }
+};
+
#ifdef _XSTRING_
-MIR_C_CORE_DLL(std::string) json_as_pstring(const JSONNODE * node);
+MIR_C_CORE_DLL(std::string) json_as_pstring(const JSONNODE *node);
#endif
}
diff --git a/src/mir_core/json/JSONNode.cpp b/src/mir_core/json/JSONNode.cpp index 9816010089..8a410f2fc8 100644 --- a/src/mir_core/json/JSONNode.cpp +++ b/src/mir_core/json/JSONNode.cpp @@ -254,7 +254,7 @@ const JSONNode & JSONNode::at(const json_string & name_t) const { #ifndef JSON_LIBRARY
struct auto_delete {
public:
- auto_delete(JSONNode * node) : mynode(node){};
+ auto_delete(JSONNode *node) : mynode(node){};
~auto_delete(void){ JSONNode::deleteJSONNode(mynode); };
JSONNode * mynode;
private:
diff --git a/src/mir_core/json/JSONNode.h b/src/mir_core/json/JSONNode.h index 27dbef2aee..dfb6ff01f3 100644 --- a/src/mir_core/json/JSONNode.h +++ b/src/mir_core/json/JSONNode.h @@ -135,7 +135,7 @@ public: JSONNode & operator[](const json_string & name_t);
const JSONNode & operator[](const json_string & name_t) const;
#ifdef JSON_LIBRARY
- void push_back(JSONNode * node);
+ void push_back(JSONNode *node);
#else
void push_back(const JSONNode & node);
#endif
@@ -385,7 +385,7 @@ public: auto_lock(JSONNode & node, int thread) : mynode(&node), mythread(thread){
mynode -> lock(mythread);
}
- auto_lock(JSONNode * node, int thread) : mynode(node), mythread(thread){
+ auto_lock(JSONNode *node, int thread) : mynode(node), mythread(thread){
mynode -> lock(mythread);
}
~auto_lock(void){
diff --git a/src/mir_core/json/internalJSONNode.cpp b/src/mir_core/json/internalJSONNode.cpp index bc9408d60c..4e3bccbf58 100644 --- a/src/mir_core/json/internalJSONNode.cpp +++ b/src/mir_core/json/internalJSONNode.cpp @@ -354,7 +354,7 @@ void internalJSONNode::Nullify(void) const { #endif
#ifdef JSON_LIBRARY
-void internalJSONNode::push_back(JSONNode * node){
+void internalJSONNode::push_back(JSONNode *node){
#else
void internalJSONNode::push_back(const JSONNode & node){
#endif
diff --git a/src/mir_core/json/internalJSONNode.h b/src/mir_core/json/internalJSONNode.h index 9ed7680a45..cf626ceae0 100644 --- a/src/mir_core/json/internalJSONNode.h +++ b/src/mir_core/json/internalJSONNode.h @@ -97,7 +97,7 @@ public: #endif
#ifdef JSON_LIBRARY
- void push_back(JSONNode * node);
+ void push_back(JSONNode *node);
#else
void push_back(const JSONNode & node);
#endif
diff --git a/src/mir_core/json/libJSON.cpp b/src/mir_core/json/libJSON.cpp index ebba2f2fd4..2bf69f0e5d 100644 --- a/src/mir_core/json/libJSON.cpp +++ b/src/mir_core/json/libJSON.cpp @@ -48,20 +48,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static const json_char * EMPTY_CSTRING = JSON_TEXT("");
#endif
-inline json_char * toCString(const json_string & str){
- const size_t len((str.length() + 1) * sizeof(json_char));
- #ifdef JSON_MEMORY_MANAGE
- return (json_char *)StringHandler.insert(memcpy(json_malloc<json_char>(len), str.c_str(), len));
- #else
- return (json_char *)memcpy(json_malloc<json_char>(len), str.c_str(), len);
- #endif
+inline TCHAR* toCString(const json_string & str)
+{
+ return mir_utf8decodeT( str.c_str());
}
/*
stuff that's in namespace libJSON
*/
-MIR_CORE_DLL(void) json_free(void * str){
+MIR_CORE_DLL(void) json_free(void *str){
JSON_ASSERT_SAFE(str, JSON_TEXT("freeing null ptr"), return;);
#ifdef JSON_MEMORY_MANAGE
StringHandler.remove(str);
@@ -69,7 +65,7 @@ MIR_CORE_DLL(void) json_free(void * str){ libjson_free<void>(str);
}
-MIR_CORE_DLL(void) json_delete(JSONNODE * node){
+MIR_CORE_DLL(void) json_delete(JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("deleting null ptr"), return;);
#ifdef JSON_MEMORY_MANAGE
NodeHandler.remove(node);
@@ -87,7 +83,7 @@ MIR_CORE_DLL(void) json_delete(JSONNODE * node){ }
#endif
-MIR_CORE_DLL(JSONNODE*) json_parse(const json_char * json){
+MIR_CORE_DLL(JSONNODE*) json_parse(const json_char *json){
JSON_ASSERT_SAFE(json, JSON_TEXT("null ptr to json_parse"), return 0;);
try {
//use this constructor to simply copy reference instead of copying the temp
@@ -96,13 +92,13 @@ MIR_CORE_DLL(JSONNODE*) json_parse(const json_char * json){ return 0;
}
-MIR_CORE_DLL(json_char*) json_strip_white_space(const json_char * json){
+MIR_CORE_DLL(TCHAR*) json_strip_white_space(const json_char *json){
JSON_ASSERT_SAFE(json, JSON_TEXT("null ptr to json_strip_white_space"), return 0;);
return toCString(JSONWorker::RemoveWhiteSpaceAndComments(json));
}
#ifdef JSON_VALIDATE
- MIR_CORE_DLL(JSONNODE*) json_validate(const json_char * json){
+ MIR_CORE_DLL(JSONNODE*) json_validate(const json_char *json){
JSON_ASSERT_SAFE(json, JSON_TEXT("null ptr to json_validate"), return 0;);
try {
//use this constructor to simply copy reference instead of copying the temp
@@ -136,17 +132,17 @@ MIR_CORE_DLL(json_char*) json_strip_white_space(const json_char * json){ JSONNode::set_global_mutex(mutex);
}
- MIR_CORE_DLL(void) json_set_mutex(JSONNODE * node, void * mutex){
+ MIR_CORE_DLL(void) json_set_mutex(JSONNODE *node, void * mutex){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_mutex"), return;);
((JSONNode*)node) -> set_mutex(mutex);
}
- MIR_CORE_DLL(void) json_lock(JSONNODE * node, int threadid){
+ MIR_CORE_DLL(void) json_lock(JSONNODE *node, int threadid){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_lock"), return;);
((JSONNode*)node) -> lock(threadid);
}
- MIR_CORE_DLL(void) json_unlock(JSONNODE * node, int threadid){
+ MIR_CORE_DLL(void) json_unlock(JSONNODE *node, int threadid){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_unlock"), return;);
((JSONNode*)node) -> unlock(threadid);
}
@@ -156,7 +152,7 @@ MIR_CORE_DLL(json_char*) json_strip_white_space(const json_char * json){ stuff that's in class JSONNode
*/
//ctors
-MIR_CORE_DLL(JSONNODE*) json_new_a(const json_char * name, const json_char * value){
+MIR_CORE_DLL(JSONNODE*) json_new_a(const json_char *name, const json_char *value){
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_new_a"), name = EMPTY_CSTRING;);
JSON_ASSERT_SAFE(value, JSON_TEXT("null value to json_new_a"), value = EMPTY_CSTRING;);
#ifdef JSON_MEMORY_CALLBACKS
@@ -166,7 +162,7 @@ MIR_CORE_DLL(JSONNODE*) json_new_a(const json_char * name, const json_char * val #endif
}
-MIR_CORE_DLL(JSONNODE*) json_new_i(const json_char * name, long value){
+MIR_CORE_DLL(JSONNODE*) json_new_i(const json_char *name, long value){
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_new_i"), name = EMPTY_CSTRING;);
#ifdef JSON_MEMORY_CALLBACKS
return MANAGER_INSERT(new(json_malloc<JSONNode>(1)) JSONNode(name, value));
@@ -175,7 +171,7 @@ MIR_CORE_DLL(JSONNODE*) json_new_i(const json_char * name, long value){ #endif
}
-MIR_CORE_DLL(JSONNODE*) json_new_f(const json_char * name, double value){
+MIR_CORE_DLL(JSONNODE*) json_new_f(const json_char *name, double value){
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_new_f"), name = EMPTY_CSTRING;);
#ifdef JSON_MEMORY_CALLBACKS
return MANAGER_INSERT(new(json_malloc<JSONNode>(1)) JSONNode(name, value));
@@ -184,7 +180,7 @@ MIR_CORE_DLL(JSONNODE*) json_new_f(const json_char * name, double value){ #endif
}
-MIR_CORE_DLL(JSONNODE*) json_new_b(const json_char * name, int value){
+MIR_CORE_DLL(JSONNODE*) json_new_b(const json_char *name, int value){
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_new_b"), name = EMPTY_CSTRING;);
#ifdef JSON_MEMORY_CALLBACKS
return MANAGER_INSERT(new(json_malloc<JSONNode>(1)) JSONNode(name, value != 0 ));
@@ -201,7 +197,7 @@ MIR_CORE_DLL(JSONNODE*) json_new(char type){ #endif
}
-MIR_CORE_DLL(JSONNODE*) json_copy(const JSONNODE * orig){
+MIR_CORE_DLL(JSONNODE*) json_copy(const JSONNODE *orig){
JSON_ASSERT_SAFE(orig, JSON_TEXT("null orig to json_copy"), return 0;);
#ifdef JSON_MEMORY_CALLBACKS
return MANAGER_INSERT(new(json_malloc<JSONNode>(1)) JSONNode(*((JSONNode*)orig)));
@@ -210,104 +206,104 @@ MIR_CORE_DLL(JSONNODE*) json_copy(const JSONNODE * orig){ #endif
}
-MIR_CORE_DLL(JSONNODE*) json_duplicate(const JSONNODE * orig){
+MIR_CORE_DLL(JSONNODE*) json_duplicate(const JSONNODE *orig){
JSON_ASSERT_SAFE(orig, JSON_TEXT("null orig to json_duplicate"), return 0;);
return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(((JSONNode*)orig) -> duplicate()));
}
//assignment
-MIR_CORE_DLL(void) json_set_a(JSONNODE * node, const json_char * value){
+MIR_CORE_DLL(void) json_set_a(JSONNODE *node, const json_char *value){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_a"), return;);
JSON_ASSERT_SAFE(value, JSON_TEXT("null value to json_set_a"), value = EMPTY_CSTRING;);
*((JSONNode*)node) = json_string(value);
}
-MIR_CORE_DLL(void) json_set_i(JSONNODE * node, long value){
+MIR_CORE_DLL(void) json_set_i(JSONNODE *node, long value){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_i"), return;);
*((JSONNode*)node) = value;
}
-MIR_CORE_DLL(void) json_set_f(JSONNODE * node, double value){
+MIR_CORE_DLL(void) json_set_f(JSONNODE *node, double value){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_f"), return;);
*((JSONNode*)node) = value;
}
-MIR_CORE_DLL(void) json_set_b(JSONNODE * node, int value){
+MIR_CORE_DLL(void) json_set_b(JSONNODE *node, int value){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_b"), return;);
*((JSONNode*)node) = value != 0;
}
-MIR_CORE_DLL(void) json_set_n(JSONNODE * node, const JSONNODE * orig){
+MIR_CORE_DLL(void) json_set_n(JSONNODE *node, const JSONNODE *orig){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_n"), return;);
JSON_ASSERT_SAFE(orig, JSON_TEXT("null node to json_set_n"), return;);
*((JSONNode*)node) = *((JSONNode*)orig);
}
//inspectors
-MIR_CORE_DLL(char) json_type(const JSONNODE * node){
+MIR_CORE_DLL(char) json_type(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_type"), return JSON_NULL;);
return ((JSONNode*)node) -> type();
}
-MIR_CORE_DLL(json_index_t) json_size(const JSONNODE * node){
+MIR_CORE_DLL(json_index_t) json_size(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_size"), return 0;);
return ((JSONNode*)node) -> size();
}
-MIR_CORE_DLL(int) json_empty(const JSONNODE * node){
+MIR_CORE_DLL(int) json_empty(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_empty"), return true;);
return (int)(((JSONNode*)node) -> empty());
}
-MIR_CORE_DLL(const json_char*) json_name(const JSONNODE * node){
+MIR_CORE_DLL(const json_char*) json_name(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_name"), return EMPTY_CSTRING;);
return ((JSONNode*)node) -> name();
}
#ifdef JSON_COMMENTS
- MIR_CORE_DLL(json_char*) json_get_comment(const JSONNODE * node){
+ MIR_CORE_DLL(json_char*) json_get_comment(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_get_comment"), return toCString(EMPTY_CSTRING););
return toCString(((JSONNode*)node) -> get_comment());
}
#endif
-MIR_CORE_DLL(json_char*) json_as_string(const JSONNODE * node){
+MIR_CORE_DLL(TCHAR*) json_as_string(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_string"), return toCString(EMPTY_CSTRING););
return toCString(((JSONNode*)node) -> as_string());
}
-MIR_C_CORE_DLL(std::string) json_as_pstring(const JSONNODE * node){
+MIR_C_CORE_DLL(std::string) json_as_pstring(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_string"), return EMPTY_CSTRING;);
return ((JSONNode*)node) -> as_string();
}
-MIR_CORE_DLL(long) json_as_int(const JSONNODE * node){
+MIR_CORE_DLL(long) json_as_int(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_int"), return 0;);
return ((JSONNode*)node) -> as_int();
}
-MIR_CORE_DLL(double) json_as_float(const JSONNODE * node){
+MIR_CORE_DLL(double) json_as_float(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_float"), return 0.0;);
return ((JSONNode*)node) -> as_float();
}
-MIR_CORE_DLL(int) json_as_bool(const JSONNODE * node){
+MIR_CORE_DLL(int) json_as_bool(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_bool"), return false;);
return (int)(((JSONNode*)node) -> as_bool());
}
-MIR_CORE_DLL(JSONNODE*) json_as_node(const JSONNODE * node){
+MIR_CORE_DLL(JSONNODE*) json_as_node(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_node"), return 0;);
return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(((JSONNode*)node) -> as_node()));
}
-MIR_CORE_DLL(JSONNODE*) json_as_array(const JSONNODE * node){
+MIR_CORE_DLL(JSONNODE*) json_as_array(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_array"), return 0;);
return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(((JSONNode*)node) -> as_array()));
}
#ifdef JSON_BINARY
- void * json_as_binary(const JSONNODE * node, unsigned long * size){
+ void * json_as_binary(const JSONNODE *node, unsigned long * size){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_binary"), if (size){*size = 0;} return 0;);
const std::string result = ((JSONNode*)node) -> as_binary();
const size_t len = result.length();
@@ -324,81 +320,81 @@ MIR_CORE_DLL(JSONNODE*) json_as_array(const JSONNODE * node){ #endif
#ifdef JSON_WRITER
- MIR_CORE_DLL(json_char*) json_write(const JSONNODE * node){
+ MIR_CORE_DLL(TCHAR*) json_write(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_write"), return toCString(EMPTY_CSTRING););
return toCString(((JSONNode*)node) -> write());
}
- MIR_CORE_DLL(json_char*) json_write_formatted(const JSONNODE * node){
+ MIR_CORE_DLL(TCHAR*) json_write_formatted(const JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_write_formatted"), return toCString(EMPTY_CSTRING););
return toCString(((JSONNode*)node) -> write_formatted());
}
#endif
//modifiers
-MIR_CORE_DLL(void) json_set_name(JSONNODE * node, const json_char * name){
+MIR_CORE_DLL(void) json_set_name(JSONNODE *node, const json_char *name){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_name"), return;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_set_name"), name = EMPTY_CSTRING;);
((JSONNode*)node) -> set_name(name);
}
#ifdef JSON_COMMENTS
- MIR_CORE_DLL(void) json_set_comment(JSONNODE * node, const json_char * comment){
+ MIR_CORE_DLL(void) json_set_comment(JSONNODE *node, const json_char * comment){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_comment"), return;);
JSON_ASSERT_SAFE(comment, JSON_TEXT("null name to json_set_comment"), comment = EMPTY_CSTRING;);
((JSONNode*)node) -> set_comment(comment);
}
#endif
-MIR_CORE_DLL(void) json_clear(JSONNODE * node){
+MIR_CORE_DLL(void) json_clear(JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_clear"), return;);
((JSONNode*)node) -> clear();
}
-MIR_CORE_DLL(void) json_nullify(JSONNODE * node){
+MIR_CORE_DLL(void) json_nullify(JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_nullify"), return;);
((JSONNode*)node) -> nullify();
}
-MIR_CORE_DLL(void) json_swap(JSONNODE * node, JSONNODE * node2){
+MIR_CORE_DLL(void) json_swap(JSONNODE *node, JSONNODE *node2){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_swap"), return;);
JSON_ASSERT_SAFE(node2, JSON_TEXT("null node to json_swap"), return;);
((JSONNode*)node) -> swap(*(JSONNode*)node2);
}
-MIR_CORE_DLL(void) json_merge(JSONNODE * node, JSONNODE * node2){
+MIR_CORE_DLL(void) json_merge(JSONNODE *node, JSONNODE *node2){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_merge"), return;);
JSON_ASSERT_SAFE(node2, JSON_TEXT("null node to json_merge"), return;);
((JSONNode*)node) -> merge(*(JSONNode*)node2);
}
#ifndef JSON_PREPARSE
- MIR_CORE_DLL(void) json_preparse(JSONNODE * node){
+ MIR_CORE_DLL(void) json_preparse(JSONNODE *node){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_preparse"), return;);
((JSONNode*)node) -> preparse();
}
#endif
#ifdef JSON_BINARY
- MIR_CORE_DLL(void) json_set_binary(JSONNODE * node, const void * data, unsigned long length){
+ MIR_CORE_DLL(void) json_set_binary(JSONNODE *node, const void * data, unsigned long length){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_swap"), return;);
JSON_ASSERT_SAFE(data, JSON_TEXT("null data to json_set_binary"), *((JSONNode*)node) = EMPTY_CSTRING; return;);
((JSONNode*)node) -> set_binary((unsigned char *)data, length);
}
#endif
-MIR_CORE_DLL(void) json_cast(JSONNODE * node, char type){
+MIR_CORE_DLL(void) json_cast(JSONNODE *node, char type){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_cast"), return;);
((JSONNode*)node) -> cast(type);
}
//children access
-MIR_CORE_DLL(void) json_reserve(JSONNODE * node, json_index_t siz){
+MIR_CORE_DLL(void) json_reserve(JSONNODE *node, json_index_t siz){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_reserve"), return;);
((JSONNode*)node) -> reserve(siz);
}
-MIR_CORE_DLL(JSONNODE*) json_at(JSONNODE * node, json_index_t pos){
+MIR_CORE_DLL(JSONNODE*) json_at(JSONNODE *node, json_index_t pos){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_at"), return 0;);
try {
return &((JSONNode*)node) -> at(pos);
@@ -406,7 +402,7 @@ MIR_CORE_DLL(JSONNODE*) json_at(JSONNODE * node, json_index_t pos){ return 0;
}
-MIR_CORE_DLL(JSONNODE*) json_get(JSONNODE * node, const json_char * name){
+MIR_CORE_DLL(JSONNODE*) json_get(JSONNODE *node, const json_char *name){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_get"), return 0;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null node to json_get. Did you mean to use json_at?"), return 0;);
try {
@@ -416,7 +412,7 @@ MIR_CORE_DLL(JSONNODE*) json_get(JSONNODE * node, const json_char * name){ }
#ifdef JSON_CASE_INSENSITIVE_FUNCTIONS
- MIR_CORE_DLL(JSONNODE*) json_get_nocase(JSONNODE * node, const json_char * name){
+ MIR_CORE_DLL(JSONNODE*) json_get_nocase(JSONNODE *node, const json_char *name){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_at_nocase"), return 0;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_at_nocase"), return 0;);
try {
@@ -425,14 +421,14 @@ MIR_CORE_DLL(JSONNODE*) json_get(JSONNODE * node, const json_char * name){ return 0;
}
- MIR_CORE_DLL(JSONNODE*) json_pop_back_nocase(JSONNODE * node, const json_char * name){
+ MIR_CORE_DLL(JSONNODE*) json_pop_back_nocase(JSONNODE *node, const json_char *name){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_pop_back_nocase"), return 0;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_pop_back_nocase"), return 0;);
return MANAGER_INSERT(((JSONNode*)node) -> pop_back_nocase(name));
}
#endif
-MIR_CORE_DLL(void) json_push_back(JSONNODE * node, JSONNODE * node2){
+MIR_CORE_DLL(void) json_push_back(JSONNODE *node, JSONNODE *node2){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_push_back"), return;);
JSON_ASSERT_SAFE(node2, JSON_TEXT("null node2 to json_push_back"), return;);
#ifdef JSON_MEMORY_MANAGE
@@ -441,19 +437,19 @@ MIR_CORE_DLL(void) json_push_back(JSONNODE * node, JSONNODE * node2){ ((JSONNode*)node) -> push_back((JSONNode*)node2);
}
-MIR_CORE_DLL(JSONNODE*) json_pop_back_at(JSONNODE * node, json_index_t pos){
+MIR_CORE_DLL(JSONNODE*) json_pop_back_at(JSONNODE *node, json_index_t pos){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_pop_back_i"), return 0;);
return MANAGER_INSERT(((JSONNode*)node) -> pop_back(pos));
}
-MIR_CORE_DLL(JSONNODE*) json_pop_back(JSONNODE * node, const json_char * name){
+MIR_CORE_DLL(JSONNODE*) json_pop_back(JSONNODE *node, const json_char *name){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_pop_back"), return 0;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_pop_back. Did you mean to use json_pop_back_at?"), return 0;);
return MANAGER_INSERT(((JSONNode*)node) -> pop_back(name));
}
//comparison
-MIR_CORE_DLL(int) json_equal(JSONNODE * node, JSONNODE * node2){
+MIR_CORE_DLL(int) json_equal(JSONNODE *node, JSONNODE *node2){
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_equal"), return false;);
JSON_ASSERT_SAFE(node2, JSON_TEXT("null node2 to json_equal"), return false;);
return (int)(*((JSONNode*)node) == *((JSONNode*)node2));
diff --git a/src/mir_core/miranda.h b/src/mir_core/miranda.h index 1525c1b792..d7d03cccbb 100644 --- a/src/mir_core/miranda.h +++ b/src/mir_core/miranda.h @@ -88,7 +88,7 @@ TCHAR* LangPackTranslateStringT(int hLangpack, const TCHAR* tszEnglish); /**** options.cpp **********************************************************************/
-HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name);
+HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR *name);
/**** subclass.cpp *********************************************************************/
diff --git a/src/mir_core/modules.cpp b/src/mir_core/modules.cpp index bbbdfc2f61..2ea78d5e34 100644 --- a/src/mir_core/modules.cpp +++ b/src/mir_core/modules.cpp @@ -290,7 +290,7 @@ extern "C" MIR_CORE_DLL(int) GetSubscribersCount(THook* pHook) return pHook->subscriberCount;
}
-static HANDLE HookEventInt(int type, const char* name, MIRANDAHOOK hookProc, void* object, LPARAM lParam)
+static HANDLE HookEventInt(int type, const char *name, MIRANDAHOOK hookProc, void* object, LPARAM lParam)
{
mir_cslock lck(csHooks);
@@ -310,27 +310,27 @@ static HANDLE HookEventInt(int type, const char* name, MIRANDAHOOK hookProc, voi return (HANDLE)((p->id << 16) | p->subscriberCount);
}
-MIR_CORE_DLL(HANDLE) HookEvent(const char* name, MIRANDAHOOK hookProc)
+MIR_CORE_DLL(HANDLE) HookEvent(const char *name, MIRANDAHOOK hookProc)
{
return HookEventInt(1, name, hookProc, 0, 0);
}
-MIR_CORE_DLL(HANDLE) HookEventParam(const char* name, MIRANDAHOOKPARAM hookProc, LPARAM lParam)
+MIR_CORE_DLL(HANDLE) HookEventParam(const char *name, MIRANDAHOOKPARAM hookProc, LPARAM lParam)
{
return HookEventInt(2, name, (MIRANDAHOOK)hookProc, 0, lParam);
}
-MIR_CORE_DLL(HANDLE) HookEventObj(const char* name, MIRANDAHOOKOBJ hookProc, void* object)
+MIR_CORE_DLL(HANDLE) HookEventObj(const char *name, MIRANDAHOOKOBJ hookProc, void* object)
{
return HookEventInt(3, name, (MIRANDAHOOK)hookProc, object, 0);
}
-MIR_CORE_DLL(HANDLE) HookEventObjParam(const char* name, MIRANDAHOOKOBJPARAM hookProc, void* object, LPARAM lParam)
+MIR_CORE_DLL(HANDLE) HookEventObjParam(const char *name, MIRANDAHOOKOBJPARAM hookProc, void* object, LPARAM lParam)
{
return HookEventInt(4, name, (MIRANDAHOOK)hookProc, object, lParam);
}
-MIR_CORE_DLL(HANDLE) HookEventMessage(const char* name, HWND hwnd, UINT message)
+MIR_CORE_DLL(HANDLE) HookEventMessage(const char *name, HWND hwnd, UINT message)
{
mir_cslock lck(csHooks);
diff --git a/src/mir_core/utf.cpp b/src/mir_core/utf.cpp index ef80832761..2a07f24626 100644 --- a/src/mir_core/utf.cpp +++ b/src/mir_core/utf.cpp @@ -247,7 +247,7 @@ int Utf8toUcs2(const char *src, int srclen, wchar_t *dst, int dstlen) /////////////////////////////////////////////////////////////////////////////////////////
// Utf8Decode - converts UTF8-encoded string to the UCS2/MBCS format
-MIR_CORE_DLL(char*) Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2)
+MIR_CORE_DLL(char*) Utf8DecodeCP(char *str, int codepage, wchar_t **ucs2)
{
int len;
bool needs_free = false;
@@ -303,12 +303,12 @@ MIR_CORE_DLL(char*) Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2) return str;
}
-MIR_CORE_DLL(char*) Utf8Decode(char* str, wchar_t** ucs2)
+MIR_CORE_DLL(char*) Utf8Decode(char *str, wchar_t **ucs2)
{
return Utf8DecodeCP(str, Langpack_GetDefaultCodePage(), ucs2);
}
-MIR_CORE_DLL(wchar_t*) Utf8DecodeW(const char* str)
+MIR_CORE_DLL(wchar_t*) Utf8DecodeW(const char *str)
{
if (str == NULL)
return NULL;
@@ -408,7 +408,7 @@ MIR_CORE_DLL(char*) Utf8EncodeW(const wchar_t* src) /////////////////////////////////////////////////////////////////////////////////////////
// Utf8Encode - converts UCS2 string to the UTF8-encoded format
-MIR_CORE_DLL(BOOL) Utf8CheckString(const char* str)
+MIR_CORE_DLL(BOOL) Utf8CheckString(const char *str)
{
int expect_bytes = 0, utf_found = 0;
diff --git a/src/mir_core/utils.cpp b/src/mir_core/utils.cpp index d357b4538f..076747cd1e 100644 --- a/src/mir_core/utils.cpp +++ b/src/mir_core/utils.cpp @@ -73,7 +73,7 @@ MIR_CORE_DLL(WCHAR*) rtrimw(WCHAR *str) return str;
}
-MIR_CORE_DLL(char*) ltrim(char* str)
+MIR_CORE_DLL(char*) ltrim(char *str)
{
if (str == NULL)
return NULL;
|