Skip to content
Permalink
Browse files

Import tinyxml, drop scew and expat.

  • Loading branch information...
kanru
kanru committed Aug 19, 2005
1 parent 3c7112b commit bac11c8a818c53e020c903c6f32f220e5c48af91
Showing with 5,331 additions and 3,756 deletions.
  1. +16 −5 Experiments/Win32/Makefile
  2. +44 −75 Experiments/Win32/OVDummyLoader/DOVDictionary.cpp
  3. +5 −8 Experiments/Win32/OVDummyLoader/DOVDictionary.h
  4. +0 −85 Experiments/Win32/OVDummyLoader/expat/ascii.h
  5. +0 −36 Experiments/Win32/OVDummyLoader/expat/asciitab.h
  6. +0 −1,004 Experiments/Win32/OVDummyLoader/expat/expat.h
  7. +0 −92 Experiments/Win32/OVDummyLoader/expat/expat_external.h
  8. +0 −37 Experiments/Win32/OVDummyLoader/expat/iasciitab.h
  9. +0 −73 Experiments/Win32/OVDummyLoader/expat/internal.h
  10. +0 −36 Experiments/Win32/OVDummyLoader/expat/latin1tab.h
  11. BIN Experiments/Win32/OVDummyLoader/expat/libexpat.dll
  12. BIN Experiments/Win32/OVDummyLoader/expat/libexpat.lib
  13. +0 −53 Experiments/Win32/OVDummyLoader/expat/macconfig.h
  14. +0 −150 Experiments/Win32/OVDummyLoader/expat/nametab.h
  15. +0 −37 Experiments/Win32/OVDummyLoader/expat/utf8tab.h
  16. +0 −30 Experiments/Win32/OVDummyLoader/expat/winconfig.h
  17. +0 −114 Experiments/Win32/OVDummyLoader/expat/xmlrole.h
  18. +0 −316 Experiments/Win32/OVDummyLoader/expat/xmltok.h
  19. +0 −46 Experiments/Win32/OVDummyLoader/expat/xmltok_impl.h
  20. +0 −138 Experiments/Win32/OVDummyLoader/scew/attribute.h
  21. +0 −249 Experiments/Win32/OVDummyLoader/scew/element.h
  22. +0 −117 Experiments/Win32/OVDummyLoader/scew/error.h
  23. +0 −181 Experiments/Win32/OVDummyLoader/scew/parser.h
  24. +0 −72 Experiments/Win32/OVDummyLoader/scew/scew.h
  25. BIN Experiments/Win32/OVDummyLoader/scew/scew.lib
  26. +0 −123 Experiments/Win32/OVDummyLoader/scew/str.h
  27. +0 −119 Experiments/Win32/OVDummyLoader/scew/tree.h
  28. +0 −70 Experiments/Win32/OVDummyLoader/scew/types.h
  29. +0 −66 Experiments/Win32/OVDummyLoader/scew/writer.h
  30. +0 −91 Experiments/Win32/OVDummyLoader/scew/xattribute.h
  31. +0 −59 Experiments/Win32/OVDummyLoader/scew/xelement.h
  32. +0 −46 Experiments/Win32/OVDummyLoader/scew/xerror.h
  33. +0 −54 Experiments/Win32/OVDummyLoader/scew/xhandler.h
  34. +0 −70 Experiments/Win32/OVDummyLoader/scew/xparser.h
  35. +0 −56 Experiments/Win32/OVDummyLoader/scew/xprint.h
  36. +0 −48 Experiments/Win32/OVDummyLoader/scew/xtree.h
  37. +192 −0 Experiments/Win32/OVDummyLoader/tinyxml/changes.txt
  38. +496 −0 Experiments/Win32/OVDummyLoader/tinyxml/readme.txt
  39. +1,592 −0 Experiments/Win32/OVDummyLoader/tinyxml/tinyxml.cpp
  40. +1,427 −0 Experiments/Win32/OVDummyLoader/tinyxml/tinyxml.h
  41. +51 −0 Experiments/Win32/OVDummyLoader/tinyxml/tinyxmlerror.cpp
  42. +1,508 −0 Experiments/Win32/OVDummyLoader/tinyxml/tinyxmlparser.cpp
@@ -13,19 +13,20 @@ LINK32_OBJS = \
$(OUTDIR)\Utils.obj \
$(OUTDIR)\OVStringToolKit.obj \
$(OUTDIR)\OVDummyLoader.obj \
$(OUTDIR)\DOVDictionary.obj
$(OUTDIR)\DOVDictionary.obj \
$(OUTDIR)\tinyxml.obj \
$(OUTDIR)\tinyxmlerror.obj \
$(OUTDIR)\tinyxmlparser.obj

$(OUTDIR):
if not exist "$(OUTDIR)/$(NULL)" mkdir $(OUTDIR)

LINK_LIBS = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib OVIME\IMM32.LIB OVIME\OVIMEUI.lib OVDummyLoader\libltdl.lib OVDummyLoader\libiconv.lib OVDummyLoader\expat\libexpat.lib scew.lib
LINK_LIBS = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib OVIME\IMM32.LIB OVIME\OVIMEUI.lib OVDummyLoader\libltdl.lib OVDummyLoader\libiconv.lib

dllllflags = /INCREMENTAL:NO /NOLOGO /DLL /PDB:$(OUTDIR)/vc70.pdb /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /MACHINE:IX86

$(OUTDIR)\$(Proj).dll: $(OUTDIR) $(LINK32_OBJS) $(OUTDIR)\$(Proj).res
link $(dllllflags) \
/NODEFAULTLIB:scew_.lib \
/LIBPATH:OVDummyLoader\scew \
$(LINK32_OBJS) $(OUTDIR)\$(Proj).res $(LINK_LIBS) \
-out:$(OUTDIR)\$(Proj).ime\
-def:OVIME\$(Proj).def
@@ -53,7 +54,7 @@ FILE=Utils
$(OUTDIR)\$(FILE).obj: OVIME\$(FILE).cpp $(OUTDIR)
$(CXX) $(cflags) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" OVIME\$(FILE).cpp

cflags = /O2 /Ob1 /Oy /I "OVIME" /I "OVIMEUI\Headers" /I "../../Headers" /I "OVDummyLoader/expat" /I "OVDummyLoader/scew" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "OVIME_EXPORTS" /D "_WINDLL" /GF /EHsc /MT /GS /Gy /W3 /c /Wp64 /Zi /TP /GR
cflags = /O2 /Ob1 /Oy /I "OVIME" /I "OVIMEUI\Headers" /I "../../Headers" /I "OVDummyLoader/expat" /I "OVDummyLoader/tinyxml" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "OVIME_EXPORTS" /D "_WINDLL" /GF /EHsc /MT /GS /Gy /W3 /c /Wp64 /Zi /TP /GR
FILE=OVStringToolKit
$(OUTDIR)\$(FILE).obj: ..\..\Source\$(FILE).cpp $(OUTDIR)
$(CXX) $(cflags) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" ..\..\Source\$(FILE).cpp
@@ -63,6 +64,16 @@ $(OUTDIR)\$(FILE).obj: OVDummyLoader\$(FILE).cpp $(OUTDIR)
FILE=DOVDictionary
$(OUTDIR)\$(FILE).obj: OVDummyLoader\$(FILE).cpp $(OUTDIR)
$(CXX) $(cflags) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" OVDummyLoader\$(FILE).cpp
FILE=tinyxml
$(OUTDIR)\$(FILE).obj: OVDummyLoader\tinyxml\$(FILE).cpp $(OUTDIR)
$(CXX) $(cflags) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" OVDummyLoader\tinyxml\$(FILE).cpp
FILE=tinyxmlerror
$(OUTDIR)\$(FILE).obj: OVDummyLoader\tinyxml\$(FILE).cpp $(OUTDIR)
$(CXX) $(cflags) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" OVDummyLoader\tinyxml\$(FILE).cpp
FILE=tinyxmlparser
$(OUTDIR)\$(FILE).obj: OVDummyLoader\tinyxml\$(FILE).cpp $(OUTDIR)
$(CXX) $(cflags) /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" OVDummyLoader\tinyxml\$(FILE).cpp


FILE=OVIME
$(OUTDIR)\$(FILE).res: OVIME\$(FILE).rc $(OUTDIR)
@@ -6,65 +6,52 @@ DummyDictionary::DummyDictionary(const char *f, const char *dict)
{
file = f;
file += "config.xml";
parser = scew_parser_create();
scew_parser_ignore_whitespaces(parser, 1);
if(!scew_parser_load_file(parser, file.c_str())) {
createNewConfig(file.c_str());
scew_parser_load_file(parser, file.c_str());
if(!doc.LoadFile(file)) {
createNewConfig(file);
doc.LoadFile();
}
tree = scew_parser_tree(parser);
root = scew_tree_root(tree);
scew_element* i = scew_element_next(root, NULL);
while(i) {
if(!strcmp(scew_element_name(i), "dict")) {
scew_attribute* at = scew_attribute_by_name(i, "name");
if(at && !strcmp(scew_attribute_value(at), dict))
break;
}
i = scew_element_next(root, i);
}
module = i;

module = findChild(doc.RootElement(), "dict", dict);
name = dict;
}

bool DummyDictionary::createNewConfig(const char *f)
bool DummyDictionary::createNewConfig(std::string file)
{
scew_tree *t = NULL;
scew_element *r = NULL;
t = scew_tree_create();
r = scew_tree_add_root(t, "OpenVanilla");
scew_writer_tree_file(t, f);
scew_tree_free(t);
TiXmlDocument tmp(file);
tmp.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><OpenVanilla></OpenVanilla>");
tmp.SaveFile();
return true;
}

void DummyDictionary::newDict()
{
module = scew_element_add(root, "dict");
scew_element_add_attr_pair(module, "name", name.c_str());
scew_writer_tree_file(tree, file.c_str());
TiXmlElement tmp("dict");
tmp.SetAttribute("name", name.c_str());
module = doc.RootElement()->InsertEndChild(tmp);
doc.SaveFile();
}

TiXmlNode *DummyDictionary::findChild(TiXmlNode *parent, const char *node, const char *name)
{
TiXmlNode *child = 0;
while( child = parent->ToElement()->IterateChildren( child ) ) {
if(!strcmp(child->Value(), node))
if(!strcmp(child->ToElement()->Attribute("name"), name))
break;
}
return child;
}

DummyDictionary::~DummyDictionary()
{
scew_parser_free(parser);
}

int DummyDictionary::keyExist(const char *key)
{
unsigned int count;
int retval = 0;
if(!module) return retval;
scew_element** list = scew_element_list(module, "key", &count);
for(int i = 0; i < count; i++) {
scew_attribute* at = scew_attribute_by_name(list[i], "name");
if(at && !strcmp(scew_attribute_value(at), key)) {
retval = 1;
break;
}
}
scew_element_list_free(list);
return retval;
if(module && findChild(module, "key", key))
return 1;
else
return 0;
}

int DummyDictionary::getInteger(const char *key)
@@ -82,61 +69,43 @@ int DummyDictionary::setInteger(const char *key, int value)

const char* DummyDictionary::getString(const char *key)
{
int i;
unsigned int count;
if(!module) return "";
scew_element** list = scew_element_list(module, "key", &count);
for(i = 0; i < count; i++) {
scew_attribute* at = scew_attribute_by_name(list[i], "name");
if(at && !strcmp(scew_attribute_value(at), key))
break;
}
if(i == count) {
scew_element_list_free(list);
return "";
}
scew_attribute* at = scew_attribute_by_name(list[i], "value");
const XML_Char *value = at ? scew_attribute_value(at) : NULL;
scew_element_list_free(list);
if(value)
return value;
TiXmlNode *child = findChild(module, "key", key);
if(child)
return child->ToElement()->Attribute("value");
else
return "";
}

const char* DummyDictionary::setString(const char *key, const char *value)
{
int i;
unsigned int count;
scew_element *cur;
if(!module)
newDict();
scew_element** list = scew_element_list(module, "key", &count);
for(i = 0; i < count; i++) {
scew_attribute* at = scew_attribute_by_name(list[i], "name");
if(at && !strcmp(scew_attribute_value(at), key))
break;
TiXmlNode *child;
child = findChild(module, "key", key);
if(!child) {
TiXmlElement tmp("key");
tmp.SetAttribute("name", key);
child = module->ToElement()->InsertEndChild(tmp);
}
if(i == count)
cur = scew_element_add(module, "key");
else
cur = list[i];
scew_element_add_attr_pair(cur, "name", key);
scew_element_add_attr_pair(cur, "value", value);
scew_writer_tree_file(tree, file.c_str());
scew_element_list_free(list);
child->ToElement()->SetAttribute("value", value);
doc.SaveFile();
return value;
}

/*
int main()
{
DummyDictionary d("F:\\windows\\openvanilla\\", "Orz");
DummyDictionary d(".\\", "Orz");
if(d.keyExist("ccc"))
std::cout << "Ya!" << d.getString("ccc") << std::endl;
d.setInteger("ccc", 456);
d.setString("bbb", "hahaha");
if(d.keyExist("ccc"))
{
printf("orz/aaa: %d\n", d.getInteger("aaa"));
printf("orz/aaa: %s\n", d.getString("ccc"));
printf("orz/bbb: %s\n", d.getString("bbb"));
}
return 0;
}
@@ -1,8 +1,6 @@
#include <string>
#include "OpenVanilla.h"
extern "C" {
#include "scew/scew.h"
}
#include "tinyxml.h"

class DummyDictionary : public OVDictionary {
public:
@@ -13,13 +11,12 @@ class DummyDictionary : public OVDictionary {
virtual int setInteger(const char *key, int value);
virtual const char* getString(const char *key);
virtual const char* setString(const char *key, const char *value);
bool createNewConfig(const char *path);
bool createNewConfig(std::string path);
private:
std::string name;
std::string file;
void newDict();
scew_parser* parser;
scew_tree* tree;
scew_element* root;
scew_element* module;
TiXmlNode *findChild(TiXmlNode *parent, const char *node, const char *name);
TiXmlDocument doc;
TiXmlNode *module;
};

This file was deleted.

This file was deleted.

0 comments on commit bac11c8

Please sign in to comment.
You can’t perform that action at this time.