From 70837bd769de01a5d065eb033cd1b2b11fdb42eb Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Wed, 11 Jan 2012 15:26:53 +0100 Subject: [PATCH] First compilation of edn with ewol ==> did not work at all --- Makefile_old | 340 +++ jni/Android.mk | 23 + jni/Linux.mk | 24 + jni/edn/Buffer/Buffer.cpp | 18 +- jni/edn/Buffer/Buffer.h | 27 +- jni/edn/Buffer/BufferEmpty.cpp | 10 +- jni/edn/Buffer/BufferEmpty.h | 2 +- jni/edn/Buffer/BufferManager.cpp | 13 +- jni/edn/Buffer/BufferManager.h | 22 +- jni/edn/Buffer/BufferText.cpp | 51 +- jni/edn/Buffer/BufferText.h | 8 +- jni/edn/Colorize/Colorize.cpp | 13 +- jni/edn/Colorize/Colorize.h | 18 +- jni/edn/Colorize/ColorizeManager.cpp | 24 +- jni/edn/Colorize/ColorizeManager.h | 21 +- .../CustumWidget/BufferView/BufferView.cpp | 32 +- jni/edn/CustumWidget/BufferView/BufferView.h | 20 +- jni/edn/CustumWidget/CodeView/CodeView.cpp | 41 +- jni/edn/CustumWidget/CodeView/CodeView.h | 15 +- .../MainAreaView/MainAreaView.cpp | 59 - .../CustumWidget/MainAreaView/MainAreaView.h | 0 jni/edn/GuiTools/MainWindows/MainWindows.cpp | 46 +- jni/edn/GuiTools/MainWindows/MainWindows.h | 32 +- jni/edn/GuiTools/MainWindows/MenuBar.cpp | 20 +- jni/edn/GuiTools/MainWindows/MenuBar.h | 24 +- jni/edn/GuiTools/MainWindows/StatusBar.cpp | 6 +- jni/edn/GuiTools/MainWindows/StatusBar.h | 8 +- jni/edn/GuiTools/MainWindows/ToolBar.cpp | 16 +- jni/edn/GuiTools/MainWindows/ToolBar.h | 12 +- jni/edn/GuiTools/Search/Search.cpp | 21 +- jni/edn/GuiTools/Search/Search.h | 14 +- jni/edn/GuiTools/Search/SearchData.cpp | 17 +- jni/edn/GuiTools/Search/SearchData.h | 11 +- .../WindowsManager/WindowsManager.cpp | 26 +- .../GuiTools/WindowsManager/WindowsManager.h | 10 +- jni/edn/Highlight/Highlight.cpp | 24 +- jni/edn/Highlight/Highlight.h | 29 +- jni/edn/Highlight/HighlightManager.cpp | 14 +- jni/edn/Highlight/HighlightManager.h | 16 +- jni/edn/Highlight/HighlightPattern.cpp | 30 +- jni/edn/Highlight/HighlightPattern.h | 38 +- jni/edn/ctags/CTagsManager.cpp | 95 +- jni/edn/ctags/CTagsManager.h | 25 +- jni/edn/init.cpp | 70 +- jni/edn/tools/ClipBoard/ClipBoard.cpp | 24 +- jni/edn/tools/ClipBoard/ClipBoard.h | 22 +- jni/edn/tools/Display/Display.cpp | 76 +- jni/edn/tools/Display/Display.h | 14 +- jni/edn/tools/EdnBuf/EdnBuf.cpp | 42 +- jni/edn/tools/EdnBuf/EdnBuf.h | 42 +- jni/edn/tools/EdnBuf/EdnBufHistory.cpp | 12 +- jni/edn/tools/EdnBuf/EdnBufHistory.h | 10 +- jni/edn/tools/EdnBuf/EdnBuf_HighLight.cpp | 32 +- jni/edn/tools/EdnBuf/EdnBuf_History.cpp | 10 +- jni/edn/tools/EdnBuf/EdnBuf_Selection.cpp | 10 +- jni/edn/tools/EdnTemplate/EdnVectorBuf.cpp | 17 +- jni/edn/tools/EdnTemplate/EdnVectorBuf.h | 10 +- jni/edn/tools/EdnTemplate/Singleton.h | 85 - jni/edn/tools/MsgBroadcast/AccelKey.cpp | 8 +- jni/edn/tools/MsgBroadcast/AccelKey.h | 8 +- jni/edn/tools/MsgBroadcast/MsgBroadcast.cpp | 10 +- jni/edn/tools/MsgBroadcast/MsgBroadcast.h | 22 +- jni/edn/tools/NameSpaceEdn/Edn.h | 36 - jni/edn/tools/NameSpaceEdn/File.cpp | 246 -- jni/edn/tools/NameSpaceEdn/File.h | 66 - jni/edn/tools/NameSpaceEdn/RegExp.cpp | 488 ---- jni/edn/tools/NameSpaceEdn/RegExp.h | 2113 ----------------- jni/edn/tools/NameSpaceEdn/String.cpp | 718 ------ jni/edn/tools/NameSpaceEdn/String.h | 92 - jni/edn/tools/NameSpaceEdn/Vector.h | 506 ---- jni/edn/tools/NameSpaceEdn/VectorType.h | 671 ------ jni/edn/tools/charset/charset.cpp | 24 +- jni/edn/tools/charset/charset.h | 28 +- jni/edn/tools/charset/charsetTable.cpp | 18 +- jni/edn/tools/debug/tools_debug.cpp | 37 +- jni/edn/tools/debug/tools_debug.h | 121 +- jni/edn/tools/globals/tools_globals.cpp | 6 +- jni/edn/tools/globals/tools_globals.h | 4 +- jni/edn/tools/memory/toolsMemory.h | 5 +- jni/edn/tools/tinyXML/tinystr.cpp | 116 - jni/edn/tools/tinyXML/tinystr.h | 319 --- jni/edn/tools/tinyXML/tinyxml.cpp | 1839 -------------- jni/edn/tools/tinyXML/tinyxml.h | 1799 -------------- jni/edn/tools/tinyXML/tinyxmlerror.cpp | 52 - jni/edn/tools/tinyXML/tinyxmlparser.cpp | 1635 ------------- jni/file.mk | 58 + 86 files changed, 1169 insertions(+), 11667 deletions(-) create mode 100644 Makefile_old create mode 100644 jni/Android.mk create mode 100644 jni/Linux.mk delete mode 100644 jni/edn/CustumWidget/MainAreaView/MainAreaView.cpp delete mode 100644 jni/edn/CustumWidget/MainAreaView/MainAreaView.h delete mode 100755 jni/edn/tools/EdnTemplate/Singleton.h delete mode 100644 jni/edn/tools/NameSpaceEdn/Edn.h delete mode 100644 jni/edn/tools/NameSpaceEdn/File.cpp delete mode 100644 jni/edn/tools/NameSpaceEdn/File.h delete mode 100644 jni/edn/tools/NameSpaceEdn/RegExp.cpp delete mode 100644 jni/edn/tools/NameSpaceEdn/RegExp.h delete mode 100644 jni/edn/tools/NameSpaceEdn/String.cpp delete mode 100644 jni/edn/tools/NameSpaceEdn/String.h delete mode 100644 jni/edn/tools/NameSpaceEdn/Vector.h delete mode 100644 jni/edn/tools/NameSpaceEdn/VectorType.h delete mode 100644 jni/edn/tools/tinyXML/tinystr.cpp delete mode 100644 jni/edn/tools/tinyXML/tinystr.h delete mode 100644 jni/edn/tools/tinyXML/tinyxml.cpp delete mode 100644 jni/edn/tools/tinyXML/tinyxml.h delete mode 100644 jni/edn/tools/tinyXML/tinyxmlerror.cpp delete mode 100644 jni/edn/tools/tinyXML/tinyxmlparser.cpp create mode 100644 jni/file.mk diff --git a/Makefile_old b/Makefile_old new file mode 100644 index 0000000..418b9a3 --- /dev/null +++ b/Makefile_old @@ -0,0 +1,340 @@ +################################################################################################################## +# # +# Fichier : Makefile # +# # +# Type : Makefile d'un programme complet # +# # +# Auteur : Heero Yui # +# # +# Evolutions : Date Auteur Raison # +# 2010-01-29 Heero Yui Mise en place d'un makefile ultra simple # +# 2011-07-14 Heero Yui Rework the current dorder includion (simplification) # +# # +# Notes : This makefile might be edited with an editor compatible with escape char and carrer return # +# char # +# # +# Concu Pour le projet edn # +# # +################################################################################################################## +export F_GRAS= +export F_INVERSER= +export F_SOUSLIGNER= +export F_NORMALE= +export F_NOIR= +export F_ROUGE= +export F_VERT= +export F_MARRON= +export F_BLUE= +export F_VIOLET= +export F_CYAN= +export F_GRIS= +export CADRE_HAUT_BAS=' $(F_INVERSER) $(F_NORMALE)' +export CADRE_COTERS=' $(F_INVERSER) $(F_NORMALE) $(F_INVERSER) $(F_NORMALE)' + +VERSION_TAG=$(shell git describe --tags) +#$(info $(VERSION_TAG)) + +VERSION_TAG_SHORT=$(shell git describe --tags --abbrev=0) +#$(info $(VERSION_TAG_SHORT)) + +VERSION_BUILD_TIME=$(shell date) +#$(info $(VERSION_BUILD_TIME)) + +############################################################################### +### Compilateur base system ### +############################################################################### +CXX=g++ +CC=gcc +AR=ar + +DEBUG:=1 + +############################################################################### +### Compilation Define ### +############################################################################### +ifeq ("$(DEBUG)", "0") + DEFINE= -DEDN_DEBUG_LEVEL=1 -DNDEBUG -DVERSION_TAG_NAME="\"$(VERSION_TAG)-release\"" +else + DEFINE= -DEDN_DEBUG_LEVEL=3 -DVERSION_TAG_NAME="\"$(VERSION_TAG)-debug\"" +endif +DEFINE+= -DVERSION_BUILD_TIME="\"$(VERSION_BUILD_TIME)\"" + +GTKFLAGS= +ifeq ($(shell if `pkg-config --exists gtk+-3.0` ; then echo "yes"; else echo "no"; fi), yes) + GTKFLAGS= `pkg-config --cflags --libs gtk+-3.0` -DUSE_GTK_VERSION_3_0 +else + ifeq ($(shell if `pkg-config --exists gtk+-2.0` ; then echo "yes"; else echo "no"; fi), yes) + GTKFLAGS= `pkg-config --cflags --libs gtk+-2.0` -DUSE_GTK_VERSION_2_0 + else + $(error No GTK 3.0 or 2.0 librairies ...) + endif +endif + +############################################################################### +### Basic Cfags ### +############################################################################### + +# basic GTK librairy +CXXFLAGS= $(GTKFLAGS) +# Linux thread system +CXXFLAGS+= -lpthread +# Enable debug (cgdb edn) +CXXFLAGS+= -g -O0 +#CXXFLAGS+= -O2 +# display all flags +CXXFLAGS+= -Wall +# ... +CXXFLAGS+= -D_REENTRANT +# internal defines +CXXFLAGS+= $(DEFINE) + +CFLAGS= $(CXXFLAGS) -std=c99 + +# basic GTK librairy +LDFLAGS= $(GTKFLAGS) +# Linux thread system +LDFLAGS+= -lpthread +# Dynamic connection of the CALLBACK of the GUI +LDFLAGS+= -Wl,--export-dynamic + +############################################################################### +### Project Name ### +############################################################################### +PROG_NAME=edn + +############################################################################### +### Basic Project description Files ### +############################################################################### +FILE_DIRECTORY=Sources +OUTPUT_NAME_RELEASE=$(PROG_NAME)_release +OUTPUT_NAME_DEBUG=$(PROG_NAME)_debug +OBJECT_DIR=Object + +ifeq ("$(DEBUG)", "0") + OBJECT_DIRECTORY=$(OBJECT_DIR)/release + OUTPUT_NAME = $(OUTPUT_NAME_RELEASE) +else + OBJECT_DIRECTORY=$(OBJECT_DIR)/debug + OUTPUT_NAME = $(OUTPUT_NAME_DEBUG) +endif + + + +############################################################################### +### Generique dependency ### +############################################################################### +MAKE_DEPENDENCE=Makefile + +############################################################################### +### Files Listes ### +############################################################################### + +# tiny XML (extern OPEN Sources) : +CXXFILES = tools/tinyXML/tinyxml.cpp \ + tools/tinyXML/tinyxmlparser.cpp \ + tools/tinyXML/tinyxmlerror.cpp \ + tools/tinyXML/tinystr.cpp + +# ExuberantCtags reading file tools (extern OPEN Sources) : +CXXFILES+= ctags/readtags.cpp \ + ctags/CTagsManager.cpp + + +# Globals debug tool: +CXXFILES+= tools/debug/tools_debug.cpp \ + tools/globals/tools_globals.cpp \ + tools/memory/toolsMemory.cpp + +# Buffers internal: +CXXFILES+= tools/EdnTemplate/EdnVectorBuf.cpp \ + tools/EdnBuf/EdnBuf.cpp \ + tools/EdnBuf/EdnBuf_HighLight.cpp \ + tools/EdnBuf/EdnBuf_History.cpp \ + tools/EdnBuf/EdnBuf_Selection.cpp \ + tools/EdnBuf/EdnBufHistory.cpp + + +# Tools internal: +CXXFILES+= tools/Display/Display.cpp \ + tools/ClipBoard/ClipBoard.cpp \ + tools/MsgBroadcast/MsgBroadcast.cpp \ + tools/MsgBroadcast/AccelKey.cpp \ + tools/charset/charsetTable.cpp \ + tools/charset/charset.cpp \ + tools/NameSpaceEdn/File.cpp \ + tools/NameSpaceEdn/String.cpp \ + tools/NameSpaceEdn/RegExp.cpp + +# Gui: +CXXFILES+= CustumWidget/BufferView/BufferView.cpp \ + CustumWidget/CodeView/CodeView.cpp \ + GuiTools/WindowsManager/WindowsManager.cpp \ + GuiTools/MainWindows/MainWindows.cpp \ + GuiTools/MainWindows/StatusBar.cpp \ + GuiTools/MainWindows/MenuBar.cpp \ + GuiTools/MainWindows/ToolBar.cpp \ + GuiTools/Search/Search.cpp \ + GuiTools/Search/SearchData.cpp + +# Basic Interface : +CXXFILES+= Buffer/Buffer.cpp \ + Buffer/BufferText.cpp \ + Buffer/BufferEmpty.cpp \ + Buffer/BufferManager.cpp \ + Colorize/Colorize.cpp \ + Colorize/ColorizeManager.cpp \ + Highlight/HighlightPattern.cpp \ + Highlight/Highlight.cpp \ + Highlight/HighlightManager.cpp + +# Main entry file : +CXXFILES+= init.cpp + + +############################################################################### +### Liste of folder where .h can be ### +############################################################################### +LISTE_MODULES = $(dir $(CXXFILES)) +INCLUDE_DIRECTORY = $(addprefix -I$(FILE_DIRECTORY)/, $(LISTE_MODULES)) + +############################################################################### +### Build Object Files List ### +############################################################################### +OBJ = $(addprefix $(OBJECT_DIRECTORY)/, $(CXXFILES:.cpp=.o)) + + + +############################################################################### +### Main Part of Makefile ### +############################################################################### +all: build + +-include $(OBJ:.o=.d) + +build: .encadrer .versionFile $(OUTPUT_NAME) + + +.encadrer: + @echo $(CADRE_HAUT_BAS) + @echo $(CADRE_COTERS) + @echo ' DEBUT DE COMPILATION DU PROGRAMME :'$(CADRE_COTERS) + @echo ' Repertoire Sources : $(FILE_DIRECTORY)/'$(CADRE_COTERS) + @echo ' Repertoire object : $(OBJECT_DIRECTORY)/'$(CADRE_COTERS) + @echo ' Binaire de sortie : $(F_VIOLET)$(OUTPUT_NAME) $(F_NORMALE)'$(CADRE_COTERS) + @echo $(CADRE_COTERS) + @echo $(CADRE_HAUT_BAS) + @mkdir -p $(addprefix $(OBJECT_DIRECTORY)/, $(LISTE_MODULES)) + + +FILE_IMAGES= data/imagesSources/*.png + + +.versionFile : + @rm -f $(OBJECT_DIRECTORY)/GuiTools/WindowsManager/WindowsManager.o + + +# Tool used to create a binary version of every element png or other needed by the application +pngToCpp: tools/pngToCpp/pngToCpp.c + @echo $(F_ROUGE)" (bin) $@"$(F_NORMALE) + @$(CXX) $< -o $@ + @strip -s $@ + +# Generate basic +$(FILE_DIRECTORY)/GuiTools/myImage.cpp: $(FILE_IMAGES) $(MAKE_DEPENDENCE) pngToCpp + @echo $(F_BLUE)" (.cpp) *.png ==> $@"$(F_NORMALE) + @./pngToCpp $@ $(FILE_IMAGES) + + +# build C++ +$(OBJECT_DIRECTORY)/%.o: $(FILE_DIRECTORY)/%.cpp $(MAKE_DEPENDENCE) + @echo $(F_VERT)" (.o) $<"$(F_NORMALE) + @$(CXX) $< -c -o $@ $(INCLUDE_DIRECTORY) $(CXXFLAGS) -MMD + +# build binary Release Mode +$(OUTPUT_NAME_RELEASE): $(OBJ) $(MAKE_DEPENDENCE) + @echo $(F_ROUGE)" (bin) $@ "$(F_NORMALE) + @$(CXX) $(OBJ) $(LDFLAGS) -o $@ + @cp $@ $(PROG_NAME) + +# build binary Debug Mode +$(OUTPUT_NAME_DEBUG): $(OBJ) $(MAKE_DEPENDENCE) + @echo $(F_ROUGE)" (bin) $@ "$(F_NORMALE) + @$(CXX) $(OBJ) $(LDFLAGS) -o $@ + @cp $@ $(PROG_NAME) + +clean: + @echo $(CADRE_HAUT_BAS) + @echo ' CLEANING : $(F_VIOLET)$(OUTPUT_NAME)$(F_NORMALE)'$(CADRE_COTERS) + @echo $(CADRE_HAUT_BAS) + @echo Remove Folder : $(OBJECT_DIR) + @rm -rf $(OBJECT_DIR) + @echo Remove File : $(PROG_NAME) $(OUTPUT_NAME_DEBUG) $(OUTPUT_NAME_RELEASE) + @rm -f $(PROG_NAME) $(OUTPUT_NAME_DEBUG) $(OUTPUT_NAME_RELEASE) + @echo Remove File : pngToCpp + @rm -f pngToCpp + @echo Remove File : $(FILE_DIRECTORY)/GuiTools/myImage.* + @rm -f $(FILE_DIRECTORY)/GuiTools/myImage.* + @echo Remove doxygen files : doxygen/* + @rm -rf doxygen + @rm -f doxygen.log + @echo Remove temporary files *.bck + @rm -f `find . -name "*.bck"` + +count: + wc -l Makefile `find $(FILE_DIRECTORY)/ -name "*.cpp"` `find $(FILE_DIRECTORY)/ -name "*.h"` + +install: .encadrer .versionFile $(OUTPUT_NAME_RELEASE) + @echo $(CADRE_HAUT_BAS) + @echo ' INSTALL : $(F_VIOLET)$(OUTPUT_NAME_RELEASE)=>$(PROG_NAME)$(F_NORMALE)'$(CADRE_COTERS) + @echo $(CADRE_HAUT_BAS) + @echo $(F_ROUGE)" (stripped) $(OUTPUT_NAME_RELEASE) => $(PROG_NAME) "$(F_NORMALE) + @cp $(OUTPUT_NAME_RELEASE) $(PROG_NAME) + @strip -s $(PROG_NAME) + @echo $(F_VERT)" (copy) $(PROG_NAME) /usr/bin/ "$(F_NORMALE) + @cp -vf $(PROG_NAME) /usr/bin/ + @echo $(F_VERT)" (data) data/* ==> /usr/share/edn/ "$(F_NORMALE) + @mkdir -p /usr/share/edn/ + @rm -rf /usr/share/edn/* + @cp -vf data/*.xml /usr/share/edn/ + @mkdir -p /usr/share/edn/images/ + @cp -vf data/imagesSources/icone.png /usr/share/edn/images/ + @cp -vf data/imagesSources/delete-24px.png /usr/share/edn/images/ + # gnome adding for the program at the list (manage icone in .xpm) + @cp -vf data/edn.desktop /usr/share/applications/ + @cp -vf data/imagesSources/icone.png /usr/share/app-install/icons/Edn.png + @cp -vf data/imagesSources/icone.xpm /usr/share/pixmaps/Edn.xpm + + +# http://alp.developpez.com/tutoriels/debian/creer-paquet/ +package: .encadrer + @echo 'Create Folders ...' + @mkdir -p package/$(PROG_NAME)/DEBIAN/ + @mkdir -p package/$(PROG_NAME)/usr/bin/ + @mkdir -p package/$(PROG_NAME)/usr/share/doc/ + @mkdir -p package/$(PROG_NAME)/usr/share/edn/ + # Create the control file + @echo "Package: "$(PROG_NAME) > package/$(PROG_NAME)/DEBIAN/control + @echo "Version: "$(VERSION_TAG_SHORT) >> package/$(PROG_NAME)/DEBIAN/control + @echo "Section: Development,Editors" >> package/$(PROG_NAME)/DEBIAN/control + @echo "Priority: optional" >>package/$(PROG_NAME)/DEBIAN/control + @echo "Architecture: all" >> package/$(PROG_NAME)/DEBIAN/control + @echo "Depends: bash" >> package/$(PROG_NAME)/DEBIAN/control + @echo "Maintainer: Mr DUPIN Edouard " >> package/$(PROG_NAME)/DEBIAN/control + @echo "Description: Text editor for sources code with ctags management" >> package/$(PROG_NAME)/DEBIAN/control + @echo "" >> package/$(PROG_NAME)/DEBIAN/control + # Create the PostRm + @echo "#!/bin/bash" > package/$(PROG_NAME)/DEBIAN/postrm + @echo "rm ~/."$(PROG_NAME) >> package/$(PROG_NAME)/DEBIAN/postrm + @echo "" >> package/$(PROG_NAME)/DEBIAN/postrm + # Enable Execution in script + @chmod 755 package/$(PROG_NAME)/DEBIAN/post* + @#chmod 755 package/$(PROG_NAME)/DEBIAN/pre* + # copy licence and information : + @cp README package/$(PROG_NAME)/usr/share/doc/README + @cp licence.txt package/$(PROG_NAME)/usr/share/doc/copyright + @echo "First generation in progress" >> package/$(PROG_NAME)/usr/share/doc/changelog + @cp -vf $(PROG_NAME) package/$(PROG_NAME)/usr/bin/ + @cp -vf data/*.xml package/$(PROG_NAME)/usr/share/edn/ + @cd package; dpkg-deb --build $(PROG_NAME) + + diff --git a/jni/Android.mk b/jni/Android.mk new file mode 100644 index 0000000..69b2c64 --- /dev/null +++ b/jni/Android.mk @@ -0,0 +1,23 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := ednpackage +LOCAL_STATIC_LIBRARIES := ewol + +LOCAL_C_INCLUDES := $(LOCAL_PATH) + +# load the common sources file of the platform +include $(LOCAL_PATH)/file.mk + +LOCAL_SRC_FILES := ewolAndroidAbstraction.cpp \ + $(FILE_LIST) + +LOCAL_LDLIBS := -llog -landroid + +include $(BUILD_SHARED_LIBRARY) + +NDK_MODULE_PATH := $(LOCAL_PATH)/../../ + + +$(call import-module,ewol/Sources) diff --git a/jni/Linux.mk b/jni/Linux.mk new file mode 100644 index 0000000..a2a529c --- /dev/null +++ b/jni/Linux.mk @@ -0,0 +1,24 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +# load the common sources file of the platform +include $(LOCAL_PATH)/file.mk + +LOCAL_MODULE := ednn +LOCAL_STATIC_LIBRARIES := ewol etk tinyxml libzip libpng + +LOCAL_C_INCLUDES := -I$(LOCAL_PATH) $(addprefix -I$(LOCAL_PATH)/, $(sort $(dir $(FILE_LIST)))) + +LOCAL_SRC_FILES := $(FILE_LIST) +LOCAL_LDLIBS := + +LOCAL_CFLAGS := -DEWOL_USE_FREE_TYPE \ + -DEDN_DEBUG_LEVEL=3 + +include $(BUILD_EXECUTABLE) + +NDK_MODULE_PATH := $(LOCAL_PATH)/../../ + + +$(call import-module,ewol/Sources) diff --git a/jni/edn/Buffer/Buffer.cpp b/jni/edn/Buffer/Buffer.cpp index a1921b2..ad14e6e 100644 --- a/jni/edn/Buffer/Buffer.cpp +++ b/jni/edn/Buffer/Buffer.cpp @@ -23,10 +23,10 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "Buffer.h" -#include "BufferManager.h" +#include +#include +#include +#include #undef __class__ #define __class__ "Buffer" @@ -44,7 +44,7 @@ Buffer::Buffer() static int32_t fileBasicID = 0; m_fileModify = true; m_haveName = false; - Edn::String mString = "Untitle - "; + etk::String mString = "Untitle - "; mString += fileBasicID++; SetFileName(mString); m_haveName = false; @@ -58,7 +58,7 @@ Buffer::Buffer() * @return --- * */ -Buffer::Buffer(Edn::File &newName) +Buffer::Buffer(etk::File &newName) { m_fileModify = false; SetFileName(newName); @@ -269,17 +269,17 @@ void Buffer::AddChar(char * UTF8data) // nothing to do } -void Buffer::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp) +void Buffer::Search(etk::String &data, bool back, bool caseSensitive, bool wrap, bool regExp) { // nothing to do } -void Buffer::Replace(Edn::String &data) +void Buffer::Replace(etk::String &data) { // nothing to do } -int32_t Buffer::FindLine(Edn::String &data) +int32_t Buffer::FindLine(etk::String &data) { // nothing to do return 0; diff --git a/jni/edn/Buffer/Buffer.h b/jni/edn/Buffer/Buffer.h index fd78b3f..8b78df0 100644 --- a/jni/edn/Buffer/Buffer.h +++ b/jni/edn/Buffer/Buffer.h @@ -26,10 +26,11 @@ #ifndef __BUFFER_H__ #define __BUFFER_H__ -#include -#include "Display.h" -#include "charset.h" -#include "Edn.h" +#include +#include +#include +#include + typedef struct{ @@ -45,24 +46,24 @@ typedef struct{ class Buffer { public: Buffer(void); - Buffer(Edn::File &newName); + Buffer(etk::File &newName); virtual ~Buffer(void); - Edn::File GetFileName(void) + etk::File GetFileName(void) { return m_fileName; }; - void SetFileName(Edn::File &newName) + void SetFileName(etk::File &newName) { m_fileName = newName; m_haveName = true; NameChange(); }; - void SetFileName(Edn::String &newName) + void SetFileName(etk::String &newName) { - m_fileName.SetCompleateName(newName); + m_fileName.SetCompleateName(newName, etk::FILE_TYPE_DIRECT); m_haveName = true; NameChange(); }; @@ -102,16 +103,16 @@ class Buffer { virtual void Copy(int8_t clipboardID); virtual void Cut(int8_t clipboardID); virtual void Paste(int8_t clipboardID); - virtual void Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp); - virtual void Replace(Edn::String &data); - virtual int32_t FindLine(Edn::String &data); + virtual void Search(etk::String &data, bool back, bool caseSensitive, bool wrap, bool regExp); + virtual void Replace(etk::String &data); + virtual int32_t FindLine(etk::String &data); virtual void JumpAtLine(int32_t newLine); virtual int32_t GetCurrentLine(void); protected: bool m_fileModify; //!< // naming - Edn::File m_fileName; //!< filename of the curent buffer + etk::File m_fileName; //!< filename of the curent buffer bool m_haveName; //!< to know if the file have a name or NOT }; diff --git a/jni/edn/Buffer/BufferEmpty.cpp b/jni/edn/Buffer/BufferEmpty.cpp index 032b9fc..80a82d1 100644 --- a/jni/edn/Buffer/BufferEmpty.cpp +++ b/jni/edn/Buffer/BufferEmpty.cpp @@ -23,11 +23,11 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "BufferEmpty.h" -#include "ColorizeManager.h" -#include "MainWindows.h" +#include +#include +#include +#include +#include #undef __class__ #define __class__ "BufferEmpty" diff --git a/jni/edn/Buffer/BufferEmpty.h b/jni/edn/Buffer/BufferEmpty.h index 19189a7..7771774 100644 --- a/jni/edn/Buffer/BufferEmpty.h +++ b/jni/edn/Buffer/BufferEmpty.h @@ -26,7 +26,7 @@ #ifndef __BUFFER_EMPTY_H__ #define __BUFFER_EMPTY_H__ -#include "Buffer.h" +#include class BufferEmpty : public Buffer { public: diff --git a/jni/edn/Buffer/BufferManager.cpp b/jni/edn/Buffer/BufferManager.cpp index 61c87b0..66cadd0 100644 --- a/jni/edn/Buffer/BufferManager.cpp +++ b/jni/edn/Buffer/BufferManager.cpp @@ -24,10 +24,9 @@ */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "BufferManager.h" -//#include "MsgBroadcast.h" +#include +#include +#include #undef __class__ #define __class__ "BufferManager" @@ -185,7 +184,7 @@ int32_t BufferManager::Create(void) * @todo : check if this file is not curently open and return the old ID * */ -int32_t BufferManager::Open(Edn::File &myFile) +int32_t BufferManager::Open(etk::File &myFile) { // TODO : Check here if the file is already open ==> and display it if needed // allocate a new Buffer @@ -236,7 +235,7 @@ bool BufferManager::Exist(int32_t BufferID) } -bool BufferManager::Exist(Edn::File &myFile ) +bool BufferManager::Exist(etk::File &myFile ) { if (-1 == GetId(myFile)) { return false; @@ -245,7 +244,7 @@ bool BufferManager::Exist(Edn::File &myFile ) } -int32_t BufferManager::GetId(Edn::File &myFile) +int32_t BufferManager::GetId(etk::File &myFile) { int32_t iii; // check if the Buffer existed diff --git a/jni/edn/Buffer/BufferManager.h b/jni/edn/Buffer/BufferManager.h index 846b469..6149827 100644 --- a/jni/edn/Buffer/BufferManager.h +++ b/jni/edn/Buffer/BufferManager.h @@ -26,15 +26,15 @@ #ifndef __BUFFER_MANAGER_H__ #define __BUFFER_MANAGER_H__ -#include "Buffer.h" -#include "BufferText.h" -#include "BufferEmpty.h" -#include "Singleton.h" -#include "MsgBroadcast.h" +#include +#include +#include +#include +#include -class BufferManager: public Singleton, public MsgBroadcast +class BufferManager: public etk::Singleton, public MsgBroadcast { - friend class Singleton; + friend class etk::Singleton; // specific for sigleton system... private: // Constructeur @@ -48,13 +48,13 @@ class BufferManager: public Singleton, public MsgBroadcast // create a buffer with no element int32_t Create(void); // open curent filename - int32_t Open(Edn::File &myFile); + int32_t Open(etk::File &myFile); int32_t GetSelected(void) { return m_idSelected;}; void SetSelected(int32_t id) {m_idSelected = id;}; Buffer * Get(int32_t BufferID); bool Exist(int32_t BufferID); - bool Exist(Edn::File &myFile); - int32_t GetId(Edn::File &myFile); + bool Exist(etk::File &myFile); + int32_t GetId(etk::File &myFile); // return the number of buffer (open in the past) if 5 buffer open and 4 close ==> return 5 uint32_t Size(void); int32_t WitchBuffer(int32_t iEmeElement); @@ -63,7 +63,7 @@ class BufferManager: public Singleton, public MsgBroadcast private: - Edn::VectorType listBuffer; //!< element List of the char Elements + etk::VectorType listBuffer; //!< element List of the char Elements void RemoveAll(void); //!< remove all buffer int32_t m_idSelected; diff --git a/jni/edn/Buffer/BufferText.cpp b/jni/edn/Buffer/BufferText.cpp index 8c73f0e..dac4cea 100644 --- a/jni/edn/Buffer/BufferText.cpp +++ b/jni/edn/Buffer/BufferText.cpp @@ -23,13 +23,12 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "ClipBoard.h" -#include "BufferText.h" -#include "toolsMemory.h" -#include "Edn.h" -#include "RegExp.h" +#include +#include +#include +#include +#include +#include #undef __class__ #define __class__ "BufferText" @@ -125,7 +124,7 @@ BufferText::BufferText() * @return --- * */ -BufferText::BufferText(Edn::File &fileName) : Buffer(fileName) +BufferText::BufferText(etk::File &fileName) : Buffer(fileName) { BasicInit(); NameChange(); @@ -327,8 +326,8 @@ int32_t BufferText::Display(DrawerManager &drawer) int displayLines = 0; // Regenerate the colorizing if necessary ... m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, m_displayStartBufferPos, m_displaySize.y); - GTimeVal timeStart; - g_get_current_time(&timeStart); + //GTimeVal timeStart; + //g_get_current_time(&timeStart); // draw the lineNumber : int32_t currentLineID = m_displayStart.y+1; @@ -450,9 +449,9 @@ int32_t BufferText::Display(DrawerManager &drawer) } drawer.Flush(); - GTimeVal timeStop; - g_get_current_time(&timeStop); - EDN_DEBUG("Display Generation = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s"); + //GTimeVal timeStop; + //g_get_current_time(&timeStop); + //EDN_DEBUG("Display Generation = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s"); return ERR_NONE; } @@ -993,7 +992,7 @@ void BufferText::AddChar(char * UTF8data) if (1==size) { if (UTF8data[0] == 0x09) { if (false == haveSelectionActive) { - Edn::VectorType tmpVect; + etk::VectorType tmpVect; tmpVect.PushBack(0x09); m_EdnBuf.Insert(m_cursorPos, tmpVect); SetInsertPosition(m_cursorPos+1, true); @@ -1002,7 +1001,7 @@ void BufferText::AddChar(char * UTF8data) // count the number of line : int32_t nbSelectedLines = m_EdnBuf.CountLines(SelectionStart, SelectionEnd); if (0 == nbSelectedLines) { - Edn::VectorType tmpVect; + etk::VectorType tmpVect; tmpVect.PushBack(0x09); m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect); SetInsertPosition(SelectionStart+tmpVect.Size(), true); @@ -1016,7 +1015,7 @@ void BufferText::AddChar(char * UTF8data) } actionDone = true; } else if (UTF8data[0] == '\n') { - Edn::VectorType tmpVect; + etk::VectorType tmpVect; if (true == globals::IsSetShift()) { tmpVect.PushBack('\r'); } else { @@ -1075,7 +1074,7 @@ void BufferText::AddChar(char * UTF8data) if (false == actionDone) { if (true == m_EdnBuf.GetUTF8Mode()) { - Edn::VectorType tmpVect; + etk::VectorType tmpVect; int32_t localOfset = strlen(UTF8data); tmpVect.PushBack((int8_t*)UTF8data, localOfset); if (false == haveSelectionActive) { @@ -1090,7 +1089,7 @@ void BufferText::AddChar(char * UTF8data) char output_ISO; convertUtf8ToIso(m_EdnBuf.GetCharsetType(), UTF8data, output_ISO); //printf(" insert : \"%s\"==> 0x%08x=%d ", UTF8data, (unsigned int)output_ISO, (int)output_ISO); - Edn::VectorType tmpVect; + etk::VectorType tmpVect; tmpVect.PushBack(output_ISO); if (false == haveSelectionActive) { m_EdnBuf.Insert(m_cursorPos, tmpVect); @@ -1107,14 +1106,14 @@ void BufferText::AddChar(char * UTF8data) } -int32_t BufferText::FindLine(Edn::String &data) +int32_t BufferText::FindLine(etk::String &data) { if ( 0 == data.Size()) { EDN_WARNING("no search data"); return 0; } EDN_INFO("Search data line : \"" << data << "\""); - Edn::VectorType mVectSearch; + etk::VectorType mVectSearch; mVectSearch = data.GetVector(); //EDN_INFO("search data Forward : startSearchPos=" << startSearchPos ); int32_t foundPos; @@ -1151,7 +1150,7 @@ int32_t BufferText::GetCurrentLine(void) -void BufferText::Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp) +void BufferText::Search(etk::String &data, bool back, bool caseSensitive, bool wrap, bool regExp) { EDN_INFO("Search data : \"" << data << "\""); @@ -1172,7 +1171,7 @@ void BufferText::Search(Edn::String &data, bool back, bool caseSensitive, bool w EDN_WARNING("no search data"); return; } - Edn::VectorType mVectSearch; + etk::VectorType mVectSearch; mVectSearch = data.GetVector(); if (false == back) { //EDN_INFO("search data Forward : startSearchPos=" << startSearchPos ); @@ -1239,14 +1238,14 @@ void BufferText::Search(Edn::String &data, bool back, bool caseSensitive, bool w } -void BufferText::Replace(Edn::String &data) +void BufferText::Replace(etk::String &data) { int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd; bool SelectionIsRect; bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd); if (true == haveSelectionActive) { // Replace Data : - Edn::VectorType myData = data.GetVector(); + etk::VectorType myData = data.GetVector(); m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, myData); SetInsertPosition(SelectionStart + myData.Size()); } @@ -1264,7 +1263,7 @@ void BufferText::Replace(Edn::String &data) */ void BufferText::Copy(int8_t clipboardID) { - Edn::VectorType mVect; + etk::VectorType mVect; // get the curent selected data if (true == m_EdnBuf.SelectHasSelection(SELECTION_PRIMARY) ) { m_EdnBuf.GetSelectionText(SELECTION_PRIMARY, mVect); @@ -1313,7 +1312,7 @@ void BufferText::Cut(int8_t clipboardID) */ void BufferText::Paste(int8_t clipboardID) { - Edn::VectorType mVect; + etk::VectorType mVect; // copy data from the click board : ClipBoard::Get(clipboardID, mVect); diff --git a/jni/edn/Buffer/BufferText.h b/jni/edn/Buffer/BufferText.h index d3eb491..7be8591 100644 --- a/jni/edn/Buffer/BufferText.h +++ b/jni/edn/Buffer/BufferText.h @@ -39,7 +39,7 @@ typedef enum { class BufferText : public Buffer { public: BufferText(void); - BufferText(Edn::File &fileName); + BufferText(etk::File &fileName); virtual ~BufferText(void); void Save(void); @@ -61,9 +61,9 @@ class BufferText : public Buffer { void Cut(int8_t clipboardID); void Paste(int8_t clipboardID); - void Search(Edn::String &data, bool back, bool caseSensitive, bool wrap, bool regExp); - void Replace(Edn::String &data); - int32_t FindLine(Edn::String &data); + void Search(etk::String &data, bool back, bool caseSensitive, bool wrap, bool regExp); + void Replace(etk::String &data); + int32_t FindLine(etk::String &data); void JumpAtLine(int32_t newLine); int32_t GetCurrentLine(void); diff --git a/jni/edn/Colorize/Colorize.cpp b/jni/edn/Colorize/Colorize.cpp index 72a49ba..1031c9f 100644 --- a/jni/edn/Colorize/Colorize.cpp +++ b/jni/edn/Colorize/Colorize.cpp @@ -23,17 +23,16 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "Colorize.h" -#include "Edn.h" +#include +#include +#include #undef __class__ #define __class__ "Colorize" -Colorize::Colorize( Edn::String &newColorName) +Colorize::Colorize( etk::String &newColorName) { m_colorFG.red=0; @@ -82,14 +81,14 @@ void Colorize::SetName(const char *newColorName) ColorName = newColorName; } -void Colorize::SetName(Edn::String &newColorName) +void Colorize::SetName(etk::String &newColorName) { //EDN_INFO("color change name : \"%s\" ==> \"%s\"",ColorName.c_str(), newColorName.c_str()); ColorName = newColorName; } -Edn::String Colorize::GetName(void) +etk::String Colorize::GetName(void) { return ColorName; } diff --git a/jni/edn/Colorize/Colorize.h b/jni/edn/Colorize/Colorize.h index 386d12a..b15a115 100644 --- a/jni/edn/Colorize/Colorize.h +++ b/jni/edn/Colorize/Colorize.h @@ -25,9 +25,7 @@ #ifndef __COLORIZE_H__ #define __COLORIZE_H__ - -#include "Edn.h" - +/* extern "C" { typedef struct { float red; @@ -35,22 +33,22 @@ extern "C" { float blue; } color_ts; } - +*/ class Colorize { public: // Constructeur Colorize(void); - Colorize(Edn::String &newColorName); + Colorize(etk::String &newColorName); ~Colorize(void); - void SetName(Edn::String &newColorName); + void SetName(etk::String &newColorName); void SetName(const char *newColorName); - Edn::String GetName(void); + etk::String GetName(void); void SetFgColor(const char *myColor); void SetBgColor(const char *myColor); - void ApplyFG(cairo_t * cr) { cairo_set_source_rgba(cr, m_colorFG.red, m_colorFG.green, m_colorFG.blue, 1); }; - void ApplyBG(cairo_t * cr) { cairo_set_source_rgba(cr, m_colorBG.red, m_colorBG.green, m_colorBG.blue, 1); }; + //void ApplyFG(cairo_t * cr) { cairo_set_source_rgba(cr, m_colorFG.red, m_colorFG.green, m_colorFG.blue, 1); }; + //void ApplyBG(cairo_t * cr) { cairo_set_source_rgba(cr, m_colorBG.red, m_colorBG.green, m_colorBG.blue, 1); }; color_ts & GetFG(void) { return m_colorFG; }; color_ts & GetBG(void) { return m_colorBG; }; @@ -65,7 +63,7 @@ class Colorize { void Display(int32_t i) { EDN_INFO(" " << i << " : \"" << ColorName.c_str() << "\"" /*<< " fg="<< m_colorFG.red <<","<< m_colorFG.green <<","<< m_colorFG.blue <<" bg="<< m_colorBG.red <<","<< m_colorBG.green <<","<< m_colorBG.blue*/ ); }; private: - Edn::String ColorName; //!< curent color Name + etk::String ColorName; //!< curent color Name color_ts m_colorFG; color_ts m_colorBG; diff --git a/jni/edn/Colorize/ColorizeManager.cpp b/jni/edn/Colorize/ColorizeManager.cpp index 07ae93b..6b25cd2 100644 --- a/jni/edn/Colorize/ColorizeManager.cpp +++ b/jni/edn/Colorize/ColorizeManager.cpp @@ -22,10 +22,10 @@ * ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "ColorizeManager.h" -#include "tinyxml.h" +#include +#include +#include +#include #define PFX "ColorizeManager " @@ -58,8 +58,8 @@ void ColorizeManager::OnMessage(int32_t id, int32_t dataID) case EDN_MSG__RELOAD_COLOR_FILE: { // Reaload File - // TODO : Check this : Pb in the recopy Edn::String element - Edn::String plop = m_fileColor; + // TODO : Check this : Pb in the recopy etk::String element + etk::String plop = m_fileColor; LoadFile(plop.c_str()); } break; @@ -67,7 +67,7 @@ void ColorizeManager::OnMessage(int32_t id, int32_t dataID) } -void ColorizeManager::LoadFile(Edn::String &xmlFilename) +void ColorizeManager::LoadFile(etk::String &xmlFilename) { LoadFile(xmlFilename.c_str()); } @@ -236,7 +236,7 @@ Colorize *ColorizeManager::Get(const char *colorName) { int32_t i; for (i=0; iGetName(); + etk::String elementName = listMyColor[i]->GetName(); if (elementName == colorName) { return listMyColor[i]; } @@ -246,7 +246,7 @@ Colorize *ColorizeManager::Get(const char *colorName) return errorColor; } -Colorize *ColorizeManager::Get(Edn::String &colorName) +Colorize *ColorizeManager::Get(etk::String &colorName) { return Get(colorName.c_str()); } @@ -265,14 +265,14 @@ bool ColorizeManager::Exist(const char *colorName) { int32_t i; for (i=0; iGetName(); + etk::String elementName = listMyColor[i]->GetName(); if (elementName == colorName) { return true; } } return false; } -bool ColorizeManager::Exist(Edn::String &colorName) +bool ColorizeManager::Exist(etk::String &colorName) { return Exist(colorName.c_str()); } @@ -282,7 +282,7 @@ void ColorizeManager::DisplayListOfColor(void) int32_t i; EDN_INFO(PFX"List of ALL COLOR : "); for (i=0; iGetName(); + //etk::String elementName = listMyColor[i]->GetName(); //EDN_INFO(i << " : \"" << elementName.c_str() << "\"" ); listMyColor[i]->Display(i); } diff --git a/jni/edn/Colorize/ColorizeManager.h b/jni/edn/Colorize/ColorizeManager.h index eafaaef..b0902ef 100644 --- a/jni/edn/Colorize/ColorizeManager.h +++ b/jni/edn/Colorize/ColorizeManager.h @@ -26,10 +26,9 @@ #ifndef __COLORIZE_MANAGER_H__ #define __COLORIZE_MANAGER_H__ -#include "Singleton.h" -#include "Colorize.h" -#include "MsgBroadcast.h" -#include "Edn.h" +#include +#include +#include typedef enum { // BASIC color for codeViewer @@ -50,9 +49,9 @@ typedef enum { -class ColorizeManager: public Singleton, public MsgBroadcast +class ColorizeManager: public etk::Singleton, public MsgBroadcast { - friend class Singleton; + friend class etk::Singleton; // specific for sigleton system... private: // Constructeur @@ -61,18 +60,18 @@ class ColorizeManager: public Singleton, public MsgBroadcast public: void OnMessage(int32_t id, int32_t dataID); public: - void LoadFile(Edn::String &xmlFilename); + void LoadFile(etk::String &xmlFilename); void LoadFile(const char * xmlFilename); Colorize * Get(const char *colorName); - Colorize * Get(Edn::String &colorName); + Colorize * Get(etk::String &colorName); color_ts & Get(basicColor_te myColor); - bool Exist(Edn::String &colorName); + bool Exist(etk::String &colorName); bool Exist(const char *colorName); void DisplayListOfColor(void); private: - Edn::String m_fileColor; - Edn::VectorType listMyColor; //!< List of ALL Color + etk::String m_fileColor; + etk::VectorType listMyColor; //!< List of ALL Color Colorize * errorColor; color_ts basicColors[COLOR_NUMBER_MAX]; }; diff --git a/jni/edn/CustumWidget/BufferView/BufferView.cpp b/jni/edn/CustumWidget/BufferView/BufferView.cpp index 534bbc5..3187fd1 100644 --- a/jni/edn/CustumWidget/BufferView/BufferView.cpp +++ b/jni/edn/CustumWidget/BufferView/BufferView.cpp @@ -23,13 +23,13 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "Display.h" -#include "BufferView.h" -#include "BufferManager.h" -#include "ColorizeManager.h" -#include "MainWindows.h" +#include +#include +#include +#include +#include +#include +#include #undef __class__ #define __class__ "BufferView" @@ -39,9 +39,9 @@ BufferView::BufferView(void) : MsgBroadcast("Buffer View", EDN_CAT_GUI) m_shawableAreaX = 0; m_shawableAreaY = 0; // Init link with the buffer Manager - m_bufferManager = BufferManager::getInstance(); - m_colorManager = ColorizeManager::getInstance(); - + //m_bufferManager = BufferManager::Get(); + //m_colorManager = ColorizeManager::Get(); +#if 0 m_widget = gtk_drawing_area_new(); gtk_widget_set_size_request( m_widget, 250, 100); @@ -74,6 +74,7 @@ BufferView::BufferView(void) : MsgBroadcast("Buffer View", EDN_CAT_GUI) # elif defined( USE_GTK_VERSION_2_0 ) g_signal_connect( G_OBJECT(m_widget), "expose_event", G_CALLBACK(CB_displayDraw), this); # endif +#endif m_selectedID = -1; } @@ -82,11 +83,12 @@ BufferView::~BufferView(void) { } - +/* GtkWidget * BufferView::GetMainWidget(void) { return m_widget; } +*/ void BufferView::OnMessage(int32_t id, int32_t dataID) { @@ -98,15 +100,15 @@ void BufferView::OnMessage(int32_t id, int32_t dataID) case EDN_MSG__BUFFER_CHANGE_NAME: case EDN_MSG__BUFFER_CHANGE_MODIFY: // change Title : - gtk_widget_queue_draw(m_widget); + //gtk_widget_queue_draw(m_widget); break; case EDN_MSG__USER_DISPLAY_CHANGE: // Redraw all the display ... - gtk_widget_queue_draw(m_widget); + //gtk_widget_queue_draw(m_widget); break; } } - +#if 0 gboolean BufferView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data) { @@ -381,5 +383,5 @@ gint BufferView::CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, */ return true; } - +#endif diff --git a/jni/edn/CustumWidget/BufferView/BufferView.h b/jni/edn/CustumWidget/BufferView/BufferView.h index f0b0fd7..4d9d9ea 100644 --- a/jni/edn/CustumWidget/BufferView/BufferView.h +++ b/jni/edn/CustumWidget/BufferView/BufferView.h @@ -25,12 +25,11 @@ #ifndef __BUFFER_VIEW_H__ #define __BUFFER_VIEW_H__ -#include "tools_debug.h" -#include "Singleton.h" -#include "CodeView.h" -#include "BufferManager.h" -#include "Display.h" -#include "MsgBroadcast.h" +#include +#include +#include +#include +#include @@ -40,8 +39,9 @@ class BufferView : public MsgBroadcast // Constructeur BufferView(void); ~BufferView(void); - GtkWidget *GetMainWidget(void); + //GtkWidget *GetMainWidget(void); void OnMessage(int32_t id, int32_t dataID); + /* // sur : GTK+ callback : static gboolean CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data); static gboolean CB_displayInit( GtkWidget *widget, gpointer data); @@ -56,12 +56,12 @@ class BufferView : public MsgBroadcast static void OnPopupEventClose(GtkWidget *menuitem, gpointer data); static void OnPopupEventSave(GtkWidget *menuitem, gpointer data); static void OnPopupEventSaveAs(GtkWidget *menuitem, gpointer data); - + */ private: - void ViewPopupMenu(GtkWidget *parrent, GdkEventButton *event, int32_t BufferID); + //void ViewPopupMenu(GtkWidget *parrent, GdkEventButton *event, int32_t BufferID); // main windows widget : - GtkWidget * m_widget; + //GtkWidget * m_widget; // récupération des proprieter général... BufferManager * m_bufferManager; ColorizeManager * m_colorManager; diff --git a/jni/edn/CustumWidget/CodeView/CodeView.cpp b/jni/edn/CustumWidget/CodeView/CodeView.cpp index b17feda..28ef486 100644 --- a/jni/edn/CustumWidget/CodeView/CodeView.cpp +++ b/jni/edn/CustumWidget/CodeView/CodeView.cpp @@ -24,16 +24,16 @@ ******************************************************************************* */ -#include "CodeView.h" +#include -#include "tools_debug.h" -#include "tools_globals.h" -#include "Display.h" -#include "CodeView.h" -#include "BufferManager.h" -#include "ColorizeManager.h" -#include "ClipBoard.h" -#include "SearchData.h" +#include +#include +#include +#include +#include +#include +#include +#include CodeView::CodeView(void) : MsgBroadcast("Code View", EDN_CAT_WORK_AREA) @@ -44,9 +44,9 @@ CodeView::CodeView(void) : MsgBroadcast("Code View", EDN_CAT_WORK_AREA) m_shawableAreaY = 0; // Init link with the buffer Manager - m_bufferManager = BufferManager::getInstance(); - m_colorManager = ColorizeManager::getInstance(); - + //m_bufferManager = BufferManager::Get(); + //m_colorManager = ColorizeManager::Get(); +/* m_widget = gtk_drawing_area_new(); gtk_widget_set_size_request( m_widget, 200, 100); @@ -79,18 +79,19 @@ CodeView::CodeView(void) : MsgBroadcast("Code View", EDN_CAT_WORK_AREA) # elif defined( USE_GTK_VERSION_2_0 ) g_signal_connect( G_OBJECT(m_widget), "expose_event", G_CALLBACK(CB_displayDraw), this); # endif +*/ } CodeView::~CodeView(void) { } - +/* GtkWidget * CodeView::GetMainWidget(void) { return m_widget; } - +*/ void CodeView::OnMessage(int32_t id, int32_t dataID) { @@ -138,21 +139,21 @@ void CodeView::OnMessage(int32_t id, int32_t dataID) break; case EDN_MSG__CURRENT_FIND_PREVIOUS: { - Edn::String myDataString; + etk::String myDataString; SearchData::GetSearch(myDataString); m_bufferManager->Get(m_bufferID)->Search(myDataString, true, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() ); } break; case EDN_MSG__CURRENT_FIND_NEXT: { - Edn::String myDataString; + etk::String myDataString; SearchData::GetSearch(myDataString); m_bufferManager->Get(m_bufferID)->Search(myDataString, false, SearchData::GetCase(), SearchData::GetWrap(), SearchData::GetRegExp() ); } break; case EDN_MSG__CURRENT_REPLACE: { - Edn::String myDataString; + etk::String myDataString; SearchData::GetReplace(myDataString); m_bufferManager->Get(m_bufferID)->Replace(myDataString); } @@ -184,11 +185,11 @@ void CodeView::OnMessage(int32_t id, int32_t dataID) break; } // Force redraw of the widget - gtk_widget_queue_draw(m_widget); + //gtk_widget_queue_draw(m_widget); } - +#if 0 gboolean CodeView::CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data) { CodeView * self = reinterpret_cast(data); @@ -416,6 +417,6 @@ gint CodeView::CB_mouseScrollEvent( GtkWidget *widget, GdkEventScroll *event, gp } - +#endif diff --git a/jni/edn/CustumWidget/CodeView/CodeView.h b/jni/edn/CustumWidget/CodeView/CodeView.h index 2e5ea48..4d36a4f 100644 --- a/jni/edn/CustumWidget/CodeView/CodeView.h +++ b/jni/edn/CustumWidget/CodeView/CodeView.h @@ -26,12 +26,11 @@ #ifndef __CODE_VIEW_H__ #define __CODE_VIEW_H__ -#include "tools_debug.h" -#include "Singleton.h" -#include "CodeView.h" -#include "BufferManager.h" -#include "Display.h" -#include "MsgBroadcast.h" +#include +#include +#include +#include +#include class CodeView : public MsgBroadcast { @@ -40,6 +39,7 @@ class CodeView : public MsgBroadcast CodeView(void); ~CodeView(void); void OnMessage(int32_t id, int32_t dataID); + /* GtkWidget *GetMainWidget(void); // sur : GTK+ callback : static gboolean CB_displayDraw( GtkWidget *widget, GdkEventExpose *event, gpointer data); @@ -50,10 +50,11 @@ class CodeView : public MsgBroadcast static gint CB_mouseButtonEvent(GtkWidget *widget, GdkEventButton *event, gpointer data); static gint CB_mouseMotionEvent( GtkWidget *widget, GdkEventMotion *event, gpointer data); static gint CB_mouseScrollEvent( GtkWidget *widget, GdkEventScroll *event, gpointer data); + */ private: // main windows widget : - GtkWidget * m_widget; + //GtkWidget * m_widget; // récupération des proprieter général... BufferManager * m_bufferManager; ColorizeManager * m_colorManager; diff --git a/jni/edn/CustumWidget/MainAreaView/MainAreaView.cpp b/jni/edn/CustumWidget/MainAreaView/MainAreaView.cpp deleted file mode 100644 index 964e32e..0000000 --- a/jni/edn/CustumWidget/MainAreaView/MainAreaView.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/** - ******************************************************************************* - * @file Search.h - * @brief Editeur De N'ours : Search system (header) - * @author Edouard DUPIN - * @date 03/01/2011 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - -#ifndef __SEARCH_H__ -#define __SEARCH_H__ - -#include "tools_debug.h" -#include "Singleton.h" - - - -class MainAreaView: public Singleton -{ - friend class Singleton; - // specific for sigleton system... - private: - // Constructeur - MainAreaView(void); - ~MainAreaView(void); - - public: - GtkWidget * GetWidget(void); - void SplitV(void); // split current window vertically (max 1 by section) - void SplitH(void); // split current window horizontaly (max 3) - void Remove(void); // remove current selected element - //ViewArea * GetCurent(void); // Get a pointer on the current displayed area - - - private: - GtkWidget * m_localDialog; //!< local dialog element - ViewArea * m_EntrySearch[6]; - uint8_t m_CurentSelected -}; - - -#endif - diff --git a/jni/edn/CustumWidget/MainAreaView/MainAreaView.h b/jni/edn/CustumWidget/MainAreaView/MainAreaView.h deleted file mode 100644 index e69de29..0000000 diff --git a/jni/edn/GuiTools/MainWindows/MainWindows.cpp b/jni/edn/GuiTools/MainWindows/MainWindows.cpp index b1a8995..15f4f50 100644 --- a/jni/edn/GuiTools/MainWindows/MainWindows.cpp +++ b/jni/edn/GuiTools/MainWindows/MainWindows.cpp @@ -23,25 +23,25 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "MainWindows.h" -#include "CodeView.h" -#include "ClipBoard.h" -#include "BufferView.h" -#include "AccelKey.h" +#include +#include +#include +#include +#include +#include +#include #undef __class__ #define __class__ "MainWindows" MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI) { - +#if 0 m_mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); // select the program icone GError *err = NULL; - Edn::String iconeFile; + etk::String iconeFile; #ifdef NDEBUG iconeFile = "/usr/share/edn/images/icone.png"; #else @@ -79,7 +79,7 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI) GtkWidget *hboxMenu = gtk_hbox_new (FALSE, 0); gtk_box_pack_start( GTK_BOX (vbox), hboxMenu, FALSE, FALSE, 0); // Add Exit boutton - Edn::String ExitIconeFile; + etk::String ExitIconeFile; #ifdef NDEBUG ExitIconeFile = "/usr/share/edn/images/delete-24px.png"; #else @@ -140,7 +140,7 @@ MainWindows::MainWindows(void) : MsgBroadcast("Main Windows", EDN_CAT_GUI) // recursive version of gtk_widget_show gtk_widget_show_all(m_mainWindow); - +#endif } MainWindows::~MainWindows(void) @@ -154,9 +154,9 @@ MainWindows::~MainWindows(void) -void MainWindows::SetTitle(Edn::File &fileName, bool isModify) +void MainWindows::SetTitle(etk::File &fileName, bool isModify) { - Edn::String tmp = ""; + etk::String tmp = ""; if (fileName.GetShortFilename() != "") { tmp += fileName.GetShortFilename(); tmp += " - "; @@ -164,7 +164,7 @@ void MainWindows::SetTitle(Edn::File &fileName, bool isModify) tmp += " - "; } tmp += "Edn"; - gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str()); + //gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str()); tmp = " "; if (fileName.GetShortFilename() != "") { tmp += fileName.GetFolder(); @@ -173,16 +173,16 @@ void MainWindows::SetTitle(Edn::File &fileName, bool isModify) } else { tmp += "Edn"; } - tmp += " "; - gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str()); + tmp += " "; + //gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str()); } void MainWindows::SetNoTitle(void) { - Edn::String tmp = "Edn"; - gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str()); - gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str()); + etk::String tmp = "Edn"; + //gtk_window_set_title(GTK_WINDOW(m_mainWindow), tmp.c_str()); + //gtk_label_set_text(GTK_LABEL(m_internalTitleLabel), tmp.c_str()); } void MainWindows::OnMessage(int32_t id, int32_t dataID) @@ -195,16 +195,18 @@ void MainWindows::OnMessage(int32_t id, int32_t dataID) if (-1 == dataID) { SetNoTitle(); } else { + /* Buffer *mybuf = BufferManager::getInstance()->Get(dataID); if (NULL != mybuf) { - Edn::File plop = mybuf->GetFileName(); + etk::File plop = mybuf->GetFileName(); SetTitle(plop, mybuf->IsModify() ); } + */ } break; } } - +/* bool MainWindows::OnQuit(GtkWidget *widget, gpointer data) { //MainWindows * self = reinterpret_cast(data); @@ -232,7 +234,7 @@ gboolean MainWindows::OnStateChange(GtkWidget *widget, GdkEvent* event, gpointer } } } - +*/ diff --git a/jni/edn/GuiTools/MainWindows/MainWindows.h b/jni/edn/GuiTools/MainWindows/MainWindows.h index 288f2aa..b31f696 100644 --- a/jni/edn/GuiTools/MainWindows/MainWindows.h +++ b/jni/edn/GuiTools/MainWindows/MainWindows.h @@ -24,39 +24,40 @@ */ -#include "tools_debug.h" -#include "Singleton.h" -#include "MsgBroadcast.h" +#include +#include +#include -#include "CodeView.h" -#include "BufferView.h" -#include "BufferManager.h" -#include "MenuBar.h" -#include "StatusBar.h" -#include "ToolBar.h" +#include +#include +#include +#include +#include +#include #ifndef __MAIN_WINDOWS_H__ #define __MAIN_WINDOWS_H__ -class MainWindows: public Singleton, public MsgBroadcast +class MainWindows: public etk::Singleton, public MsgBroadcast { - friend class Singleton; + friend class etk::Singleton; // specific for sigleton system... private: // Constructeur MainWindows(void); ~MainWindows(void); public: - GtkWidget * GetWidget(void) { return m_mainWindow;}; + //GtkWidget * GetWidget(void) { return m_mainWindow;}; void OnMessage(int32_t id, int32_t dataID); - static bool OnQuit(GtkWidget *widget, gpointer data); - static gboolean OnStateChange(GtkWidget *widget, GdkEvent* event, gpointer data); + //static bool OnQuit(GtkWidget *widget, gpointer data); + //static gboolean OnStateChange(GtkWidget *widget, GdkEvent* event, gpointer data); private: - void SetTitle(Edn::File &fileName, bool isModify); + void SetTitle(etk::File &fileName, bool isModify); void SetNoTitle(void); // main windows widget : + /* GtkWidget * m_mainWindow; GtkWidget * m_internalTitleLabel; BufferView m_BufferView; @@ -64,6 +65,7 @@ class MainWindows: public Singleton, public MsgBroadcast MenuBar m_MenuBar; StatusBar m_StatusBar; ToolBar m_ToolBar; + */ }; #endif diff --git a/jni/edn/GuiTools/MainWindows/MenuBar.cpp b/jni/edn/GuiTools/MainWindows/MenuBar.cpp index 40cd309..8b8a7d2 100644 --- a/jni/edn/GuiTools/MainWindows/MenuBar.cpp +++ b/jni/edn/GuiTools/MainWindows/MenuBar.cpp @@ -24,12 +24,12 @@ */ -#include "tools_debug.h" -#include "MenuBar.h" -#include "ClipBoard.h" -#include "charset.h" -#include "ColorizeManager.h" - +#include +#include +#include +#include +#include +#if 0 #define MENU_MSG const char * MSG_TogleDisplayChar = "Request a Togle of char displaying"; const char * MSG_TogleDisplayEOL = "Request a Togle of displaying EndOfLine"; @@ -79,7 +79,7 @@ static void CB_menuInternal(GtkMenuItem *menu_item, gpointer data) GeneralSendMessage(EDN_MSG__CURRENT_SET_CHARSET, EDN_CHARSET_UTF8); } else if (myPointer == MSG_LoadColorWhite) { ColorizeManager * myColorSystem = ColorizeManager::getInstance(); - Edn::String homedir; + etk::String homedir; # ifdef NDEBUG homedir = "/usr/share/edn/"; # else @@ -89,7 +89,7 @@ static void CB_menuInternal(GtkMenuItem *menu_item, gpointer data) myColorSystem->LoadFile(homedir); } else if (myPointer == MSG_LoadColorBlack) { ColorizeManager * myColorSystem = ColorizeManager::getInstance(); - Edn::String homedir; + etk::String homedir; # ifdef NDEBUG homedir = "/usr/share/edn/"; # else @@ -217,7 +217,7 @@ class MenuBarMain GtkWidget * m_parent; GtkWidget * m_menu; GtkWidget * m_menuListe; - Edn::VectorType m_message; + etk::VectorType m_message; }; #undef __class__ @@ -383,4 +383,4 @@ void MenuBar::OnMessage(int32_t id, int32_t dataID) //EDN_INFO("ReceiveMessage"); } - +#endif diff --git a/jni/edn/GuiTools/MainWindows/MenuBar.h b/jni/edn/GuiTools/MainWindows/MenuBar.h index 6df0a9d..01ba9e9 100644 --- a/jni/edn/GuiTools/MainWindows/MenuBar.h +++ b/jni/edn/GuiTools/MainWindows/MenuBar.h @@ -23,30 +23,32 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "MsgBroadcast.h" -#include "VectorType.h" -#include "AccelKey.h" +#include +#include +#include +#include +#include #ifndef __MENU_BAR_H__ #define __MENU_BAR_H__ -class MenuBarMain; +//class MenuBarMain; class MenuBar: public MsgBroadcast { public: // Constructeur - MenuBar(void); - ~MenuBar(void); - GtkWidget * GetWidget(void) { return m_mainWidget; }; - void OnMessage(int32_t id, int32_t dataID); + MenuBar(void) : MsgBroadcast("Menu bar", EDN_CAT_GUI){}; + ~MenuBar(void) {}; + //GtkWidget * GetWidget(void) { return m_mainWidget; }; + void OnMessage(int32_t id, int32_t dataID) {}; private: + /* GtkWidget * m_mainWidget; GtkAccelGroup * m_accelGroup; - Edn::VectorType m_listMenu; + etk::VectorType m_listMenu; + */ }; diff --git a/jni/edn/GuiTools/MainWindows/StatusBar.cpp b/jni/edn/GuiTools/MainWindows/StatusBar.cpp index ff3e678..1710b13 100644 --- a/jni/edn/GuiTools/MainWindows/StatusBar.cpp +++ b/jni/edn/GuiTools/MainWindows/StatusBar.cpp @@ -23,13 +23,14 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "StatusBar.h" +#include +#include StatusBar::StatusBar(void) : MsgBroadcast("Status bar", EDN_CAT_GUI) { +/* m_mainWidget = gtk_statusbar_new(); // pas très bien compris pourquoi mais ca marche... m_iContextId = gtk_statusbar_get_context_id(GTK_STATUSBAR(m_mainWidget), "ExitMsg"); @@ -37,6 +38,7 @@ StatusBar::StatusBar(void) : MsgBroadcast("Status bar", EDN_CAT_GUI) gtk_statusbar_push(GTK_STATUSBAR (m_mainWidget), GPOINTER_TO_INT(m_iContextId), "Edn Editeur de n'ours"); // Supression du précédent message : //gtk_statusbar_pop(GTK_STATUSBAR(m_mainWidget), GPOINTER_TO_INT(m_iContextId)); +*/ } StatusBar::~StatusBar(void) diff --git a/jni/edn/GuiTools/MainWindows/StatusBar.h b/jni/edn/GuiTools/MainWindows/StatusBar.h index a9af6cc..23df565 100644 --- a/jni/edn/GuiTools/MainWindows/StatusBar.h +++ b/jni/edn/GuiTools/MainWindows/StatusBar.h @@ -23,7 +23,7 @@ ******************************************************************************* */ -#include "MsgBroadcast.h" +#include #ifndef __STATUS_BAR_H__ #define __STATUS_BAR_H__ @@ -34,12 +34,12 @@ class StatusBar: public MsgBroadcast // Constructeur StatusBar(void); ~StatusBar(void); - GtkWidget * GetWidget(void) { return m_mainWidget; }; + //GtkWidget * GetWidget(void) { return m_mainWidget; }; void OnMessage(int32_t id, int32_t dataID); private: - GtkWidget * m_mainWidget; - guint m_iContextId; + //GtkWidget * m_mainWidget; + //guint m_iContextId; }; diff --git a/jni/edn/GuiTools/MainWindows/ToolBar.cpp b/jni/edn/GuiTools/MainWindows/ToolBar.cpp index 0f9bd67..464378c 100644 --- a/jni/edn/GuiTools/MainWindows/ToolBar.cpp +++ b/jni/edn/GuiTools/MainWindows/ToolBar.cpp @@ -23,10 +23,11 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "ToolBar.h" -#include "ClipBoard.h" +#include +#include +#include +/* static void CB_menuGenerique(GtkMenuItem *menu_item, gpointer data) { //EDN_INFO("basic menue_event"); @@ -34,11 +35,11 @@ static void CB_menuGenerique(GtkMenuItem *menu_item, gpointer data) // broacast message : GeneralSendMessage(msg->msgId, msg->dataId); } - - +*/ ToolBar::ToolBar(void) : MsgBroadcast("Tool bar", EDN_CAT_GUI) { +/* m_mainWidget = gtk_toolbar_new(); # ifdef USE_GTK_VERSION_2_0 gtk_toolbar_set_orientation(GTK_TOOLBAR(m_mainWidget), GTK_ORIENTATION_VERTICAL); @@ -55,6 +56,7 @@ ToolBar::ToolBar(void) : MsgBroadcast("Tool bar", EDN_CAT_GUI) Add(GTK_STOCK_SAVE_AS, "Enregistrer sous", EDN_MSG__CURRENT_SAVE_AS); AddSeparator(); Add(GTK_STOCK_QUIT, "Quitter"); +*/ } ToolBar::~ToolBar(void) @@ -66,7 +68,7 @@ void ToolBar::OnMessage(int32_t id, int32_t dataID) { //EDN_INFO("ReceiveMessage"); } - +/* void ToolBar::AddSeparator(void) { # ifdef USE_GTK_VERSION_3_0 @@ -87,7 +89,7 @@ void ToolBar::Add(const char * title, const char * labelHelp, messageType_te id, gtk_toolbar_insert_stock(GTK_TOOLBAR(m_mainWidget), title, labelHelp, NULL, G_CALLBACK(CB_menuGenerique), message, -1); # endif } - +*/ diff --git a/jni/edn/GuiTools/MainWindows/ToolBar.h b/jni/edn/GuiTools/MainWindows/ToolBar.h index fcbadb1..f192cae 100644 --- a/jni/edn/GuiTools/MainWindows/ToolBar.h +++ b/jni/edn/GuiTools/MainWindows/ToolBar.h @@ -23,7 +23,7 @@ ******************************************************************************* */ -#include "MsgBroadcast.h" +#include #ifndef __TOOL_BAR_H__ #define __TOOL_BAR_H__ @@ -35,14 +35,14 @@ class ToolBar: public MsgBroadcast // Constructeur ToolBar(void); ~ToolBar(void); - GtkWidget * GetWidget(void) { return m_mainWidget; }; + //GtkWidget * GetWidget(void) { return m_mainWidget; }; void OnMessage(int32_t id, int32_t dataID); private: - void AddSeparator(void); - void Add(const char * title, const char * labelHelp, messageType_te id = EDN_MSG__NONE, bool enable = false); - GtkWidget * m_mainWidget; - Edn::VectorType m_message; + //void AddSeparator(void); + //void Add(const char * title, const char * labelHelp, messageType_te id = EDN_MSG__NONE, bool enable = false); + //GtkWidget * m_mainWidget; + //etk::VectorType m_message; }; diff --git a/jni/edn/GuiTools/Search/Search.cpp b/jni/edn/GuiTools/Search/Search.cpp index 5a204d1..05d0188 100644 --- a/jni/edn/GuiTools/Search/Search.cpp +++ b/jni/edn/GuiTools/Search/Search.cpp @@ -36,26 +36,28 @@ Search::Search(void) - : m_localDialog(NULL), + /*: m_localDialog(NULL), m_searchLabel(NULL), m_searchEntry(NULL), m_replaceLabel(NULL), m_replaceEntry(NULL), m_CkMatchCase(NULL), - m_CkWrapAround(NULL) + m_CkWrapAround(NULL) */ { // nothing to do ... } Search::~Search(void) { +/* if (NULL!=m_localDialog) { gtk_widget_hide(m_localDialog); gtk_widget_destroy(m_localDialog); m_localDialog = NULL; } +*/ } - +/* void Search::Display(GtkWindow *parent) { if(NULL == m_localDialog) { @@ -193,7 +195,7 @@ void Search::Display(GtkWindow *parent) gtk_widget_set_sensitive(m_CkMatchCase, true); } // Remove data form the search - Edn::String myDataString = ""; + etk::String myDataString = ""; SearchData::SetSearch(myDataString); gtk_entry_set_text(GTK_ENTRY(m_searchEntry), myDataString.c_str()); if (0 == strlen(myDataString.c_str())) { @@ -228,21 +230,25 @@ void Search::Display(GtkWindow *parent) gtk_widget_hide(m_CkRegularExpression); } } +*/ void Search::Destroy(void) { +/* if (NULL!=m_localDialog) { gtk_widget_destroy(m_localDialog); m_localDialog = NULL; } +*/ } void Search::Hide(void) { - gtk_widget_hide(m_localDialog); + //gtk_widget_hide(m_localDialog); } +/* void Search::OnButtonPrevious(GtkWidget *widget, gpointer data) { //EDN_INFO("CALLBACK"); @@ -315,7 +321,7 @@ void Search::OnEntrySearchChange(GtkWidget *widget, gpointer data) // update research data const char *testData = gtk_entry_get_text(GTK_ENTRY(widget)); if (NULL != testData) { - Edn::String myDataString = testData; + etk::String myDataString = testData; SearchData::SetSearch(myDataString); if (0 == strlen(testData)) { self->m_haveSearchData = false; @@ -341,7 +347,7 @@ void Search::OnEntryReplaceChange(GtkWidget *widget, gpointer data) // update replace data const char *testData = gtk_entry_get_text(GTK_ENTRY(widget)); if (NULL != testData) { - Edn::String myDataString = testData; + etk::String myDataString = testData; SearchData::SetReplace(myDataString); if (0 == strlen(testData)) { self->m_haveReplaceData = false; @@ -357,3 +363,4 @@ void Search::OnEntryReplaceChange(GtkWidget *widget, gpointer data) } } } +*/ diff --git a/jni/edn/GuiTools/Search/Search.h b/jni/edn/GuiTools/Search/Search.h index 38dcba4..ab25a4f 100644 --- a/jni/edn/GuiTools/Search/Search.h +++ b/jni/edn/GuiTools/Search/Search.h @@ -26,13 +26,13 @@ #ifndef __SEARCH_H__ #define __SEARCH_H__ -#include "tools_debug.h" -#include "Singleton.h" +#include +#include -class Search: public Singleton +class Search: public etk::Singleton { - friend class Singleton; + friend class etk::Singleton; // specific for sigleton system... private: // Constructeur @@ -41,9 +41,9 @@ class Search: public Singleton public: void Destroy(void); - void Display(GtkWindow *parent); + //void Display(GtkWindow *parent); void Hide(void); - +/* private: GtkWidget * m_localDialog; //!< local dialog element // entry @@ -75,7 +75,7 @@ class Search: public Singleton static void OnCheckBoxEventRegExp(GtkWidget *widget, gpointer user_data); static void OnEntrySearchChange(GtkWidget *widget, gpointer user_data); static void OnEntryReplaceChange(GtkWidget *widget, gpointer user_data); - +*/ }; diff --git a/jni/edn/GuiTools/Search/SearchData.cpp b/jni/edn/GuiTools/Search/SearchData.cpp index 5238fcd..35d7fed 100644 --- a/jni/edn/GuiTools/Search/SearchData.cpp +++ b/jni/edn/GuiTools/Search/SearchData.cpp @@ -23,22 +23,21 @@ ******************************************************************************* */ -#include "tools_globals.h" -#include "SearchData.h" -#include "Edn.h" +#include +#include #undef __class__ #define __class__ "SearchData" -static Edn::String m_findRequest = ""; +static etk::String m_findRequest = ""; -void SearchData::SetSearch(Edn::String &myData) +void SearchData::SetSearch(etk::String &myData) { m_findRequest = myData; } -void SearchData::GetSearch(Edn::String &myData) +void SearchData::GetSearch(etk::String &myData) { myData = m_findRequest; } @@ -50,12 +49,12 @@ bool SearchData::IsSearchEmpty(void) return true; } -static Edn::String m_replaceRequest = ""; -void SearchData::SetReplace(Edn::String &myData) +static etk::String m_replaceRequest = ""; +void SearchData::SetReplace(etk::String &myData) { m_replaceRequest = myData; } -void SearchData::GetReplace(Edn::String &myData) +void SearchData::GetReplace(etk::String &myData) { myData = m_replaceRequest; } diff --git a/jni/edn/GuiTools/Search/SearchData.h b/jni/edn/GuiTools/Search/SearchData.h index 05e8e8f..a233392 100644 --- a/jni/edn/GuiTools/Search/SearchData.h +++ b/jni/edn/GuiTools/Search/SearchData.h @@ -26,16 +26,15 @@ #ifndef __SEARCH_DATA_H__ #define __SEARCH_DATA_H__ -#include "tools_debug.h" -#include "Edn.h" +#include namespace SearchData { - void SetSearch(Edn::String &myData); - void GetSearch(Edn::String &myData); + void SetSearch(etk::String &myData); + void GetSearch(etk::String &myData); bool IsSearchEmpty(void); - void SetReplace(Edn::String &myData); - void GetReplace(Edn::String &myData); + void SetReplace(etk::String &myData); + void GetReplace(etk::String &myData); bool IsReplaceEmpty(void); void SetCase(bool value); bool GetCase(void); diff --git a/jni/edn/GuiTools/WindowsManager/WindowsManager.cpp b/jni/edn/GuiTools/WindowsManager/WindowsManager.cpp index 9f2e323..acbc7ed 100644 --- a/jni/edn/GuiTools/WindowsManager/WindowsManager.cpp +++ b/jni/edn/GuiTools/WindowsManager/WindowsManager.cpp @@ -24,12 +24,11 @@ */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "WindowsManager.h" -#include "MainWindows.h" -#include "Edn.h" -#include "Search.h" +#include +#include +#include +#include +#include #undef __class__ @@ -65,6 +64,7 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID) { switch (id) { + /* case EDN_MSG__BUFFER_CHANGE_CURRENT: m_currentBufferID = dataID; break; @@ -101,13 +101,13 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID) if( -1 != m_currentBufferID && true == myBufferManager->Exist(m_currentBufferID) ) { - Edn::File fileName = myBufferManager->Get(m_currentBufferID)->GetFileName(); + etk::File fileName = myBufferManager->Get(m_currentBufferID)->GetFileName(); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), fileName.GetFolder().c_str()); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fileName.GetShortFilename().c_str()); } if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { - Edn::File myfilename; + etk::File myfilename; myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog)); if (false == myBufferManager->Exist(myfilename) ) { @@ -131,7 +131,7 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID) idSelected = dataID; } Buffer *myBuffer = BufferManager::getInstance()->Get(idSelected); - Edn::String tmpString = "Save as file : "; + etk::String tmpString = "Save as file : "; tmpString += myBuffer->GetFileName().GetShortFilename().c_str(); GtkWidget *dialog = gtk_file_chooser_dialog_new( tmpString.c_str(), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, @@ -142,7 +142,7 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID) gtk_window_set_skip_pager_hint(GTK_WINDOW(dialog), TRUE); if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { - Edn::String myfilename; + etk::String myfilename; myfilename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog)); myBuffer->SetFileName(myfilename); @@ -311,10 +311,10 @@ void WindowsManager::OnMessage(int32_t id, int32_t dataID) gtk_widget_destroy (p_dialog); break; } - - } break; - + */ + default: + break; } } \ No newline at end of file diff --git a/jni/edn/GuiTools/WindowsManager/WindowsManager.h b/jni/edn/GuiTools/WindowsManager/WindowsManager.h index 042262b..3b56089 100644 --- a/jni/edn/GuiTools/WindowsManager/WindowsManager.h +++ b/jni/edn/GuiTools/WindowsManager/WindowsManager.h @@ -26,13 +26,13 @@ #ifndef __WINDOWS_MANAGER_H__ #define __WINDOWS_MANAGER_H__ -#include "Singleton.h" -#include "MsgBroadcast.h" -#include "MainWindows.h" +#include +#include +#include -class WindowsManager: public Singleton, public MsgBroadcast +class WindowsManager: public etk::Singleton, public MsgBroadcast { - friend class Singleton; + friend class etk::Singleton; // specific for sigleton system... private: // Constructeur diff --git a/jni/edn/Highlight/Highlight.cpp b/jni/edn/Highlight/Highlight.cpp index af77814..bf70824 100644 --- a/jni/edn/Highlight/Highlight.cpp +++ b/jni/edn/Highlight/Highlight.cpp @@ -23,17 +23,17 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "Highlight.h" -#include "tinyxml.h" +#include +#include +#include +#include #undef __class__ #define __class__ "Highlight" -void Highlight::ParseRules(TiXmlNode *child, Edn::VectorType &mListPatern, int32_t level) +void Highlight::ParseRules(TiXmlNode *child, etk::VectorType &mListPatern, int32_t level) { // Create the patern ... HighlightPattern *myPattern = new HighlightPattern(); @@ -45,7 +45,7 @@ void Highlight::ParseRules(TiXmlNode *child, Edn::VectorType -Highlight::Highlight(Edn::String &xmlFilename) +Highlight::Highlight(etk::String &xmlFilename) { TiXmlDocument XmlDocument; @@ -72,7 +72,7 @@ Highlight::Highlight(Edn::String &xmlFilename) const char *myData = child->ToElement()->GetText(); if (NULL != myData) { //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData); - Edn::String * myEdnData = new Edn::String(myData); + etk::String * myEdnData = new etk::String(myData); m_listExtentions.PushBack(myEdnData); } } else if (!strcmp(child->Value(), "pass1")) { @@ -150,7 +150,7 @@ void Highlight::ReloadColor(void) } } -bool Highlight::HasExtention(Edn::String &ext) +bool Highlight::HasExtention(etk::String &ext) { int32_t i; for (i=0; i &metaData, + etk::VectorType &metaData, int32_t addingPos, EdnVectorBuf &buffer) { @@ -270,7 +270,7 @@ void Highlight::Parse(int32_t start, */ void Highlight::Parse2(int32_t start, int32_t stop, - Edn::VectorType &metaData, + etk::VectorType &metaData, EdnVectorBuf &buffer) { //EDN_DEBUG("Parse element 0 => " << m_listHighlightPass2.size() << " ==> position search: (" << start << "," << stop << ")" ); diff --git a/jni/edn/Highlight/Highlight.h b/jni/edn/Highlight/Highlight.h index 2a174bf..14744ec 100644 --- a/jni/edn/Highlight/Highlight.h +++ b/jni/edn/Highlight/Highlight.h @@ -23,7 +23,6 @@ ******************************************************************************* */ -#include "Edn.h" #ifndef __HIGHLIGHT_H__ #define __HIGHLIGHT_H__ @@ -43,35 +42,35 @@ extern "C" { } colorInformation_ts; } -#include "HighlightPattern.h" -#include "Colorize.h" -#include "EdnVectorBuf.h" -#include "tinyxml.h" +#include +#include +#include +#include class Highlight { public: // Constructeur - Highlight(Edn::String &xmlFilename); + Highlight(etk::String &xmlFilename); ~Highlight(void); - bool HasExtention(Edn::String &ext); - bool FileNameCompatible(Edn::File &fileName); + bool HasExtention(etk::String &ext); + bool FileNameCompatible(etk::File &fileName); void Display(void); void ReloadColor(void); void Parse(int32_t start, int32_t stop, - Edn::VectorType &metaData, + etk::VectorType &metaData, int32_t addingPos, EdnVectorBuf &buffer); void Parse2(int32_t start, int32_t stop, - Edn::VectorType &metaData, + etk::VectorType &metaData, EdnVectorBuf &buffer); private: - void ParseRules(TiXmlNode *child, Edn::VectorType &mListPatern, int32_t level); - Edn::String m_styleName; //!< curent style name (like "c++" or "c" or "script Bash") - Edn::VectorType m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" - Edn::VectorType m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer) - Edn::VectorType m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) ) + void ParseRules(TiXmlNode *child, etk::VectorType &mListPatern, int32_t level); + etk::String m_styleName; //!< curent style name (like "c++" or "c" or "script Bash") + etk::VectorType m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" + etk::VectorType m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 ==> when we load and wride data on the buffer) + etk::VectorType m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 ==> When we display the buffer( only the display area (100 lines)) ) }; diff --git a/jni/edn/Highlight/HighlightManager.cpp b/jni/edn/Highlight/HighlightManager.cpp index fc45ee7..0eff021 100644 --- a/jni/edn/Highlight/HighlightManager.cpp +++ b/jni/edn/Highlight/HighlightManager.cpp @@ -23,9 +23,9 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "HighlightManager.h" +#include +#include +#include #undef __class__ #define __class__ "HighlightManager" @@ -65,7 +65,7 @@ void HighlightManager::OnMessage(int32_t id, int32_t dataID) } } -Highlight *HighlightManager::Get(Edn::File &fileName) +Highlight *HighlightManager::Get(etk::File &fileName) { int32_t i; for (i=0; i +#include +#include -class HighlightManager: public Singleton, public MsgBroadcast +class HighlightManager: public etk::Singleton, public MsgBroadcast { - friend class Singleton; + friend class etk::Singleton; // specific for sigleton system... private: // Constructeur @@ -46,11 +46,11 @@ class HighlightManager: public Singleton, public MsgBroadcast void OnMessage(int32_t id, int32_t dataID); public: void loadLanguages(void); - Highlight * Get(Edn::File &fileName); - bool Exist(Edn::File &fileName); + Highlight * Get(etk::File &fileName); + bool Exist(etk::File &fileName); private: - Edn::VectorType listHighlight; //!< List of ALL hightlight modules + etk::VectorType listHighlight; //!< List of ALL hightlight modules }; #endif diff --git a/jni/edn/Highlight/HighlightPattern.cpp b/jni/edn/Highlight/HighlightPattern.cpp index 1e357a9..46a285b 100644 --- a/jni/edn/Highlight/HighlightPattern.cpp +++ b/jni/edn/Highlight/HighlightPattern.cpp @@ -22,10 +22,10 @@ * ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "HighlightPattern.h" -#include "ColorizeManager.h" +#include +#include +#include +#include #undef __class__ @@ -39,8 +39,8 @@ HighlightPattern::HighlightPattern(void) m_multiline = false; ColorizeManager *myColorManager = ColorizeManager::getInstance(); m_color = myColorManager->Get("normal"); - m_regExpStart = new EdnRegExp(); - m_regExpStop = new EdnRegExp(); + m_regExpStart = new etk::RegExp(); + m_regExpStop = new etk::RegExp(); m_escapeChar = 0; } @@ -50,12 +50,12 @@ HighlightPattern::~HighlightPattern(void) delete(m_regExpStop); } -void HighlightPattern::SetPaternStart(Edn::String ®Exp) +void HighlightPattern::SetPaternStart(etk::String ®Exp) { m_regExpStart->SetRegExp(regExp); } -void HighlightPattern::SetPaternStop(Edn::String ®Exp) +void HighlightPattern::SetPaternStop(etk::String ®Exp) { if (regExp.Size() != 0) { m_regExpStop->SetRegExp(regExp); @@ -65,7 +65,7 @@ void HighlightPattern::SetPaternStop(Edn::String ®Exp) } } -void HighlightPattern::SetEscapeChar(Edn::String &EscapeChar) +void HighlightPattern::SetEscapeChar(etk::String &EscapeChar) { if (EscapeChar.Size()>0) { m_escapeChar = EscapeChar.c_str()[0]; @@ -75,7 +75,7 @@ void HighlightPattern::SetEscapeChar(Edn::String &EscapeChar) } -void HighlightPattern::SetColor(Edn::String &colorName) +void HighlightPattern::SetColor(etk::String &colorName) { m_colorName = colorName; ColorizeManager *myColorManager = ColorizeManager::getInstance(); @@ -140,7 +140,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level) //-------------------------------------------------------------------------------------------- // process attribute const char *highLightName = child->ToElement()->Attribute("name"); - Edn::String myEdnDataTmp = "???"; + etk::String myEdnDataTmp = "???"; if (NULL != highLightName) { myEdnDataTmp = highLightName; } @@ -152,7 +152,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level) const char *myData = xChild->GetText(); if (myData) { //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); - Edn::String myEdnData = myData; + etk::String myEdnData = myData; SetColor(myEdnData); } } @@ -161,7 +161,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level) const char *myData = xChild->GetText(); if (myData) { //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); - Edn::String myEdnData = myData; + etk::String myEdnData = myData; SetPaternStart(myEdnData); } } @@ -170,7 +170,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level) const char *myData = xChild->GetText(); if (myData) { //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); - Edn::String myEdnData = myData; + etk::String myEdnData = myData; SetPaternStop(myEdnData); } } @@ -179,7 +179,7 @@ void HighlightPattern::ParseRules(TiXmlNode *child, int32_t level) const char *myData = xChild->GetText(); if (myData) { //EDN_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); - Edn::String myEdnData = myData; + etk::String myEdnData = myData; SetEscapeChar(myEdnData); } } diff --git a/jni/edn/Highlight/HighlightPattern.h b/jni/edn/Highlight/HighlightPattern.h index e8bcd40..9663e7a 100644 --- a/jni/edn/Highlight/HighlightPattern.h +++ b/jni/edn/Highlight/HighlightPattern.h @@ -23,19 +23,19 @@ ******************************************************************************* */ -#include "Highlight.h" +#include #ifndef __HIGHLIGHT_PATTERN_H__ #define __HIGHLIGHT_PATTERN_H__ class HighlightPattern; -#include "Edn.h" -#include "RegExp.h" -#include "Colorize.h" -#include "VectorType.h" -#include "tinyxml.h" -#include "EdnVectorBuf.h" + +#include +#include +#include +#include +#include typedef enum { HLP_FIND_ERROR, @@ -51,13 +51,13 @@ class HighlightPattern { HighlightPattern(void); ~HighlightPattern(void); - void SetName(Edn::String &name) { m_paternName = name;}; - Edn::String GetName(void) { return m_paternName;}; + void SetName(etk::String &name) { m_paternName = name;}; + etk::String GetName(void) { return m_paternName;}; - void SetPaternStart(Edn::String ®Exp); - void SetPaternStop(Edn::String ®Exp); - void SetColor(Edn::String &colorName); - void SetEscapeChar(Edn::String &EscapeChar); + void SetPaternStart(etk::String ®Exp); + void SetPaternStop(etk::String ®Exp); + void SetColor(etk::String &colorName); + void SetEscapeChar(etk::String &EscapeChar); void SetMultiline(bool enable) { m_multiline = enable; }; void SetLevel(int32_t newLevel) { m_level = newLevel; }; @@ -73,16 +73,16 @@ class HighlightPattern { private: int32_t m_level; //!< Level of the pattern ==> this is to overwrite next pattern when we create an higher .... - Edn::String m_paternName; //!< Current style name (like "c++" or "c" or "script Bash") - Edn::String m_colorName; //!< Current color name + etk::String m_paternName; //!< Current style name (like "c++" or "c" or "script Bash") + etk::String m_colorName; //!< Current color name Colorize * m_color; //!< Link to the color manager - EdnRegExp * m_regExpStart; //!< Start of Regular expression - EdnRegExp * m_regExpStop; //!< Stop of Regular Expression + etk::RegExp * m_regExpStart; //!< Start of Regular expression + etk::RegExp * m_regExpStop; //!< Stop of Regular Expression bool m_haveStopPatern; //!< Stop patern presence bool m_multiline; //!< The patern is multiline char m_escapeChar; //!< Escape char to prevent exeit of patern .... - Edn::VectorType m_subPatern; //!< Under patern of this one -// Edn::VectorType m_subColor; //!< Under Color in the start RegExp ... + etk::VectorType m_subPatern; //!< Under patern of this one +// etk::VectorType m_subColor; //!< Under Color in the start RegExp ... }; #endif diff --git a/jni/edn/ctags/CTagsManager.cpp b/jni/edn/ctags/CTagsManager.cpp index c585aa3..51da17d 100644 --- a/jni/edn/ctags/CTagsManager.cpp +++ b/jni/edn/ctags/CTagsManager.cpp @@ -23,12 +23,11 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "Edn.h" -#include "CTagsManager.h" -#include "ClipBoard.h" -#include "BufferManager.h" +#include +#include +#include +#include +#include @@ -61,16 +60,19 @@ CTagsManager::CTagsManager(void) : MsgBroadcast("C-Tags Manager", EDN_CAT_CTAGS) */ CTagsManager::~CTagsManager(void) { + /* if(0 != m_historyList.Size()) { for (int32_t iii=0; iii< m_historyList.Size(); iii++) { delete(m_historyList[iii]); } m_historyList.Clear(); } + */ } -Edn::String CTagsManager::GetFolder(Edn::String &inputString) +etk::String CTagsManager::GetFolder(etk::String &inputString) { + /* char tmpVal[4096]; strncpy(tmpVal, inputString.c_str(), 4096); tmpVal[4096-1] = '\0'; @@ -78,17 +80,21 @@ Edn::String CTagsManager::GetFolder(Edn::String &inputString) if (NULL == ptr) { ptr = strrchr(tmpVal, '\\'); } - Edn::String out = "./"; + etk::String out = "./"; if (NULL != ptr) { *ptr = '\0'; out = tmpVal; out+= '/'; } return out; + */ + etk::String out = "./"; + return out; } void CTagsManager::OnMessage(int32_t id, int32_t dataID) { + /* switch (id) { case EDN_MSG__BUFFER_CHANGE_CURRENT: @@ -136,13 +142,14 @@ void CTagsManager::OnMessage(int32_t id, int32_t dataID) m_historyList.PopBack(); } break; - } + */ } void CTagsManager::LoadTagFile(void) { + /* tagFileInfo info; // close previous tag file @@ -161,10 +168,12 @@ void CTagsManager::LoadTagFile(void) } else { EDN_INFO("Error to open ctags file ..."); } + */ } void CTagsManager::AddToHistory(int32_t bufferID) { + /* // check tho history position : remove if needed if (m_historyPos < edn_max(m_historyList.Size()-1, 0) ) { for(int32_t iii= m_historyPos; iii < m_historyList.Size(); iii++) { @@ -174,16 +183,17 @@ void CTagsManager::AddToHistory(int32_t bufferID) } // add the current element BufferManager *myBufferManager = BufferManager::getInstance(); - Edn::File currentFilename = myBufferManager->Get(bufferID)->GetFileName(); + etk::File currentFilename = myBufferManager->Get(bufferID)->GetFileName(); + */ } +/* enum { CTAGS_COL_FILE = 0, CTAGS_COL_LINE_NUMBER, CTAGS_NUM_COLS }; - void CTagsManager::cb_row(GtkTreeView *p_treeview, GtkTreePath * p_path, GtkTreeViewColumn * p_column, @@ -219,9 +229,9 @@ void CTagsManager::cb_row(GtkTreeView *p_treeview, } } } +*/ - - +/* GtkWidget * CTagsManager::CreateViewAndModel(void) { @@ -260,18 +270,19 @@ GtkWidget * CTagsManager::CreateViewAndModel(void) } gtk_tree_view_set_model( GTK_TREE_VIEW(view), GTK_TREE_MODEL(m_listStore) ); - g_signal_connect( G_OBJECT(view), "row-activated", G_CALLBACK(cb_row), /*(gpointer)p_model*/ this ); + g_signal_connect( G_OBJECT(view), "row-activated", G_CALLBACK(cb_row), this ); //g_object_unref(GTK_TREE_MODEL(m_listStore)); return view; } - +*/ int32_t CTagsManager::MultipleJump(void) { + /* // dlg to confirm the quit event : m_Dialog = gtk_dialog_new_with_buttons("C-Tags jump...", NULL, @@ -294,34 +305,21 @@ int32_t CTagsManager::MultipleJump(void) // Remove dialogue gtk_widget_destroy(m_Dialog); } - //GtkTreeIter *myIter; - //gtk_tree_selection_get_selected(selection, &model, myIter); - - - - // Remove dialogue - //gtk_widget_destroy(myDialog); + */ return 0; } -/* -void BufferView::OnCtagsEventList(GtkWidget *menuitem, gpointer data) -{ - //BufferView * self = reinterpret_cast(data); - //self->SendMessage(EDN_MSG__GUI_SHOW_SAVE_AS, self->m_contectMenuSelectID); - //self->m_contectMenuSelectID = -1; -} -*/ void CTagsManager::JumpAtID(int32_t selectID) { +/* BufferManager *myBufferManager = BufferManager::getInstance(); - Edn::File myFile = m_currentList[selectID].filename; + etk::File myFile = m_currentList[selectID].filename; EDN_INFO("save curent filename and position : "); int32_t currentSelected = myBufferManager->GetSelected(); Buffer* tmpBuf = myBufferManager->Get(currentSelected); if (NULL != tmpBuf) { - Edn::File * bufferFilename = new Edn::File(); + etk::File * bufferFilename = new etk::File(); *bufferFilename = tmpBuf->GetFileName(); bufferFilename->SetLineNumber(tmpBuf->GetCurrentLine()); m_historyList.PushBack(bufferFilename); @@ -334,28 +332,17 @@ void CTagsManager::JumpAtID(int32_t selectID) } else { SendMessage(EDN_MSG__CURRENT_CHANGE_BUFFER_ID, myBufferManager->GetId(myFile)); } - /* - int32_t localId = myBufferManager->GetId(myFile); - Edn::String pattern = entry.address.pattern; - EDN_DEBUG("try to find line with : \"" << pattern << "\"" ); - if (pattern.Size() > 4) { - pattern.Remove(0,2); - pattern.Remove(pattern.Size()-1,2); - } - // TODO : remove '\' char when needed ... - EDN_DEBUG("try to find line with : \"" << pattern << "\"" ); - int32_t destLine = myBufferManager->Get(localId)->FindLine(pattern); - SendMessage(EDN_MSG__CURRENT_GOTO_LINE, destLine); - */ SendMessage(EDN_MSG__CURRENT_GOTO_LINE, m_currentList[selectID].lineID - 1); +*/ } void CTagsManager::JumpTo(void) { +/* m_currentList.Clear(); if (NULL != m_ctagFile) { - Edn::VectorType data; + etk::VectorType data; // get the middle button of the clipboard ==> represent the current selection ... ClipBoard::Get(COPY_MIDDLE_BUTTON, data); if (data.Size() == 0) { @@ -370,9 +357,9 @@ void CTagsManager::JumpTo(void) // For all tags : Save in an internal Structure : do { - Edn::String destinationFilename = m_tagFolderBase; + etk::String destinationFilename = m_tagFolderBase; destinationFilename += entry.file; - Edn::File myfile = destinationFilename; + etk::File myfile = destinationFilename; TagListFind_ts myStruct; strncpy(myStruct.filename, myfile.GetCompleateName().c_str(), MAX_FILE_NAME); myStruct.filename[MAX_FILE_NAME-1] = '\0'; @@ -392,18 +379,13 @@ void CTagsManager::JumpTo(void) // Open a choice windows... int32_t SelectID = MultipleJump(); } - /* - // Display all the element : - do { - PrintTag(&entry, true); - } while (tagsFindNext (m_ctagFile, &entry) == TagSuccess); - */ } else { EDN_INFO("no tag find ..."); } } +*/ } - +/* void CTagsManager::PrintTag (const tagEntry *entry, bool small) { if (small==true) { @@ -426,4 +408,5 @@ void CTagsManager::PrintTag (const tagEntry *entry, bool small) EDN_INFO(" " << entry->fields.list[i].key << ":" << entry->fields.list[i].value ); } } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/jni/edn/ctags/CTagsManager.h b/jni/edn/ctags/CTagsManager.h index 110ce1f..0d5c9fa 100644 --- a/jni/edn/ctags/CTagsManager.h +++ b/jni/edn/ctags/CTagsManager.h @@ -27,10 +27,9 @@ #define __C_TAGS_MANAGER_H__ -#include "Singleton.h" +#include #include "MsgBroadcast.h" #include "readtags.h" -#include "Edn.h" #define MAX_REG_EXP_SEARCH (1024) @@ -41,9 +40,9 @@ typedef struct{ } TagListFind_ts; -class CTagsManager: public Singleton, public MsgBroadcast +class CTagsManager: public etk::Singleton, public MsgBroadcast { - friend class Singleton; + friend class etk::Singleton; // specific for sigleton system... private: // Constructeur @@ -58,24 +57,26 @@ class CTagsManager: public Singleton, public MsgBroadcast int32_t MultipleJump(void); void JumpTo(void); void PrintTag(const tagEntry *entry, bool small); - Edn::String GetFolder(Edn::String &inputString); - Edn::String m_tagFolderBase; - Edn::String m_tagFilename; + etk::String GetFolder(etk::String &inputString); + etk::String m_tagFolderBase; + etk::String m_tagFilename; tagFile * m_ctagFile; // history system void AddToHistory(int32_t bufferID); int32_t m_historyPos; - Edn::VectorType m_historyList; - Edn::VectorType m_currentList; + etk::VectorType m_historyList; + etk::VectorType m_currentList; void JumpAtID(int32_t selectID); + /* GtkWidget * CreateViewAndModel(void); static void cb_row (GtkTreeView *p_treeview, - GtkTreePath * p_path, - GtkTreeViewColumn * p_column, - gpointer p_data); + GtkTreePath * p_path, + GtkTreeViewColumn * p_column, + gpointer p_data); // save data in the list : GtkListStore * m_listStore; GtkWidget * m_Dialog; + */ }; #endif diff --git a/jni/edn/init.cpp b/jni/edn/init.cpp index 7af91d9..fb7f896 100644 --- a/jni/edn/init.cpp +++ b/jni/edn/init.cpp @@ -23,43 +23,33 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "Display.h" -#include "BufferManager.h" -#include "ColorizeManager.h" -#include "HighlightManager.h" -#include "ClipBoard.h" -#include -#include "WindowsManager.h" -#include "Search.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include "readtags.h" -#include "CTagsManager.h" - - -#include "Edn.h" - +#include +#include /** - * @brief Main start function of the system - * - * @param[in] argc number of argument when called - * @param[in] argv sus nomer arguments - * - * @return EXIT_SUCCESS, all time - * + * @brief main application function Initialisation */ -int main (int argc, char *argv[]) +void APP_Init(int argc, char *argv[]) { EDN_INFO("Start Edn"); - //Edn::TestUntaire_String(); + //etk::TestUntaire_String(); //return 0; // Use and remove GTK arguments from the application argument list. - gtk_init (&argc, &argv); + //gtk_init (&argc, &argv); // init internal global value globals::init(); @@ -69,7 +59,7 @@ int main (int argc, char *argv[]) // init ALL Singleton : (void)MsgBroadcastCore::getInstance(); - (void)AccelKey::getInstance(); + //(void)AccelKey::getInstance(); (void)WindowsManager::getInstance(); (void)CTagsManager::getInstance(); BufferManager *myBufferManager = BufferManager::getInstance(); @@ -77,7 +67,7 @@ int main (int argc, char *argv[]) // set color and other trucs... ColorizeManager *myColorManager = NULL; myColorManager = ColorizeManager::getInstance(); - Edn::String homedir; + etk::String homedir; //homedir = getenv("HOME"); #ifdef NDEBUG homedir = "/usr/share/edn/"; @@ -99,7 +89,7 @@ int main (int argc, char *argv[]) // get the curent program folder char cCurrentPath[FILENAME_MAX]; if (!getcwd(cCurrentPath, FILENAME_MAX)) { - return -1; + return ; } cCurrentPath[FILENAME_MAX - 1] = '\0'; //EDN_INFO("The current working directory is " << cCurrentPath); @@ -109,7 +99,7 @@ int main (int argc, char *argv[]) EDN_INFO("show list of files : "); for( int32_t i=1 ; iExist(myfile) ) { int32_t idBuffOpened = myBufferManager->Open(myfile); @@ -118,26 +108,30 @@ int main (int argc, char *argv[]) } } } +} - EDN_INFO("Start gtk main"); - gtk_main(); - EDN_INFO("Stop gtk main"); + +/** + * @brief main application function Un-Initialisation + */ +void APP_UnInit(void) +{ //Kill all singleton EDN_INFO("Stop BufferManager"); - BufferManager::kill(); + //BufferManager::kill(); EDN_INFO("Stop ColorizeManager"); - ColorizeManager::kill(); + //ColorizeManager::kill(); EDN_INFO("Stop Search"); - Search::kill(); + //Search::kill(); EDN_INFO("Stop Accel key"); - AccelKey::kill(); + //AccelKey::kill(); EDN_INFO("Stop Display"); Display::UnInit(); EDN_INFO("Stop Edn"); - return EXIT_SUCCESS; + //return EXIT_SUCCESS; } diff --git a/jni/edn/tools/ClipBoard/ClipBoard.cpp b/jni/edn/tools/ClipBoard/ClipBoard.cpp index 8f5b9d5..3f7f416 100644 --- a/jni/edn/tools/ClipBoard/ClipBoard.cpp +++ b/jni/edn/tools/ClipBoard/ClipBoard.cpp @@ -23,19 +23,21 @@ ******************************************************************************* */ -#include "tools_globals.h" -#include "ClipBoard.h" +#include +#include #undef __class__ #define __class__ "ClipBoard" +#include + /* note: la copy dans le : 0 : copy standard [1..9] : copy interne 10 : bouton du milieux */ -static Edn::VectorType mesCopy[TOTAL_OF_CLICKBOARD]; +static etk::VectorType mesCopy[TOTAL_OF_CLICKBOARD]; void ClipBoard::Init(void) @@ -47,7 +49,7 @@ void ClipBoard::Init(void) } -void ClipBoard::Set(uint8_t clipboardID, Edn::VectorType &data) +void ClipBoard::Set(uint8_t clipboardID, etk::VectorType &data) { // check if ID is correct if(clipboardID >= TOTAL_OF_CLICKBOARD) { @@ -55,35 +57,39 @@ void ClipBoard::Set(uint8_t clipboardID, Edn::VectorType &data) } else if(0 == data.Size()) { EDN_INFO("request a copy of nothing"); } else if (COPY_STD == clipboardID) { - GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_text(clipboard, (const gchar*)&data[0], data.Size() ); + //GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); + //gtk_clipboard_set_text(clipboard, (const gchar*)&data[0], data.Size() ); } else if (COPY_MIDDLE_BUTTON == clipboardID) { - GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); - gtk_clipboard_set_text(clipboard, (const gchar*)&data[0], data.Size() ); + //GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); + //gtk_clipboard_set_text(clipboard, (const gchar*)&data[0], data.Size() ); } // Copy datas ... mesCopy[clipboardID] = data; } -void ClipBoard::Get(uint8_t clipboardID, Edn::VectorType &data) +void ClipBoard::Get(uint8_t clipboardID, etk::VectorType &data) { if(clipboardID >= TOTAL_OF_CLICKBOARD) { EDN_WARNING("request ClickBoard id error"); } else if (COPY_STD == clipboardID) { + /* GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD ); gchar *text = gtk_clipboard_wait_for_text(clipboard); if (text != NULL) { mesCopy[COPY_STD].Clear(); mesCopy[COPY_STD].PushBack((int8_t*)text, strlen(text) ); } + */ } else if (COPY_MIDDLE_BUTTON == clipboardID) { + /* GtkClipboard * clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY ); gchar *text = gtk_clipboard_wait_for_text(clipboard); if (text != NULL) { mesCopy[COPY_MIDDLE_BUTTON].Clear(); mesCopy[COPY_MIDDLE_BUTTON].PushBack((int8_t*)text, strlen(text) ); } + */ } // Copy datas ... data = mesCopy[clipboardID]; diff --git a/jni/edn/tools/ClipBoard/ClipBoard.h b/jni/edn/tools/ClipBoard/ClipBoard.h index 132d0b4..37c5bab 100644 --- a/jni/edn/tools/ClipBoard/ClipBoard.h +++ b/jni/edn/tools/ClipBoard/ClipBoard.h @@ -26,19 +26,19 @@ #ifndef __CLIP_BOARD_H__ #define __CLIP_BOARD_H__ - #include "tools_debug.h" - #include "VectorType.h" +#include "tools_debug.h" +#include "etk/VectorType.h" - #define TOTAL_OF_CLICKBOARD (11) - #define COPY_MIDDLE_BUTTON (10) - #define COPY_STD (0) +#define TOTAL_OF_CLICKBOARD (11) +#define COPY_MIDDLE_BUTTON (10) +#define COPY_STD (0) - namespace ClipBoard - { - void Init(void); - void Set(uint8_t clipboardID, Edn::VectorType &data); - void Get(uint8_t clipboardID, Edn::VectorType &data); - } +namespace ClipBoard +{ + void Init(void); + void Set(uint8_t clipboardID, etk::VectorType &data); + void Get(uint8_t clipboardID, etk::VectorType &data); +} #endif diff --git a/jni/edn/tools/Display/Display.cpp b/jni/edn/tools/Display/Display.cpp index 6700525..cf4e902 100644 --- a/jni/edn/tools/Display/Display.cpp +++ b/jni/edn/tools/Display/Display.cpp @@ -23,12 +23,12 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "Display.h" -#include "ColorizeManager.h" -#include "charset.h" -#include +#include +#include +#include +#include +#include +#include #undef __class__ #define __class__ "Display" @@ -59,9 +59,12 @@ static int32_t m_pangoFontHeight = 11; static cairo_font_face_t * m_cairoFont[2][2] = {{NULL, NULL},{ NULL, NULL}}; */ -static cairo_font_face_t * m_cairoFont[2][2] = {{NULL, NULL},{ NULL, NULL}}; +//static cairo_font_face_t * m_cairoFont[2][2] = {{NULL, NULL},{ NULL, NULL}}; + + void Display::Init(void) { +/* m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL); m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES] = cairo_toy_font_face_create(POLICE_NAME, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); @@ -81,6 +84,7 @@ void Display::Init(void) EDN_ERROR("Italic & Bold font error ... link with basic font"); m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES] = m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO]; } +*/ } @@ -89,11 +93,13 @@ void Display::Init(void) void Display::UnInit(void) { +/* // clean the builder... cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO]); cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO]); cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_YES]); cairo_font_face_destroy(m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES]); +*/ } @@ -109,8 +115,9 @@ int32_t Display::GetFontWidth(void) -cairo_font_face_t * Display::GetFont(bool bold, bool italic) +void * Display::GetFont(bool bold, bool italic) { +/* if( false == bold && false == italic) { return m_cairoFont[FONT_ITALIC_NO][FONT_BOLD_NO]; @@ -122,6 +129,8 @@ cairo_font_face_t * Display::GetFont(bool bold, bool italic) return m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_NO]; } return m_cairoFont[FONT_ITALIC_YES][FONT_BOLD_YES]; +*/ + return NULL; } @@ -140,7 +149,7 @@ cairo_font_face_t * Display::GetFont(bool bold, bool italic) * @return --- * */ -DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y) +DrawerManager::DrawerManager(void * widget, int32_t x, int32_t y) { m_size.x = x; @@ -148,6 +157,7 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y) m_haveWork = false; m_nbElement = 0; // Create the Cairo Element +/* # if USE_GTK_VERSION_3_0 m_cairo = gdk_cairo_create(gtk_widget_get_window(widget)); # elif USE_GTK_VERSION_2_0 @@ -157,20 +167,10 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y) cairo_set_source_rgb(m_cairo, 0, 0, 0); cairo_paint(m_cairo); cairo_set_font_size(m_cairo, POLICE_SIZE); +*/ m_dataToDisplay[0] = '\0'; - cairo_scale(m_cairo, 1.0, 1.0); - - // http://cairographics.org/FAQ/#clear_a_surface - // http://gtk.developpez.com/faq/?page=gtkwidget#GTK_WIDGET_transparent - //cairo_set_source_rgba(m_cairo, 1, 1, 1, 0); - //cairo_set_operator(m_cairo, CAIRO_OPERATOR_SOURCE); - //cairo_paint(m_cairo); - //cairo_fill(m_cairo); - //cairo_stroke (m_cairo); - - - + //cairo_scale(m_cairo, 1.0, 1.0); } @@ -187,7 +187,7 @@ DrawerManager::DrawerManager(GtkWidget * widget, int32_t x, int32_t y) */ DrawerManager::~DrawerManager() { - cairo_destroy(m_cairo); + //cairo_destroy(m_cairo); } @@ -208,6 +208,7 @@ DrawerManager::~DrawerManager() */ void DrawerManager::Text(Colorize *SelectColor, int32_t x, int32_t y,const char *myUTF8Text, int32_t len) { +/* EDN_CHECK_INOUT(NULL!=SelectColor); // check if flush is needed : if (true == m_haveWork) { @@ -233,10 +234,12 @@ void DrawerManager::Text(Colorize *SelectColor, int32_t x, int32_t y,const char } else { m_nbElement+=strUtf8Len(myUTF8Text); } +*/ } void DrawerManager::Text(color_ts & SelectColorFg, color_ts & SelectColorBg, int32_t x, int32_t y,const char *myText) { +/* Flush(); cairo_set_font_face(m_cairo, Display::GetFont(false, false)); int32_t letterHeight = Display::GetFontHeight(); @@ -247,10 +250,12 @@ void DrawerManager::Text(color_ts & SelectColorFg, color_ts & SelectColorBg, int cairo_set_source_rgb(m_cairo, SelectColorFg.red, SelectColorFg.green, SelectColorFg.blue); cairo_show_text(m_cairo, myText); cairo_fill(m_cairo); +*/ } void DrawerManager::Text(color_ts & SelectColorFg, int32_t x, int32_t y,const char *myText) { +/* Flush(); cairo_set_font_face(m_cairo, Display::GetFont(false, false)); int32_t letterHeight = Display::GetFontHeight(); @@ -258,16 +263,18 @@ void DrawerManager::Text(color_ts & SelectColorFg, int32_t x, int32_t y,const ch cairo_set_source_rgb(m_cairo, SelectColorFg.red, SelectColorFg.green, SelectColorFg.blue); cairo_show_text(m_cairo, myText); cairo_fill(m_cairo); - +*/ } void DrawerManager::SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32_t nbChar) { +/* Flush(); int32_t letterHeight = Display::GetFontHeight(); int32_t letterWidth = Display::GetFontWidth(); DirectRectangle(SelectColor, x, y, letterWidth*nbChar, letterHeight); cairo_fill(m_cairo); +*/ } @@ -283,6 +290,7 @@ void DrawerManager::SpaceText(color_ts & SelectColor, int32_t x, int32_t y,int32 */ void DrawerManager::Flush(void) { +/* if (true == m_haveWork) { //EDN_WARNING("flush : \"" << m_dataToDisplay << "\"" << " bold=" << m_selectColor->GetBold() << " italic=" << m_selectColor->GetItalic()); m_haveWork = false; @@ -303,6 +311,7 @@ void DrawerManager::Flush(void) m_dataToDisplay[0] = '\0'; m_nbElement = 0; } +*/ } @@ -322,8 +331,8 @@ void DrawerManager::Flush(void) */ void DrawerManager::Rectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height) { - Flush(); - DirectRectangle(SelectColor, x, y, width, height); + //Flush(); + //DirectRectangle(SelectColor, x, y, width, height); } @@ -341,6 +350,7 @@ void DrawerManager::Rectangle(Colorize *SelectColor, int32_t x, int32_t y, int32 */ void DrawerManager::DirectRectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height) { +/* EDN_CHECK_INOUT(NULL!=SelectColor); //EDN_INFO("x="<< x <<" y="<< y <<" width="<< width <<" height="<< height); //gdk_draw_rectangle( p_pixmap, SelectColor->GetColorBG(), TRUE, x, y, width, height); @@ -351,16 +361,18 @@ void DrawerManager::DirectRectangle(Colorize *SelectColor, int32_t x, int32_t y, //cairo_stroke(m_cairo); // flush cairo_fill(m_cairo); +*/ } void DrawerManager::DirectRectangle(color_ts &SelectColor, int32_t x, int32_t y, int32_t width, int32_t height) { - +/* cairo_set_source_rgb(m_cairo, SelectColor.red, SelectColor.green, SelectColor.blue); // set postion cairo_rectangle(m_cairo, x, y, width, height); //cairo_stroke(m_cairo); // flush cairo_fill(m_cairo); +*/ } @@ -374,8 +386,10 @@ void DrawerManager::DirectRectangle(color_ts &SelectColor, int32_t x, int32_t y, */ void DrawerManager::Clean(Colorize *SelectColor) { +/* m_haveWork = false; DirectRectangle(SelectColor, 0, 0, m_size.x, m_size.y); +*/ } /** @@ -388,8 +402,10 @@ void DrawerManager::Clean(Colorize *SelectColor) */ void DrawerManager::Clean(color_ts & SelectColor) { +/* m_haveWork = false; DirectRectangle(SelectColor, 0, 0, m_size.x, m_size.y); +*/ } /** @@ -406,6 +422,7 @@ void DrawerManager::Clean(color_ts & SelectColor) #define CURSOR_WIDTH (4) void DrawerManager::Cursor(int32_t x, int32_t y) { +/* Flush(); // get the cursor Color : color_ts myColor = ColorizeManager::getInstance()->Get(COLOR_CODE_CURSOR); @@ -433,6 +450,7 @@ void DrawerManager::Cursor(int32_t x, int32_t y) } cairo_stroke(m_cairo); cairo_fill(m_cairo); +*/ } /** @@ -448,6 +466,7 @@ void DrawerManager::Cursor(int32_t x, int32_t y) */ void DrawerManager::EndOfLine(int32_t x, int32_t y) { +#if 0 if (true == globals::IsSetDisplayEndOfLine() ) { Flush(); // get the cursor Color : @@ -472,6 +491,7 @@ void DrawerManager::EndOfLine(int32_t x, int32_t y) cairo_stroke(m_cairo); cairo_fill(m_cairo); } +#endif } @@ -489,6 +509,7 @@ void DrawerManager::EndOfLine(int32_t x, int32_t y) */ void DrawerManager::Tabulation(Colorize *SelectColor, int32_t x, int32_t y, int32_t mbColomn) { +/* Flush(); int32_t letterWidth = Display::GetFontWidth(); int32_t letterHeight = Display::GetFontHeight(); @@ -509,6 +530,7 @@ void DrawerManager::Tabulation(Colorize *SelectColor, int32_t x, int32_t y, int3 cairo_stroke(m_cairo); cairo_fill(m_cairo); +*/ } @@ -526,6 +548,7 @@ void DrawerManager::Tabulation(Colorize *SelectColor, int32_t x, int32_t y, int3 */ void DrawerManager::UTF8UnknownElement(Colorize *SelectColor, int32_t x, int32_t y, int8_t utf8Size, bool ValidUtf8) { +#if 0 Flush(); int32_t letterWidth = Display::GetFontWidth(); int32_t letterHeight = Display::GetFontHeight(); @@ -576,6 +599,7 @@ void DrawerManager::UTF8UnknownElement(Colorize *SelectColor, int32_t x, int32_t } cairo_stroke(m_cairo); cairo_fill(m_cairo); +#endif } diff --git a/jni/edn/tools/Display/Display.h b/jni/edn/tools/Display/Display.h index c98ceb7..58bf0f2 100644 --- a/jni/edn/tools/Display/Display.h +++ b/jni/edn/tools/Display/Display.h @@ -26,9 +26,9 @@ #ifndef __TOOLS_DISPLAY_H__ #define __TOOLS_DISPLAY_H__ -#include "tools_debug.h" -#include "Colorize.h" -#include "ColorizeManager.h" +#include +#include +#include /** @@ -38,7 +38,8 @@ namespace Display { void Init(void); void UnInit(void); - cairo_font_face_t * GetFont(bool bold, bool italic); + //cairo_font_face_t * GetFont(bool bold, bool italic); + void * GetFont(bool bold, bool italic); int32_t GetFontHeight(void); int32_t GetFontWidth(void); }; @@ -52,7 +53,8 @@ class DrawerManager; class DrawerManager { public: // Constructeur - DrawerManager(GtkWidget * widget, int32_t x, int32_t y); + //DrawerManager(GtkWidget * widget, int32_t x, int32_t y); + DrawerManager(void * widget, int32_t x, int32_t y); ~DrawerManager(); void Rectangle(Colorize *SelectColor, int32_t x, int32_t y, int32_t width, int32_t height); @@ -84,7 +86,7 @@ class DrawerManager { Colorize * m_selectColor; //!< curent color to display position_ts m_size; //!< Total size - cairo_t * m_cairo; //!< Cairo Layout pointer + //cairo_t * m_cairo; //!< Cairo Layout pointer }; diff --git a/jni/edn/tools/EdnBuf/EdnBuf.cpp b/jni/edn/tools/EdnBuf/EdnBuf.cpp index bd3508e..a05ca9d 100644 --- a/jni/edn/tools/EdnBuf/EdnBuf.cpp +++ b/jni/edn/tools/EdnBuf/EdnBuf.cpp @@ -23,9 +23,9 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "EdnBuf.h" +#include +#include +#include #undef __class__ @@ -126,7 +126,7 @@ bool EdnBuf::DumpFrom(FILE *myFile) } -void EdnBuf::GetAll(Edn::VectorType &text) +void EdnBuf::GetAll(etk::VectorType &text) { // Clean output vector text.Clear(); @@ -135,9 +135,9 @@ void EdnBuf::GetAll(Edn::VectorType &text) } -void EdnBuf::SetAll(Edn::VectorType &text) +void EdnBuf::SetAll(etk::VectorType &text) { - Edn::VectorType deletedText; + etk::VectorType deletedText; // extract all data of the buffer : GetAll(deletedText); @@ -155,7 +155,7 @@ void EdnBuf::SetAll(Edn::VectorType &text) eventModification(0, m_data.Size(), deletedText); } -void EdnBuf::GetRange(int32_t start, int32_t end, Edn::VectorType &output) +void EdnBuf::GetRange(int32_t start, int32_t end, etk::VectorType &output) { // Remove all data ... output.Clear(); @@ -189,7 +189,7 @@ int8_t EdnBuf::operator[] (int32_t pos) * @return --- * */ -void EdnBuf::Insert(int32_t pos, Edn::VectorType &insertText) +void EdnBuf::Insert(int32_t pos, etk::VectorType &insertText) { // if pos is not contiguous to existing text, make it pos = edn_average(0, pos, m_data.Size() ); @@ -197,7 +197,7 @@ void EdnBuf::Insert(int32_t pos, Edn::VectorType &insertText) insert(pos, insertText); // Call the redisplay ... - Edn::VectorType deletedText; + etk::VectorType deletedText; eventModification(pos, insertText.Size(), deletedText); } @@ -212,9 +212,9 @@ void EdnBuf::Insert(int32_t pos, Edn::VectorType &insertText) * @return --- * */ -void EdnBuf::Replace(int32_t start, int32_t end, Edn::VectorType &insertText) +void EdnBuf::Replace(int32_t start, int32_t end, etk::VectorType &insertText) { - Edn::VectorType deletedText; + etk::VectorType deletedText; GetRange(start, end, deletedText); m_data.Replace(start, end-start, insertText); // update internal elements @@ -234,7 +234,7 @@ void EdnBuf::Replace(int32_t start, int32_t end, Edn::VectorType &insert void EdnBuf::Remove(int32_t start, int32_t end) { - Edn::VectorType deletedText; + etk::VectorType deletedText; // Make sure the arguments make sense if (start > end) { int32_t temp = start; @@ -265,7 +265,7 @@ int32_t EdnBuf::Indent(selectionType_te select) // Get Range : int32_t l_start = StartOfLine(SelectionStart); int32_t l_end = EndOfLine(SelectionEnd); - Edn::VectorType l_tmpData; + etk::VectorType l_tmpData; GetRange(l_start, l_end, l_tmpData); l_tmpData.Insert(0, '\n'); @@ -304,7 +304,7 @@ int32_t EdnBuf::UnIndent(selectionType_te select) // Get Range : int32_t l_start = StartOfLine(SelectionStart); int32_t l_end = EndOfLine(SelectionEnd); - Edn::VectorType l_tmpData; + etk::VectorType l_tmpData; GetRange(l_start, l_end, l_tmpData); l_tmpData.Insert(0, '\n'); @@ -346,7 +346,7 @@ int32_t EdnBuf::UnIndent(selectionType_te select) * @return --- * */ -void EdnBuf::GetLineText(int32_t pos, Edn::VectorType &text) +void EdnBuf::GetLineText(int32_t pos, etk::VectorType &text) { GetRange( StartOfLine(pos), EndOfLine(pos), text); } @@ -666,9 +666,9 @@ int32_t EdnBuf::CountLines(int32_t startPos, int32_t endPos) * @return number of line found * */ -int32_t EdnBuf::CountLines(Edn::VectorType &data) +int32_t EdnBuf::CountLines(etk::VectorType &data) { - Edn::VectorType::Iterator myPosIt = data.Begin(); + etk::VectorType::Iterator myPosIt = data.Begin(); int32_t lineCount = 0; while(myPosIt) { @@ -810,7 +810,7 @@ bool EdnBuf::charMatch(char first, char second, bool caseSensitive) * @return false ==> not found data * */ -bool EdnBuf::SearchForward(int32_t startPos, Edn::VectorType &searchVect, int32_t *foundPos, bool caseSensitive) +bool EdnBuf::SearchForward(int32_t startPos, etk::VectorType &searchVect, int32_t *foundPos, bool caseSensitive) { int32_t position; int32_t searchLen = searchVect.Size(); @@ -851,7 +851,7 @@ bool EdnBuf::SearchForward(int32_t startPos, Edn::VectorType &searchVect * @return false ==> not found data * */ -bool EdnBuf::SearchBackward(int32_t startPos, Edn::VectorType &searchVect, int32_t *foundPos, bool caseSensitive) +bool EdnBuf::SearchBackward(int32_t startPos, etk::VectorType &searchVect, int32_t *foundPos, bool caseSensitive) { int32_t position; int32_t searchLen = searchVect.Size(); @@ -977,7 +977,7 @@ bool EdnBuf::SelectAround(int32_t startPos, int32_t &beginPos, int32_t &endPos) * @return number of element inserted. * */ -int32_t EdnBuf::insert(int32_t pos, Edn::VectorType &insertText) +int32_t EdnBuf::insert(int32_t pos, etk::VectorType &insertText) { // Insert data in buffer m_data.Insert(pos, insertText); @@ -998,7 +998,7 @@ int32_t EdnBuf::insert(int32_t pos, Edn::VectorType &insertText) * @return --- * */ -void EdnBuf::eventModification(int32_t pos, int32_t nInserted, Edn::VectorType &deletedText) +void EdnBuf::eventModification(int32_t pos, int32_t nInserted, etk::VectorType &deletedText) { if( 0 == deletedText.Size() && 0 == nInserted) diff --git a/jni/edn/tools/EdnBuf/EdnBuf.h b/jni/edn/tools/EdnBuf/EdnBuf.h index 224d9fe..92007db 100644 --- a/jni/edn/tools/EdnBuf/EdnBuf.h +++ b/jni/edn/tools/EdnBuf/EdnBuf.h @@ -31,10 +31,10 @@ class EdnBuf; -#include "EdnVectorBuf.h" -#include "EdnBufHistory.h" -#include "HighlightManager.h" -#include "charset.h" +#include +#include +#include +#include /* @@ -67,7 +67,7 @@ typedef enum{ typedef struct { - Edn::VectorType HLData; + etk::VectorType HLData; int32_t idSequence; int32_t posHLPass1; int32_t posHLPass2; @@ -82,21 +82,21 @@ class EdnBuf { // destructer ~EdnBuf(void); // public function : - void GetAll( Edn::VectorType &text); - void SetAll( Edn::VectorType &text); - void GetRange( int32_t start, int32_t end, Edn::VectorType &output); + void GetAll( etk::VectorType &text); + void SetAll( etk::VectorType &text); + void GetRange( int32_t start, int32_t end, etk::VectorType &output); bool DumpIn( FILE *myFile); bool DumpFrom( FILE *myFile); // replace with operator [] ... int8_t operator[] (int32_t); - void Insert( int32_t pos, Edn::VectorType &insertText); - void Replace( int32_t start, int32_t end, Edn::VectorType &insertText); + void Insert( int32_t pos, etk::VectorType &insertText); + void Replace( int32_t start, int32_t end, etk::VectorType &insertText); void Remove( int32_t start, int32_t end); int32_t Indent( selectionType_te select); int32_t UnIndent( selectionType_te select); - void GetLineText( int32_t pos, Edn::VectorType &text); + void GetLineText( int32_t pos, etk::VectorType &text); int32_t StartOfLine( int32_t pos); int32_t EndOfLine( int32_t pos); @@ -107,12 +107,12 @@ class EdnBuf { int32_t CountForwardDispChars( int32_t lineStartPos, int32_t nChars); int32_t CountLines( int32_t startPos, int32_t endPos); int32_t CountLines( void); - int32_t CountLines( Edn::VectorType &data); + int32_t CountLines( etk::VectorType &data); int32_t CountForwardNLines( int32_t startPos, int32_t nLines); int32_t CountBackwardNLines( int32_t startPos, int32_t nLines); - bool SearchForward( int32_t startPos, Edn::VectorType &searchVect, int32_t *foundPos, bool caseSensitive = true); - bool SearchBackward( int32_t startPos, Edn::VectorType &searchVect, int32_t *foundPos, bool caseSensitive = true); + bool SearchForward( int32_t startPos, etk::VectorType &searchVect, int32_t *foundPos, bool caseSensitive = true); + bool SearchBackward( int32_t startPos, etk::VectorType &searchVect, int32_t *foundPos, bool caseSensitive = true); bool SearchForward( int32_t startPos, char searchChar, int32_t *foundPos); bool SearchBackward( int32_t startPos, char searchChar, int32_t *foundPos); bool SelectAround( int32_t startPos, int32_t &beginPos, int32_t &endPos); @@ -130,9 +130,9 @@ class EdnBuf { void Unselect( selectionType_te select); void RectSelect( selectionType_te select, int32_t start, int32_t end, int32_t rectStart, int32_t rectEnd); bool GetSelectionPos( selectionType_te select, int32_t &start, int32_t &end, bool &isRect, int32_t &rectStart, int32_t &rectEnd); - void GetSelectionText( selectionType_te select, Edn::VectorType &text); + void GetSelectionText( selectionType_te select, etk::VectorType &text); void RemoveSelected( selectionType_te select); - void ReplaceSelected( selectionType_te select, Edn::VectorType &text); + void ReplaceSelected( selectionType_te select, etk::VectorType &text); private: // current selection of the buffer selection m_selectionList[SELECTION_SIZE]; //!< Selection area of the buffer @@ -148,15 +148,15 @@ class EdnBuf { private: bool m_isUndoProcessing; bool m_isRedoProcessing; - Edn::VectorType m_historyUndo; - Edn::VectorType m_historyRedo; + etk::VectorType m_historyUndo; + etk::VectorType m_historyRedo; // ----------------------------------------- // hightlight section : // ----------------------------------------- private: Highlight * m_Highlight; //!< internal link with the Highlight system - Edn::VectorType m_HLDataPass1; //!< colorisation position in the current buffer pass 1 + etk::VectorType m_HLDataPass1; //!< colorisation position in the current buffer pass 1 int32_t m_HLDataSequence; //!< position of the start of line requested by the screen viewer void RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded); void GenerateHighLightAt(int32_t pos, int32_t endPos, int32_t addinPos=0); @@ -201,10 +201,10 @@ class EdnBuf { void removeSelected( selection &sel); void replaceSelected( selection &sel, const char *text); - void eventModification( int32_t pos, int32_t nInserted, Edn::VectorType &deletedText); + void eventModification( int32_t pos, int32_t nInserted, etk::VectorType &deletedText); - int32_t insert( int32_t pos, Edn::VectorType &insertText); + int32_t insert( int32_t pos, etk::VectorType &insertText); bool charMatch( char first, char second, bool caseSensitive = true); }; diff --git a/jni/edn/tools/EdnBuf/EdnBufHistory.cpp b/jni/edn/tools/EdnBuf/EdnBufHistory.cpp index b7337b9..76ed52f 100644 --- a/jni/edn/tools/EdnBuf/EdnBufHistory.cpp +++ b/jni/edn/tools/EdnBuf/EdnBufHistory.cpp @@ -24,9 +24,9 @@ */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "EdnBufHistory.h" +#include +#include +#include #undef __class__ @@ -39,7 +39,7 @@ EdnBufHistory::EdnBufHistory(void) m_nInserted = 0; } -EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, Edn::VectorType &deletedText) +EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, etk::VectorType &deletedText) { //EDN_INFO("EdnBufHistory new + data"); m_pos = pos; @@ -47,7 +47,7 @@ EdnBufHistory::EdnBufHistory(int32_t pos, int32_t nInserted, Edn::VectorType &deletedText) +void EdnBufHistory::Set(int32_t pos, int32_t nInserted, etk::VectorType &deletedText) { //EDN_INFO("EdnBufHistory new + data"); m_pos = pos; @@ -75,7 +75,7 @@ int32_t EdnBufHistory::getnbInserted(void) return m_nInserted; } -void EdnBufHistory::getData(Edn::VectorType &deletedText) +void EdnBufHistory::getData(etk::VectorType &deletedText) { deletedText = m_deletedText; } diff --git a/jni/edn/tools/EdnBuf/EdnBufHistory.h b/jni/edn/tools/EdnBuf/EdnBufHistory.h index 33a7b95..3545561 100644 --- a/jni/edn/tools/EdnBuf/EdnBufHistory.h +++ b/jni/edn/tools/EdnBuf/EdnBufHistory.h @@ -27,22 +27,22 @@ #define __EDN_BUFFER_HISTORY_H__ -#include "VectorType.h" +#include class EdnBufHistory{ public: EdnBufHistory(void); - EdnBufHistory(int32_t pos, int32_t nInserted, Edn::VectorType &deletedText); + EdnBufHistory(int32_t pos, int32_t nInserted, etk::VectorType &deletedText); ~EdnBufHistory(void); - void Set(int32_t pos, int32_t nInserted, Edn::VectorType &deletedText); + void Set(int32_t pos, int32_t nInserted, etk::VectorType &deletedText); int32_t getPos(void); int32_t getnbDeleted(void); int32_t getnbInserted(void); - void getData(Edn::VectorType &deletedText); + void getData(etk::VectorType &deletedText); private: int32_t m_pos; int32_t m_nInserted; - Edn::VectorType m_deletedText; + etk::VectorType m_deletedText; }; #endif diff --git a/jni/edn/tools/EdnBuf/EdnBuf_HighLight.cpp b/jni/edn/tools/EdnBuf/EdnBuf_HighLight.cpp index b399fb5..ef9980b 100644 --- a/jni/edn/tools/EdnBuf/EdnBuf_HighLight.cpp +++ b/jni/edn/tools/EdnBuf/EdnBuf_HighLight.cpp @@ -23,9 +23,9 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "EdnBuf.h" +#include +#include +#include #undef __class__ @@ -43,8 +43,8 @@ void EdnBuf::SetHLSystem(Highlight * newHLSystem) // TODO : Check this fuction it have too many conditionnal inside ==> can do a better algo void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdded) { - GTimeVal timeStart; - g_get_current_time(&timeStart); + //GTimeVal timeStart; + //g_get_current_time(&timeStart); // remove display HL... m_HLDataSequence++; @@ -64,7 +64,7 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd int32_t i; /* for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) { - Edn::String ploppp; + etk::String ploppp; if (NULL != m_HLDataPass1[i].patern ) { ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName(); } @@ -108,7 +108,7 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd //EDN_DEBUG("new size=" << (int32_t)m_HLDataPass1.Size()-1); /* for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) { - Edn::String ploppp; + etk::String ploppp; if (NULL != m_HLDataPass1[i].patern ) { ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName(); } @@ -151,16 +151,16 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd } /* for (i=0; i< (int32_t)m_HLDataPass1.Size(); i++) { - Edn::String ploppp; + etk::String ploppp; if (NULL != m_HLDataPass1[i].patern ) { ploppp = ((HighlightPattern*)m_HLDataPass1[i].patern)->GetName(); } EDN_DEBUG("HighLight (end) element id=" << i << " S=" << m_HLDataPass1[i].beginStart << " E=" << m_HLDataPass1[i].endStop << " patern name=" << ploppp ); } */ - GTimeVal timeStop; - g_get_current_time(&timeStop); - EDN_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s"); + //GTimeVal timeStop; + //g_get_current_time(&timeStop); + //EDN_DEBUG("HL General = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s"); } void EdnBuf::FindMainHighLightPosition(int32_t startPos, int32_t endPos, int32_t &startId, int32_t &stopId, bool backPreviousNotEnded) @@ -296,8 +296,8 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, return; } if (MData.idSequence != m_HLDataSequence) { - GTimeVal timeStart; - g_get_current_time(&timeStart); + //GTimeVal timeStart; + //g_get_current_time(&timeStart); MData.idSequence = m_HLDataSequence; HLStart = StartOfLine(HLStart); MData.HLData.Clear(); @@ -350,9 +350,9 @@ void EdnBuf::HightlightGenerateLines(displayHLData_ts & MData, int32_t HLStart, } } - GTimeVal timeStop; - g_get_current_time(&timeStop); - EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s"); + //GTimeVal timeStop; + //g_get_current_time(&timeStop); + //EDN_DEBUG("Display reAnnalyse = " << timeStop.tv_usec - timeStart.tv_usec << " micro-s"); } } diff --git a/jni/edn/tools/EdnBuf/EdnBuf_History.cpp b/jni/edn/tools/EdnBuf/EdnBuf_History.cpp index 509c872..383653f 100644 --- a/jni/edn/tools/EdnBuf/EdnBuf_History.cpp +++ b/jni/edn/tools/EdnBuf/EdnBuf_History.cpp @@ -23,9 +23,9 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "EdnBuf.h" +#include +#include +#include #undef __class__ @@ -53,7 +53,7 @@ int32_t EdnBuf::Undo(void) int32_t pos = m_historyUndo[nbElement]->getPos(); int32_t nbDeleted = m_historyUndo[nbElement]->getnbDeleted(); int32_t nbInserted = m_historyUndo[nbElement]->getnbInserted(); - Edn::VectorType deletedText; + etk::VectorType deletedText; m_historyUndo[nbElement]->getData(deletedText); m_isUndoProcessing = true; if (0 == nbInserted) { @@ -101,7 +101,7 @@ int32_t EdnBuf::Redo(void) int32_t pos = m_historyRedo[nbElement]->getPos(); int32_t nbDeleted = m_historyRedo[nbElement]->getnbDeleted(); int32_t nbInserted = m_historyRedo[nbElement]->getnbInserted(); - Edn::VectorType deletedText; + etk::VectorType deletedText; m_historyRedo[nbElement]->getData(deletedText); m_isRedoProcessing = true; if (0 == nbInserted) { diff --git a/jni/edn/tools/EdnBuf/EdnBuf_Selection.cpp b/jni/edn/tools/EdnBuf/EdnBuf_Selection.cpp index 84f9938..b0e46c8 100644 --- a/jni/edn/tools/EdnBuf/EdnBuf_Selection.cpp +++ b/jni/edn/tools/EdnBuf/EdnBuf_Selection.cpp @@ -23,9 +23,9 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "EdnBuf.h" +#include +#include +#include #undef __class__ @@ -136,7 +136,7 @@ bool EdnBuf::GetSelectionPos(selectionType_te select, int32_t &start, int32_t &e * @return --- * */ -void EdnBuf::GetSelectionText(selectionType_te select, Edn::VectorType &text) +void EdnBuf::GetSelectionText(selectionType_te select, etk::VectorType &text) { int32_t start, end, rectStart, rectEnd; bool isRect; @@ -198,7 +198,7 @@ void EdnBuf::RemoveSelected(selectionType_te select) * @return --- * */ -void EdnBuf::ReplaceSelected(selectionType_te select, Edn::VectorType &text) +void EdnBuf::ReplaceSelected(selectionType_te select, etk::VectorType &text) { int32_t start, end, rectStart, rectEnd; bool isRect; diff --git a/jni/edn/tools/EdnTemplate/EdnVectorBuf.cpp b/jni/edn/tools/EdnTemplate/EdnVectorBuf.cpp index 144f4bd..2631bfd 100644 --- a/jni/edn/tools/EdnTemplate/EdnVectorBuf.cpp +++ b/jni/edn/tools/EdnTemplate/EdnVectorBuf.cpp @@ -23,11 +23,10 @@ ******************************************************************************* */ - -#include "tools_debug.h" -#include "tools_globals.h" -#include "toolsMemory.h" -#include "EdnVectorBuf.h" +#include +#include +#include +#include #undef __class__ #define __class__ "EdnEdnVectorBuf" @@ -227,7 +226,7 @@ int8_t& EdnVectorBuf::Get(int32_t pos) * @return --- * */ -void EdnVectorBuf::Get(int32_t pos, int32_t nbElement, Edn::VectorType &tmpBuffer) +void EdnVectorBuf::Get(int32_t pos, int32_t nbElement, etk::VectorType &tmpBuffer) { tmpBuffer.Clear(); if (pos < m_gapStart) { @@ -399,7 +398,7 @@ void EdnVectorBuf::Insert(int32_t pos, const int8_t& item) * @return --- * */ -void EdnVectorBuf::Insert(int32_t pos, Edn::VectorType& items) +void EdnVectorBuf::Insert(int32_t pos, etk::VectorType& items) { if( pos > Size() || pos < 0 ) { @@ -455,7 +454,7 @@ void EdnVectorBuf::Replace(int32_t pos, const int8_t& item) * @return --- * */ -void EdnVectorBuf::Replace(int32_t pos, int32_t nbRemoveElement, Edn::VectorType& items) +void EdnVectorBuf::Replace(int32_t pos, int32_t nbRemoveElement, etk::VectorType& items) { if( pos > Size() || pos < 0 ) { @@ -652,7 +651,7 @@ void TestEdnVectorBuf(void) myBufferTmp.Display(); plop='m'; - Edn::VectorType items; + etk::VectorType items; items.PushBack('i'); items.PushBack('j'); items.PushBack('k'); diff --git a/jni/edn/tools/EdnTemplate/EdnVectorBuf.h b/jni/edn/tools/EdnTemplate/EdnVectorBuf.h index fb74a42..fec42a1 100644 --- a/jni/edn/tools/EdnTemplate/EdnVectorBuf.h +++ b/jni/edn/tools/EdnTemplate/EdnVectorBuf.h @@ -26,8 +26,8 @@ #ifndef __EDN_VECTOR_BUF_H__ #define __EDN_VECTOR_BUF_H__ -#include "toolsMemory.h" -#include "VectorType.h" +#include +#include #undef __class__ #define __class__ "EdnVectorBuf" @@ -272,14 +272,14 @@ class EdnVectorBuf EdnVectorBuf & operator=( const EdnVectorBuf & Evb); int8_t operator[] (int32_t pos); int8_t & Get( int32_t pos); - void Get( int32_t pos, int32_t nbElement, Edn::VectorType &tmpBuffer); + void Get( int32_t pos, int32_t nbElement, etk::VectorType &tmpBuffer); // insert functions void PushBack( const int8_t& item); void Insert( int32_t pos, const int8_t& item); - void Insert( int32_t pos, Edn::VectorType& items); + void Insert( int32_t pos, etk::VectorType& items); // Remove and insert functions void Replace( int32_t pos, const int8_t& item); - void Replace( int32_t pos, int32_t nbRemoveElement, Edn::VectorType& items); + void Replace( int32_t pos, int32_t nbRemoveElement, etk::VectorType& items); // Revove fonctions void Remove( int32_t pos, int32_t nbRemoveElement = 1); void PopBack( void); diff --git a/jni/edn/tools/EdnTemplate/Singleton.h b/jni/edn/tools/EdnTemplate/Singleton.h deleted file mode 100755 index ab84006..0000000 --- a/jni/edn/tools/EdnTemplate/Singleton.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - ******************************************************************************* - * @file Singleton.h - * @brief Editeur De N'ours : singleton system class - * @author Edouard DUPIN - * @date 04/12/2010 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - -#ifndef __SINGLETON_H__ -#define __SINGLETON_H__ - -#include -using namespace std; - - -///////////////////////////////////////////////////////////////////////////// -// -// Singleton - modèle Singleton applicable à n'importe quelle classe. -// -///////////////////////////////////////////////////////////////////////////// - -template -class Singleton -{ - protected: - // Constructeur/destructeur - Singleton() { } - ~Singleton() { /*std::cout << "destroying singleton." << std::endl;*/ } - - public: - // Interface publique - static T *getInstance() - { - if (NULL == _singleton) - { - /*std::cout << "C: Singleton | creating singleton." << std::endl;*/ - _singleton = new T; - } - /* - else - { - std::cout << "C: Singleton | singleton already created!" << std::endl; - } - */ - - return (static_cast (_singleton)); - } - - static void kill() - { - if (NULL != _singleton) - { - delete _singleton; - _singleton = NULL; - } - } - - private: - // Unique instance - static T *_singleton; -}; - -template - T *Singleton::_singleton = NULL; - -#endif - - diff --git a/jni/edn/tools/MsgBroadcast/AccelKey.cpp b/jni/edn/tools/MsgBroadcast/AccelKey.cpp index ddeac30..df14024 100644 --- a/jni/edn/tools/MsgBroadcast/AccelKey.cpp +++ b/jni/edn/tools/MsgBroadcast/AccelKey.cpp @@ -23,9 +23,9 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "AccelKey.h" - +#include +#include +#if 0 AccelKey::AccelKey(void) { m_accelGroup = gtk_accel_group_new(); @@ -94,4 +94,4 @@ void AccelKey::LinkCommonAccel(GtkWindow * widget) gtk_window_add_accel_group(GTK_WINDOW(widget), m_accelGroup); } - +#endif diff --git a/jni/edn/tools/MsgBroadcast/AccelKey.h b/jni/edn/tools/MsgBroadcast/AccelKey.h index 4b5c743..8d6166c 100644 --- a/jni/edn/tools/MsgBroadcast/AccelKey.h +++ b/jni/edn/tools/MsgBroadcast/AccelKey.h @@ -26,9 +26,9 @@ #ifndef __ACCEL_KEY_H__ #define __ACCEL_KEY_H__ -#include "tools_debug.h" -#include "Singleton.h" - +#include +#include +/* // need to create a syngleton ... class AccelKey: public Singleton { @@ -50,7 +50,7 @@ class AccelKey: public Singleton private: GtkAccelGroup * m_accelGroup; }; - +*/ #endif diff --git a/jni/edn/tools/MsgBroadcast/MsgBroadcast.cpp b/jni/edn/tools/MsgBroadcast/MsgBroadcast.cpp index c42399c..946efd1 100644 --- a/jni/edn/tools/MsgBroadcast/MsgBroadcast.cpp +++ b/jni/edn/tools/MsgBroadcast/MsgBroadcast.cpp @@ -23,9 +23,9 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "MsgBroadcast.h" +#include +#include +#include #undef __class__ #define __class__ "MsgBroadcast" @@ -33,7 +33,7 @@ MsgBroadcast::MsgBroadcast(const char * className, messageCat_te cat) { - m_messageSystem = MsgBroadcastCore::getInstance(); + m_messageSystem = MsgBroadcastCore::Get(); m_className = className; m_cat = cat; // add on listner @@ -282,5 +282,5 @@ void MsgBroadcastCore::RmReceiver(MsgBroadcast * pointerOnReceiver) void GeneralSendMessage(messageType_te id, int32_t dataID) { - MsgBroadcastCore::getInstance()->SendMessage(NULL, id, dataID); + MsgBroadcastCore::Get()->SendMessage(NULL, id, dataID); } diff --git a/jni/edn/tools/MsgBroadcast/MsgBroadcast.h b/jni/edn/tools/MsgBroadcast/MsgBroadcast.h index 8b6408a..7ca30cd 100644 --- a/jni/edn/tools/MsgBroadcast/MsgBroadcast.h +++ b/jni/edn/tools/MsgBroadcast/MsgBroadcast.h @@ -26,9 +26,9 @@ #ifndef __MSG_BROADCAST_H__ #define __MSG_BROADCAST_H__ -#include "tools_debug.h" -#include "Edn.h" -#include "Singleton.h" +#include +#include +#include @@ -163,7 +163,7 @@ class MsgBroadcastCore; class MsgBroadcast { private: - Edn::String m_className; + etk::String m_className; MsgBroadcastCore * m_messageSystem; messageCat_te m_cat; public: @@ -171,7 +171,7 @@ class MsgBroadcast virtual ~MsgBroadcast(void); // caul when a message is send virtual void OnMessage(int32_t id, int32_t dataID); - Edn::String& GetName(void) { return m_className; }; + etk::String& GetName(void) { return m_className; }; messageCat_te GetCat(void) { return m_cat; }; protected : void SendMessage(messageType_te id, int32_t dataID = -1); @@ -186,9 +186,9 @@ typedef struct { }messageElement_ts; // need to create a syngleton ... -class MsgBroadcastCore: public Singleton +class MsgBroadcastCore: public etk::Singleton { - friend class Singleton; + friend class etk::Singleton; // specific for sigleton system... private: // Constructeur @@ -200,17 +200,13 @@ class MsgBroadcastCore: public Singleton void RmReceiver(MsgBroadcast * pointerOnReceiver); private: - Edn::VectorType m_listMessage; + etk::VectorType m_listMessage; uint32_t m_messageID; - Edn::VectorType m_listOfMessage; + etk::VectorType m_listOfMessage; }; void GeneralSendMessage(messageType_te id, int32_t dataID = -1); - - - - #endif diff --git a/jni/edn/tools/NameSpaceEdn/Edn.h b/jni/edn/tools/NameSpaceEdn/Edn.h deleted file mode 100644 index 08b27bc..0000000 --- a/jni/edn/tools/NameSpaceEdn/Edn.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - ******************************************************************************* - * @file Edn.h - * @brief Editeur De N'ours : Basic namespace for Edn (header) - * @author Edouard DUPIN - * @date 16/07/2011 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - - -#include "tools_debug.h" -#include "toolsMemory.h" -//#include "Vector.h" // TODO : Set the vector of edn enable -#include "VectorType.h" - - -#include "String.h" - -#include "File.h" - diff --git a/jni/edn/tools/NameSpaceEdn/File.cpp b/jni/edn/tools/NameSpaceEdn/File.cpp deleted file mode 100644 index 66e0ce7..0000000 --- a/jni/edn/tools/NameSpaceEdn/File.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/** - ******************************************************************************* - * @file File.cpp - * @brief Editeur De N'ours : File folder and name abstraction (Sources) - * @author Edouard DUPIN - * @date 16/07/2011 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - - -#include "tools_debug.h" -#include "tools_globals.h" -#include "Edn.h" - - -#undef __class__ -#define __class__ "Edn::File" - - -std::ostream& Edn::operator <<(std::ostream &os, const Edn::File &obj) -{ - os << obj.m_folder; - os << "/"; - os << obj.m_shortFilename; - return os; -} - -Edn::File::File(Edn::String &filename, int32_t LineNumber) -{ - m_lineNumberOpen = LineNumber; - SetCompleateName(filename); -} - - -Edn::File::File(const char *filename, int32_t LineNumber) -{ - Edn::String tmpString = filename; - m_lineNumberOpen = LineNumber; - SetCompleateName(tmpString); -} - - -Edn::File::File(Edn::String &filename, Edn::String &folder, int32_t lineNumber) -{ - Edn::String tmpString = folder; - tmpString += '/'; - tmpString += filename; - SetCompleateName(tmpString); - m_lineNumberOpen = lineNumber; -} - -Edn::File::~File(void) -{ - // nothing to do ... -} - - -Edn::String Edn::File::GetFolder(void) const -{ - return m_folder; -} - -Edn::String Edn::File::GetShortFilename(void) const -{ - return m_shortFilename; -} - -Edn::String Edn::File::GetCompleateName(void) const -{ - Edn::String out; - out = m_folder; - out += '/'; - out += m_shortFilename; - return out; -} - -const Edn::File& Edn::File::operator= (const Edn::File &ednF ) -{ - if( this != &ednF ) // avoid copy to itself - { - m_folder = ednF.m_folder; - m_shortFilename = ednF.m_shortFilename; - m_lineNumberOpen = ednF.m_lineNumberOpen; - } - return *this; -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -bool Edn::File::operator== (const Edn::File &ednF) const -{ - if( this != &ednF ) { - if (ednF.GetCompleateName() == GetCompleateName() ) { - return true; - } else { - return false; - } - return true; - } - return true; -} - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -bool Edn::File::operator!= (const Edn::File &ednF) const -{ - return !(*this == ednF); -} - - -void Edn::File::SetCompleateName(Edn::String &newFilename) -{ - char buf[MAX_FILE_NAME]; - memset(buf, 0, MAX_FILE_NAME); - char * ok; - // Reset ALL DATA : - m_folder = ""; - m_shortFilename = ""; - m_lineNumberOpen = 0; - EDN_DEBUG("1 :Set Name : " << newFilename ); - Edn::String destFilename; - if (newFilename.Size() == 0) { - destFilename = "no-name"; - } else { - destFilename = newFilename; - } - EDN_DEBUG("2 : Get file Name : " << destFilename ); - if ('/' != *destFilename.c_str()) { - // Get the command came from the running of the program : - char cCurrentPath[FILENAME_MAX]; - if (!getcwd(cCurrentPath, FILENAME_MAX)) { - return; - } - cCurrentPath[FILENAME_MAX - 1] = '\0'; - Edn::String tmpFilename = destFilename; - destFilename = cCurrentPath; - destFilename += '/'; - destFilename += tmpFilename; - } - EDN_DEBUG("3 : Get file Name : " << destFilename ); - - // Get the real Path of the current File - ok = realpath(destFilename.c_str(), buf); - if (!ok) { - int32_t lastPos = destFilename.FindBack('/'); - if (-1 != lastPos) { - // Get the FileName - Edn::String tmpFilename = destFilename.Extract(lastPos+1); - destFilename.Remove(lastPos, destFilename.Size() - lastPos); - EDN_DEBUG("try to find :\"" << destFilename << "\" / \"" << tmpFilename << "\" "); - ok = realpath(destFilename.c_str(), buf); - if (!ok) { - EDN_ERROR("Can not find real Path name of \"" << destFilename << "\""); - m_shortFilename = tmpFilename; - m_folder = destFilename; - } else { - // ALL is OK ... - m_shortFilename = tmpFilename; - m_folder = destFilename; - } - } else { - EDN_WARNING("file : \"" << destFilename << "\" ==> No data???"); - // Basic ERROR ... - m_shortFilename = destFilename; - } - } else { - destFilename = buf; - int32_t lastPos = destFilename.FindBack('/'); - if (-1 != lastPos) { - m_shortFilename = destFilename.Extract(lastPos+1); - m_folder = destFilename.Extract(0, lastPos); - } else { - // Basic ERROR ... - EDN_WARNING("file : \"" << destFilename << "\" ==> No data???"); - m_shortFilename = destFilename; - } - } - EDN_DEBUG("Set FileName :\"" << m_folder << "\" / \"" << m_shortFilename << "\" "); -} - -int32_t Edn::File::GetLineNumber(void) -{ - return m_lineNumberOpen; -} - -void Edn::File::SetLineNumber(int32_t newline) -{ - m_lineNumberOpen = newline; -} - -bool Edn::File::HasExtention(void) -{ - int32_t lastPos = m_shortFilename.FindBack('.'); - if( -1 != lastPos // not find the . - && 0 != lastPos // Find a . at the fist position .jdlskjdfklj ==> hiden file - && m_shortFilename.Size() != lastPos ) // Remove file ended with . - { - return true; - } else { - return false; - } -} - - -Edn::String Edn::File::GetExtention(void) -{ - Edn::String tmpExt = ""; - int32_t lastPos = m_shortFilename.FindBack('.'); - if( -1 != lastPos // not find the . - && 0 != lastPos // Find a . at the fist position .jdlskjdfklj ==> hiden file - && m_shortFilename.Size() != lastPos ) // Remove file ended with . - { - // Get the FileName - tmpExt = m_shortFilename.Extract(lastPos+1); - } - return tmpExt; -} diff --git a/jni/edn/tools/NameSpaceEdn/File.h b/jni/edn/tools/NameSpaceEdn/File.h deleted file mode 100644 index 28a355f..0000000 --- a/jni/edn/tools/NameSpaceEdn/File.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - ******************************************************************************* - * @file File.h - * @brief Editeur De N'ours : File folder and name abstraction (header) - * @author Edouard DUPIN - * @date 16/07/2011 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - -#ifndef __EDN__FILE_H__ -#define __EDN__FILE_H__ - -#define MAX_FILE_NAME (10240) - -namespace Edn -{ - class File - { - public: - File(void) { m_lineNumberOpen=0; } - File(Edn::String &filename, int32_t LineNumber = 0); - File(const char *filename, int32_t LineNumber = 0); - File(Edn::String &filename, Edn::String &folder, int32_t lineNumber = 0); - ~File(void); - Edn::String GetFolder(void) const; - Edn::String GetShortFilename(void) const; - Edn::String GetCompleateName(void) const; - bool HasExtention(void); - Edn::String GetExtention(void); - int32_t GetLineNumber(void); - void SetLineNumber(int32_t newline); - void SetCompleateName(Edn::String &newFilename); - - const Edn::File& operator= (const Edn::File &ednF ); - bool operator== (const Edn::File &ednF ) const; - bool operator!= (const Edn::File &ednF ) const; - friend std::ostream& operator <<( std::ostream &os,const Edn::File &obj); - - private : - Edn::String m_folder; - Edn::String m_shortFilename; - int32_t m_lineNumberOpen; - }; - - std::ostream& operator <<(std::ostream &os, const Edn::File &obj); - -} - -#endif - diff --git a/jni/edn/tools/NameSpaceEdn/RegExp.cpp b/jni/edn/tools/NameSpaceEdn/RegExp.cpp deleted file mode 100644 index 3c41042..0000000 --- a/jni/edn/tools/NameSpaceEdn/RegExp.cpp +++ /dev/null @@ -1,488 +0,0 @@ -/** - ******************************************************************************* - * @file RegExp.cpp - * @brief Editeur De N'ours : Regular expression annalyser (sources) - * @author Edouard DUPIN - * @date 04/04/2011 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - -#include "tools_debug.h" -#include "tools_globals.h" -#include "toolsMemory.h" -#include "RegExp.h" - - - -const convertionTable_ts constConvertionTable[] = { - // haveBackSlash, inputValue, newValue - { false , '(' , OPCODE_PTHESE_IN}, - { true , '(' , (int16_t)'('}, - { false , ')' , OPCODE_PTHESE_OUT}, - { true , ')' , (int16_t)')'}, - { false , '[' , OPCODE_BRACKET_IN}, - { true , '[' , (int16_t)'['}, - { false , ']' , OPCODE_BRACKET_OUT}, - { true , ']' , (int16_t)']'}, - { false , '{' , OPCODE_BRACE_IN}, - { true , '{' , (int16_t)'{'}, - { false , '}' , OPCODE_BRACE_OUT}, - { true , '}' , (int16_t)'}'}, - { false , '-' , OPCODE_TO}, - { true , '-' , (int16_t)'-'}, - { false , '*' , OPCODE_STAR}, - { true , '*' , (int16_t)'*'}, - { false , '.' , OPCODE_DOT}, - { true , '.' , (int16_t)'.'}, - { false , '?' , OPCODE_QUESTION}, - { true , '?' , (int16_t)'?'}, - { false , '+' , OPCODE_PLUS}, - { true , '+' , (int16_t)'+'}, - { false , '|' , OPCODE_PIPE}, - { true , '|' , (int16_t)'|'}, - { false , '^' , OPCODE_START_OF_LINE}, - { true , '^' , (int16_t)'^'}, - { false , '$' , OPCODE_END_OF_LINE}, - { true , '$' , (int16_t)'$'}, - { true , 'd' , OPCODE_DIGIT}, - { true , 'D' , OPCODE_DIGIT_NOT}, - { true , 'l' , OPCODE_LETTER}, - { true , 'L' , OPCODE_LETTER_NOT}, - { true , 's' , OPCODE_SPACE}, - { true , 'S' , OPCODE_SPACE_NOT}, - { true , 'w' , OPCODE_WORD}, - { true , 'W' , OPCODE_WORD_NOT}, - { true , 'a' , (int16_t)'\a'}, - { true , 'b' , (int16_t)'\b'}, - { true , 'e' , 0x001B}, // Escape character - { true , 'f' , (int16_t)'\f'}, - { true , 'n' , (int16_t)'\n'}, - { true , 'r' , (int16_t)'\r'}, - { true , 't' , (int16_t)'\t'}, - { true , 'v' , (int16_t)'\v'}, - { true , '\\' , (int16_t)'\\'}, - { true , '&' , (int16_t)'&'}, - { true , '0' , (int16_t)'\0'}, - { true , '@' , OPCODE_NO_CHAR}, -}; -const int32_t constConvertionTableSize = sizeof(constConvertionTable) / sizeof(convertionTable_ts) ; - - -/** - * @brief Display the internal data of a node - * - * @param[in] data element do display in the console - * - * @return --- - * - */ -void DisplayData(Edn::VectorType &data) -{ - int32_t i; - for (i=0; i<(int32_t)data.Size() ; i++) { - std::cout<< (char)(data[i]&0x00FF ); - } -} - -/** - * @brief Display of a part of the Regexp element - * - * @param[in] data Vector where data is constain - * @param[in] start Position where the display might start - * @param[in] stop Position where the display might stop - * - * @return --- - * - */ -void DisplayElem(Edn::VectorType &data, int32_t start, int32_t stop) -{ - int32_t i; - std::cout<< COLOR_NORMAL; - for (i=start; i<(int32_t)data.Size() && i &data, int32_t startPos) -{ - int32_t pos = startPos; - int32_t nbOpen = 0; - // special case of the (...) or | ==> we search '|' or ')' - if( OPCODE_PTHESE_OUT == data[pos] - || OPCODE_PIPE == data[pos]) { - return 0; - } - // find size ... - while (pos < (int32_t)data.Size() ) { - if(OPCODE_PTHESE_IN == data[pos]) { - // find a sub section : - nbOpen++; - } else if(0 < nbOpen) { - if (OPCODE_PTHESE_OUT == data[pos]) - { - nbOpen--; - if (0 > nbOpen) { - EDN_ERROR("Error in the (...) find element at "<< pos); - return -1; - } - } - } else if( OPCODE_PTHESE_OUT == data[pos] - || OPCODE_PIPE == data[pos]) - { - // Find the end of the (...) - // just return the size inside - int32_t sizeInside = pos - startPos; - if (0 >= sizeInside) { - EDN_ERROR("Error in the (...) no data at "<< pos-1); - return -1; - } else { - return sizeInside; - } - } - pos++; - } - return pos - startPos; -} - -/** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ -int32_t GetLenOfPThese(Edn::VectorType &data, int32_t startPos) -{ - int32_t pos = startPos; - int32_t nbOpen = 0; - // special case of the (...) or | ==> we search '|' or ')' - if( OPCODE_PTHESE_OUT == data[pos]) { - return 0; - } else if( OPCODE_PTHESE_IN == data[pos]) - { - pos++; - // find size ... - while (pos < (int32_t)data.Size() ) { - if(OPCODE_PTHESE_IN == data[pos]) { - // find a sub section : - nbOpen++; - } else if(0 < nbOpen) { - if (OPCODE_PTHESE_OUT == data[pos]) - { - nbOpen--; - if (0 > nbOpen) { - EDN_ERROR("Error in the (...) find element at "<< pos); - return -1; - } - } - } else if( OPCODE_PTHESE_OUT == data[pos]) - { - // Find the end of the (...) - // just return the size inside - int32_t sizeInside = pos - startPos-1; - if (0 >= sizeInside) { - EDN_ERROR("Error in the (...) no data at "<< pos-1); - return -1; - } else { - return sizeInside; - } - } - pos++; - } - } else { - return -1; - } - return 0; -} - - -/** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ -int32_t GetLenOfBracket(Edn::VectorType &data, int32_t startPos) -{ - int32_t pos = startPos; - // special case of the (...) or | ==> we search '|' or ')' - if( OPCODE_BRACKET_OUT == data[pos]) { - return 0; - } else if( OPCODE_BRACKET_IN == data[pos]) { - pos++; - // find size ... - while (pos < (int32_t)data.Size() ) { - if(OPCODE_BRACKET_OUT == data[pos]) { - // Find the end of the [...] - // just return the size inside - int32_t sizeInside = pos - startPos -1 ; - if (0 >= sizeInside) { - EDN_ERROR("Error in the [...] no data at "<< pos-1); - return sizeInside; - } else { - return sizeInside; - } - } else if( OPCODE_TO != data[pos] - && ( 0 > data[pos] - || 0xFF < data[pos]) ) - { - EDN_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)data[pos] << "'"); - return false; - } - pos++; - } - } else { - return -1; - } - return 0; -} - - -/** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ -int32_t GetLenOfBrace(Edn::VectorType &data, int32_t startPos) -{ - int32_t pos = startPos; - // special case of the (...) or | ==> we search '|' or ')' - if( OPCODE_BRACE_OUT == data[pos]) { - return 0; - } else if( OPCODE_BRACE_IN == data[pos]) { - pos++; - // find size ... - while (pos < (int32_t)data.Size() ) { - if(OPCODE_BRACE_OUT == data[pos]) { - // Find the end of the [...] - // just return the size inside - int32_t sizeInside = pos - startPos -1 ; - if (0 >= sizeInside) { - EDN_ERROR("Error in the {...} no data at "<< pos-1); - return sizeInside; - } else { - return sizeInside; - } - } else if( ',' != data[pos] - && ( '0' > data[pos] - || '9' < data[pos]) ) - { - EDN_ERROR("Error in the {...} not permited element at "<< pos << " '" << (char)data[pos] << "'"); - return false; - } - pos++; - } - } else { - return -1; - } - return 0; -} - - -/** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ -int32_t GetLenOfNormal(Edn::VectorType &data, int32_t startPos) -{ - int32_t pos = startPos; - - // find size ... - while (pos < (int32_t)data.Size() ) { - switch(data[pos]) - { - case OPCODE_PTHESE_IN: - case OPCODE_PTHESE_OUT: - case OPCODE_BRACKET_IN: - case OPCODE_BRACKET_OUT: - case OPCODE_BRACE_IN: - case OPCODE_BRACE_OUT: - case OPCODE_TO: - case OPCODE_STAR: - case OPCODE_DOT: - case OPCODE_QUESTION: - case OPCODE_PLUS: - case OPCODE_PIPE: - case OPCODE_START_OF_LINE: - case OPCODE_END_OF_LINE: - case OPCODE_DIGIT: - case OPCODE_DIGIT_NOT: - case OPCODE_LETTER: - case OPCODE_LETTER_NOT: - case OPCODE_SPACE: - case OPCODE_SPACE_NOT: - case OPCODE_WORD: - case OPCODE_WORD_NOT: - { - // just return the size inside - int32_t sizeInside = pos - startPos; - if (0 >= sizeInside) { - EDN_ERROR("Error in the normal data : no data ..."); - } - return sizeInside; - } - break; - default : - // nothing to do ... - break; - } - pos++; - } - return pos - startPos ; -} - - -/** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ -bool ParseBrace(Edn::VectorType &data, int32_t &min, int32_t &max) -{ - //EDN_INFO("parse {...} in "; DisplayElem(data); ); - int32_t k=0; - - int32_t firstElement = 0; - int32_t SecondElement = 0; - - while(k= (char)data[k]) { - firstElement *=10; - firstElement += (char)data[k] - '0'; - } else { - EDN_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k); - return false; - } - k++; - } - if (k==data.Size()) { - SecondElement = firstElement; - } - while(k= (char)data[k]) { - SecondElement *=10; - SecondElement += (char)data[k] - '0'; - } else { - EDN_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k); - return false; - } - k++; - } - -allIsSet: - if (SecondElement == 0 && firstElement != 0) { - min = 0; - max = firstElement; - } else { - min = firstElement; - max = SecondElement; - } - if (min > max) { - EDN_ERROR("Minimum=" << min << " can not be < maximum=" << max ); - return false; - } - return true; -} - - diff --git a/jni/edn/tools/NameSpaceEdn/RegExp.h b/jni/edn/tools/NameSpaceEdn/RegExp.h deleted file mode 100644 index 7b9804c..0000000 --- a/jni/edn/tools/NameSpaceEdn/RegExp.h +++ /dev/null @@ -1,2113 +0,0 @@ -/** - ******************************************************************************* - * @file RegExp.h - * @brief Editeur De N'ours : Regular expression annalyser (header) - * @author Edouard DUPIN - * @date 04/04/2011 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ -#ifndef __EDN_REG_EXP_H__ -#define __EDN_REG_EXP_H__ - -#include "VectorType.h" -#include "Edn.h" - -/* -normal mode : - (...) sub element is separate with | - \d Digits [0-9] - \D NOT a digit [^0-9] - \l Letters [a-zA-Z] - \L NOT a Letter [^a-zA-Z] - \s Whitespace [ \t\n\r\f\v] - \S NOT Whitespace [^ \t\n\r\f\v] - \w "Word" character [a-zA-Z0-9_] - \W NOT a "Word" character [^a-zA-Z0-9_] - \@ at the start or the end not in the parsing of element ==> check if \w is not present (other regExp will be <> ...) - [anjdi] or [a-gt-j] range - . dot [^\x00-\x08\x0A-\x1F\x7F] -==> TODO : - $ End / Start of line of line ==> ce sera un truc suplémentaire comme le \@ - ^in the [] invertion of the range element - -multiplicity : - * ==> {0, 2147483647} - ? ==> {0, 1} - + ==> {1, 2147483647} - {x} ==> {x, x} - {x,y} ==> {x, y} -*/ - - -// internal define to permit to have all neeed system -#define OPCODE_PTHESE_IN (-300) /* ( */ -#define OPCODE_PTHESE_OUT ( 300) /* ) */ -#define OPCODE_BRACKET_IN (-301) /* [ */ -#define OPCODE_BRACKET_OUT ( 301) /* ] */ -#define OPCODE_BRACE_IN (-302) /* { */ -#define OPCODE_BRACE_OUT ( 302) /* } */ -#define OPCODE_TO (-305) /* - */ -#define OPCODE_STAR (-306) /* * */ -#define OPCODE_DOT (-307) /* . */ -#define OPCODE_QUESTION (-308) /* ? */ -#define OPCODE_PLUS (-309) /* + */ -#define OPCODE_PIPE (-310) /* | */ -#define OPCODE_START_OF_LINE (-311) /* ^ this is also NOT, but not manage */ -#define OPCODE_END_OF_LINE (-312) /* $ */ -#define OPCODE_DIGIT ( 313) /* \d */ -#define OPCODE_DIGIT_NOT (-313) /* \D */ -#define OPCODE_LETTER ( 314) /* \l */ -#define OPCODE_LETTER_NOT (-314) /* \L */ -#define OPCODE_SPACE ( 315) /* \s */ -#define OPCODE_SPACE_NOT (-315) /* \S */ -#define OPCODE_WORD ( 316) /* \w */ -#define OPCODE_WORD_NOT (-316) /* \W */ -#define OPCODE_NO_CHAR (-317) /* \@ */ - -typedef struct { - bool haveBackSlash; - char inputValue; - int16_t newValue; -}convertionTable_ts; - -extern const convertionTable_ts constConvertionTable[]; -extern const int32_t constConvertionTableSize; - -void DisplayData(Edn::VectorType &data); -void DisplayElem(Edn::VectorType &data, int32_t start=0, int32_t stop=0x7FFFFFFF); -char * levelSpace(int32_t level); -int32_t GetLenOfPTheseElem(Edn::VectorType &data, int32_t startPos); -int32_t GetLenOfPThese(Edn::VectorType &data, int32_t startPos); -int32_t GetLenOfBracket(Edn::VectorType &data, int32_t startPos); -int32_t GetLenOfBrace(Edn::VectorType &data, int32_t startPos); -int32_t GetLenOfNormal(Edn::VectorType &data, int32_t startPos); -bool ParseBrace(Edn::VectorType &data, int32_t &min, int32_t &max); - - -#undef __class__ -#define __class__ "RegExpNode" - -/** - * @brief Node Elements for every-one - */ -template class RegExpNode{ - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNode(void) - { - SetMult(1,1); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - virtual ~RegExpNode(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - virtual int32_t Generate(Edn::VectorType &data, int32_t startPos, int32_t nbElement) - { - return 0; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - virtual bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - virtual void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@???@ {" << GetMultMin() << "," << GetMultMax() << "} subdata="; DisplayElem(m_RegExpData);); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void SetMult(int32_t min, int32_t max) - { - m_multipleMin = edn_max(min, 0); - m_multipleMax = edn_max(max, 1); - } - protected: - /** - * @brief - * @param[in,out] - * @return - */ - int32_t GetMultMin(void) - { - return m_multipleMin; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - int32_t GetMultMax(void) - { - return m_multipleMax; - }; - protected : - int32_t m_multipleMin; //!< minimum repetition (included) - int32_t m_multipleMax; //!< maximum repetition (included) - // Data Section ... (can have no data...) - Edn::VectorType m_RegExpData; //!< data to parse and compare in some case ... -}; - -#undef __class__ -#define __class__ "RegExpNodeValue" - -template class RegExpNodeValue : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeValue(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeValue(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - int32_t Generate(Edn::VectorType &data) - { - RegExpNode::m_RegExpData = data; - //EDN_DEBUG("Request Parse \"Value\" data="; DisplayElem(RegExpNode::m_RegExpData);); - m_data.Clear(); - for (int32_t i=0; i::m_RegExpData.Size(); i++) { - m_data.PushBack((char)RegExpNode::m_RegExpData[i]); - } - return data.Size(); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : Value{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - if (0==m_data.Size()) { - EDN_ERROR("No data inside type elemTypeValue"); - return false; - } - //EDN_DEBUG("check element value : '" << m_data[0] << "'"); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind == true; j++) { - int32_t ofset = 0; - int32_t k; - for (k=0; findLen+k=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@Value@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData); std::cout<< " data: "; DisplayData(m_data); ); - }; - protected : - // SubNodes : - Edn::VectorType m_data; -}; -#undef __class__ -#define __class__ "RegExpNodeBracket" - -template class RegExpNodeBracket : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeBracket(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeBracket(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - int32_t Generate(Edn::VectorType &data) - { - RegExpNode::m_RegExpData = data; - //EDN_DEBUG("Request Parse [...] data="; DisplayElem(RegExpNode::m_RegExpData);); - m_data.Clear(); - - char lastElement = 'a'; - bool multipleElement = false; - // - for (int32_t k=0; k::m_RegExpData.Size(); k++) { - if (RegExpNode::m_RegExpData[k] == OPCODE_TO && multipleElement == true) { - EDN_ERROR("Can not have 2 consecutive - in [...]"); - return 0; - } else if (multipleElement == true) { - char j='\0'; - for (j=lastElement+1; j <= (char)RegExpNode::m_RegExpData[k]; j++) { - m_data.PushBack(j); - } - multipleElement = false; - } else if(RegExpNode::m_RegExpData[k] == OPCODE_TO) { - multipleElement = true; - } else { - lastElement = (char)RegExpNode::m_RegExpData[k]; - m_data.PushBack(lastElement); - } - } - // check size ... - if (m_data.Size() == 0) { - EDN_ERROR("No data inside [...] "); - return 0; - } - return data.Size(); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : [...]{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - if (0==m_data.Size()) { - EDN_ERROR("No data inside type elemTypeValue"); - return false; - } - //EDN_DEBUG("one of element value List : "; DisplayData(element->m_data);); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - int32_t i; - tmpFind=false; - for (i=0; i=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@[...]@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData); std::cout<< " data: "; DisplayData(m_data); ); - }; - protected : - // SubNodes : - Edn::VectorType m_data; -}; -#undef __class__ -#define __class__ "RegExpNodeDigit" - -template class RegExpNodeDigit : public RegExpNode { - public : - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeDigit(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeDigit(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : Digit{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} : "<< data[currentPos] << " lenMax=" << lenMax); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - //EDN_DEBUG("compare : " << tmpVal); - if( '0' <= tmpVal - && '9' >= tmpVal) - { - //EDN_DEBUG("find ++"); - findLen += 1; - } else { - tmpFind=false; - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@Digit@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; -#undef __class__ -#define __class__ "RegExpNodeDigitNot" - -template class RegExpNodeDigitNot : public RegExpNode { - public : - RegExpNodeDigitNot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeDigitNot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : DigitNot{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( '0' > tmpVal - || '9' < tmpVal) - { - findLen += 1; - } else { - tmpFind=false; - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@DigitNot@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; -#undef __class__ -#define __class__ "RegExpNodeLetter" - -template class RegExpNodeLetter : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeLetter(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeLetter(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : Letter{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal )) - { - findLen += 1; - } else { - tmpFind=false; - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@Letter@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; -#undef __class__ -#define __class__ "RegExpNodeLetterNot" - -template class RegExpNodeLetterNot : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeLetterNot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeLetterNot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : LetterNot{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 'a' > tmpVal - && 'Z' < tmpVal ) - || 'A' > tmpVal - || 'z' < tmpVal ) - { - findLen += 1; - } else { - tmpFind=false; - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@LetterNot@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; -#undef __class__ -#define __class__ "RegExpNodeWhiteSpace" - -template class RegExpNodeWhiteSpace : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeWhiteSpace(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeWhiteSpace(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : Space{" << m_multipleMin << "," << m_multipleMax << "}"); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ' ' == tmpVal - || '\t' == tmpVal - || '\n' == tmpVal - || '\r' == tmpVal - || '\f' == tmpVal - || '\v' == tmpVal ) - { - findLen += 1; - } else { - tmpFind=false; - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@Space@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; -#undef __class__ -#define __class__ "RegExpNodeWhiteSpaceNot" - -template class RegExpNodeWhiteSpaceNot : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeWhiteSpaceNot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeWhiteSpaceNot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : SpaceNot{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ' ' != tmpVal - && '\t' != tmpVal - && '\n' != tmpVal - && '\r' != tmpVal - && '\f' != tmpVal - && '\v' != tmpVal ) - { - findLen += 1; - } else { - tmpFind=false; - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@SpaceNot@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; -#undef __class__ -#define __class__ "RegExpNodeWordChar" - -template class RegExpNodeWordChar : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeWordChar(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeWordChar(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : Word{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal )) - { - findLen += 1; - } else { - tmpFind=false; - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@Word@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; -#undef __class__ -#define __class__ "RegExpNodeWordCharNot" - -template class RegExpNodeWordCharNot : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeWordCharNot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeWordCharNot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : WordNot{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 'A' > tmpVal - && '9' < tmpVal ) - || ( 'a' > tmpVal - && 'Z' < tmpVal ) - || '0' > tmpVal - || 'z' < tmpVal ) - { - findLen += 1; - } else { - tmpFind=false; - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@WordNot@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; -#undef __class__ -#define __class__ "RegExpNodeDot" - -template class RegExpNodeDot : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeDot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeDot(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : '.'{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - // equivalent a : [^\x00-\x08\x0A-\x1F\x7F] - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 0x08 < tmpVal - && 0x0A > tmpVal ) - || ( 0x1F < tmpVal - && 0x7F > tmpVal ) - || ( 0x7F < tmpVal - && 0xFF > tmpVal )) - { - findLen += 1; - } else { - tmpFind=false; - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@.@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; - -#undef __class__ -#define __class__ "RegExpNodeSOL" - -template class RegExpNodeSOL : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeSOL(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeSOL(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - EDN_INFO("Parse node : SOL{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@SOL@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; - -#undef __class__ -#define __class__ "RegExpNodeEOL" - -template class RegExpNodeEOL : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodeEOL(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeEOL(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - EDN_INFO("Parse node : EOL{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@EOL@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - }; -}; - -typedef struct { - int32_t start; - int32_t stop; -}elementPos_ts; - -#undef __class__ -#define __class__ "RegExpNodePTheseElem" - -template class RegExpNodePThese; - -template class RegExpNodePTheseElem : public RegExpNode { - public : - - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodePTheseElem(void) - { - - }; - - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodePTheseElem(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - int32_t Generate(Edn::VectorType &data) - { - RegExpNode::m_RegExpData = data; - //EDN_DEBUG("Request Parse (elem) data="; DisplayElem(RegExpNode::m_RegExpData);); - - int32_t pos = 0; - int32_t elementSize = 0; - Edn::VectorType tmpData; - while (pos < RegExpNode::m_RegExpData.Size()) { - tmpData.Clear(); - switch (RegExpNode::m_RegExpData[pos]) - { - case OPCODE_PTHESE_IN: - { - elementSize=GetLenOfPThese(RegExpNode::m_RegExpData, pos); - for (int32_t k=pos+1; k::m_RegExpData[k]); - } - RegExpNodePThese * myElem = new RegExpNodePThese(); - (void)myElem->Generate(tmpData); - // add to the subnode list : - m_subNode.PushBack(myElem); - // move current position ... - pos += elementSize+1; - } - break; - case OPCODE_PTHESE_OUT: - EDN_ERROR("Impossible case : ')' " << pos); - return false; - - case OPCODE_BRACKET_IN: - { - elementSize=GetLenOfBracket(RegExpNode::m_RegExpData, pos); - for (int32_t k=pos+1; k::m_RegExpData[k]); - } - RegExpNodeBracket * myElem = new RegExpNodeBracket(); - (void)myElem->Generate(tmpData); - // add to the subnode list : - m_subNode.PushBack(myElem); - // move current position ... - pos += elementSize+1; - } - break; - case OPCODE_BRACKET_OUT: - EDN_ERROR("Impossible case : ']' " << pos); - return false; - - case OPCODE_BRACE_IN: - { - elementSize=GetLenOfBrace(RegExpNode::m_RegExpData, pos); - for (int32_t k=pos+1; k::m_RegExpData[k]); - } - int32_t min = 0; - int32_t max = 0; - if (false == ParseBrace(tmpData, min, max)) { - return false; - } - SetMultiplicityOnLastNode(min, max); - pos += elementSize+1; - } - break; - case OPCODE_BRACE_OUT: - EDN_ERROR("Impossible case : '}' " << pos); - return false; - - case OPCODE_TO: - EDN_ERROR("Impossible case : '-' " << pos); - return false; - - case OPCODE_STAR: - SetMultiplicityOnLastNode(0, 0x7FFFFFFF); - break; - - case OPCODE_QUESTION: - SetMultiplicityOnLastNode(0, 1); - break; - - case OPCODE_PLUS: - SetMultiplicityOnLastNode(1, 0x7FFFFFFF); - break; - - case OPCODE_PIPE: - EDN_ERROR("Impossible case : '|' " << pos); - return false; - - case OPCODE_DOT: - m_subNode.PushBack(new RegExpNodeDot()); - break; - - case OPCODE_START_OF_LINE: - m_subNode.PushBack(new RegExpNodeSOL()); - break; - - case OPCODE_END_OF_LINE: - m_subNode.PushBack(new RegExpNodeEOL()); - break; - - case OPCODE_DIGIT: - m_subNode.PushBack(new RegExpNodeDigit()); - break; - - case OPCODE_DIGIT_NOT: - m_subNode.PushBack(new RegExpNodeDigitNot()); - break; - - case OPCODE_LETTER: - m_subNode.PushBack(new RegExpNodeLetter()); - break; - - case OPCODE_LETTER_NOT: - m_subNode.PushBack(new RegExpNodeLetterNot()); - break; - - case OPCODE_SPACE: - m_subNode.PushBack(new RegExpNodeWhiteSpace()); - break; - - case OPCODE_SPACE_NOT: - m_subNode.PushBack(new RegExpNodeWhiteSpaceNot()); - break; - - case OPCODE_WORD: - m_subNode.PushBack(new RegExpNodeWordChar()); - break; - - case OPCODE_WORD_NOT: - m_subNode.PushBack(new RegExpNodeWordCharNot()); - break; - - default: - { - elementSize=GetLenOfNormal(RegExpNode::m_RegExpData, pos); - for (int32_t k=pos; k::m_RegExpData[k]); - } - RegExpNodeValue * myElem = new RegExpNodeValue(); - (void)myElem->Generate(tmpData); - // add to the subnode list : - m_subNode.PushBack(myElem); - // move current position ... - pos += elementSize-1; - } - break; - } - pos++; - } - return data.Size(); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : (Elem){" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - // NOTE 1 : Must done only one time in EVERY case ... - // NOTE 2 : All element inside must be OK - if (0 == m_subNode.Size()) { - return false; - } - int32_t tmpCurrentPos = currentPos; - for (int32_t i=0; iParse(data, tmpCurrentPos, lenMax, tmpFindLen)) { - findLen = 0; - return false; - } else { - tmpCurrentPos += tmpFindLen; - } - } - findLen = tmpCurrentPos - currentPos; - return true; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - EDN_INFO("Find NODE : " << levelSpace(level) << "@(Elem)@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - for(int32_t i=0; iDisplay(level+1); - } - }; - protected : - // SubNodes : - Edn::VectorType*> m_subNode; - private : - /** - * @brief Set the number of repeate time on a the last node in the list ... - * - * @param[in] min Minimum of the multiplicity - * @param[in] max Maximum of the multiplicity - * - * @return true if we find the node, false otherwise - * - */ - bool SetMultiplicityOnLastNode(int32_t min, int32_t max) - { - if (0==m_subNode.Size()) { - EDN_ERROR("Set multiplicity on an inexistant element ...."); - return false; - } - RegExpNode * myNode = m_subNode[m_subNode.Size()-1]; - if (NULL==myNode) { - EDN_ERROR("INTERNAL error ==> node not generated"); - return false; - } - myNode->SetMult(min, max); - return true; - } -}; - -#undef __class__ -#define __class__ "RegExpNodePThese" - -template class RegExpNodePThese : public RegExpNode { - public : - /** - * @brief - * @param[in,out] - * @return - */ - RegExpNodePThese(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodePThese(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - int32_t Generate(Edn::VectorType &data) - { - RegExpNode::m_RegExpData = data; - //EDN_DEBUG("Request Parse (...) data="; DisplayElem(RegExpNode::m_RegExpData);); - //Find all the '|' in the string (and at the good level ...) - int32_t pos = 0; - int32_t elementSize = GetLenOfPTheseElem(RegExpNode::m_RegExpData, pos); - // generate all the "elemTypePTheseElem" of the Node - while (elementSize>0) { - // geerate output deta ... - Edn::VectorType tmpData; - for (int32_t k=pos; k::m_RegExpData[k]); - } - RegExpNodePTheseElem * myElem = new RegExpNodePTheseElem(); - (void)myElem->Generate(tmpData); - // add to the subnode list : - m_subNode.PushBack(myElem); - pos += elementSize+1; - //EDN_DEBUG("plop="; DisplayElem(data, pos, pos+1);); - elementSize = GetLenOfPTheseElem(RegExpNode::m_RegExpData, pos); - //EDN_DEBUG("find " << elementSize << " elements"); - } - if (0 == pos && 0 == elementSize) { - EDN_ERROR("No data in the (...) element at " << pos); - return false; - } - return data.Size(); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; - //EDN_INFO("Parse node : (...){" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); - if (0 == m_subNode.Size()) { - return false; - } - bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind == true ; j++) { - tmpFind = false; - for (int32_t i=0; iParse(data, currentPos+findLen, lenMax, tmpFindLen)) { - findLen += tmpFindLen; - tmpFind = true; - } - } - } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { - //EDN_DEBUG("find " << findLen); - return true; - } else if( 0 == RegExpNode::m_multipleMin ) { - //EDN_DEBUG("find size=0"); - return true; - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) - { - if (-1 == level) { - EDN_INFO("regExp :"; DisplayElem(RegExpNode::m_RegExpData);); - } else { - EDN_INFO("Find NODE : " << levelSpace(level) << "@(...)@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - for(int32_t i=0; iDisplay(level+1); - } - } - }; - - protected : - // SubNodes : - Edn::VectorType*> m_subNode; - //int32_t m_posPthese; //!< position of the element is detected in the output element -}; -#undef __class__ -#define __class__ "EdnRegExp" - -// Regular expression manager -template class EdnRegExp { - // public API : - public: - // create the regular expression - - /** - * @brief - * @param[in,out] - * @return - */ - EdnRegExp(const char *exp) - { - m_isOk = false; - m_areaFind.start=0; - m_areaFind.stop=0; - m_notBeginWithChar = false; - m_notEndWithChar = false; - SetRegExp(exp); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - EdnRegExp(Edn::String &exp) - { - m_isOk = false; - m_areaFind.start=0; - m_areaFind.stop=0; - m_notBeginWithChar = false; - m_notEndWithChar = false; - SetRegExp(exp); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - EdnRegExp(void) - { - m_isOk = false; - m_areaFind.start=0; - m_areaFind.stop=0; - m_notBeginWithChar = false; - m_notEndWithChar = false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~EdnRegExp(void) - { - // TODO : remove all under nodes... - m_isOk = false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void SetRegExp(const char *exp) - { - EDN_CHECK_INOUT(exp); - Edn::String expressionRequested = exp; - SetRegExp(expressionRequested); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void SetRegExp(Edn::String &expressionRequested) - { - m_expressionRequested = expressionRequested; // TODO : Must be deprecated ... - Edn::VectorType tmpExp; - - //EDN_DEBUG("Parse RegExp : " << expressionRequested.c_str() ); - m_isOk = false; - m_areaFind.start=0; - m_areaFind.stop=0; - m_notBeginWithChar = false; - m_notEndWithChar = false; - - char * exp = expressionRequested.c_str(); - int32_t regExpLen = strlen(exp); - // change in the regular Opcode ==> replace \x with the corect element ... x if needed - int32_t iii; - int32_t countBraceIn = 0; - int32_t countBraceOut = 0; - int32_t countPTheseIn = 0; - int32_t countPTheseOut = 0; - int32_t countBracketIn = 0; - int32_t countBracketOut = 0; - for (iii=0; iii=regExpLen) { - EDN_ERROR("Dangerous parse of the element pos " << iii << " \\ with nothing after"); - // TODO : Generate Exeption ... - return; - } - int32_t j; - // Find the element in the list... - for (j=0; j0 - && OPCODE_NO_CHAR == tmpExp[0]) - { - //EDN_DEBUG("=> must not begin with char"); - m_notBeginWithChar = true; - // remove element - tmpExp.Erase(0); - } - if( tmpExp.Size()>0 - && OPCODE_NO_CHAR == tmpExp[tmpExp.Size()-1]) - { - //EDN_DEBUG("=> must not end with char"); - m_notEndWithChar = true; - // remove element - tmpExp.Erase(tmpExp.Size()-1); - } - - if (tmpExp.Size() != m_exprRootNode.Generate(tmpExp) ) { - return; - } - // TODO : optimize node here ... - - //Display(); - - // all OK ... play again - m_isOk = true; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - Edn::String GetRegExp(void) - { - return m_expressionRequested; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool GetStatus(void) - { - return m_isOk; - }; - // process the regular expression - - /** - * @brief - * @param[in,out] - * @return - */ - bool Process( CLASS_TYPE &SearchIn, - int32_t startPos, - int32_t endPos, - char escapeChar=0) - { - if (false == m_isOk) { - return false; - } - int32_t buflen = SearchIn.Size(); - if (endPos > buflen) { - endPos = buflen; - } - if (startPos > endPos) { - return false; - } - int32_t i = 0; - for (i=startPos; i0) { - char tmpVal = SearchIn[i-1]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal ) - || ( '_' == tmpVal ) ) - { - // go on the next char ... - continue; - } - } - } - if (true == m_exprRootNode.Parse(SearchIn, i, maxlen, findLen)) { - if( 0!=escapeChar - && i>0) - { - if (escapeChar == (char)SearchIn[i-1]) { - //==> detected escape char ==> try find again ... - continue; - } - } - // Check end : - if (true == m_notEndWithChar) { - if (i+findLen < SearchIn.Size() ) { - char tmpVal = SearchIn[i+findLen]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal ) - || ( '_' == tmpVal ) ) - { - // go on the next char ... - continue; - } - } - } - m_areaFind.start = i; - m_areaFind.stop = i + findLen; - /* - if (i == 812) { - std::cout << std::endl; - for(int32_t k=startPos; k buflen) { - endPos = buflen; - } - if (startPos > endPos) { - return false; - } - int32_t findLen=0; - int32_t maxlen = endPos-startPos; - if (true == m_notBeginWithChar) { - if (startPos>0) { - char tmpVal = SearchIn[startPos-1]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal ) - || ( '_' == tmpVal ) ) - { - // go on the next char ... - return false; - } - } - } - if (true == m_exprRootNode.Parse(SearchIn, startPos, maxlen, findLen)) { - if( 0!=escapeChar - && startPos>0) - { - if (escapeChar == (char)SearchIn[startPos-1]) { - //==> detected escape char ==> try find again ... - return false; - } - } - // Check end : - if (true == m_notEndWithChar) { - if (startPos+findLen < SearchIn.Size() ) { - char tmpVal = SearchIn[startPos+findLen]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal ) - || ( '_' == tmpVal ) ) - { - // go on the next char ... - return false; - } - } - } - m_areaFind.start = startPos; - m_areaFind.stop = startPos + findLen; - return true; - } - return false; - }; - - - /** - * @brief - * @param[in,out] - * @return - */ - int32_t Start(void) - { - return m_areaFind.start; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - int32_t Stop(void) - { - return m_areaFind.stop; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - void Display(void) - { - m_exprRootNode.Display(0); - }; - // internal parameters - private: - Edn::String m_expressionRequested; // TODO : Remove ... - elementPos_ts m_areaFind; //!< position around selection - RegExpNodePThese m_exprRootNode; //!< The tree where data is set - bool m_isOk; //!< Known if we can process with this regExp - bool m_notBeginWithChar; //!< The regular expression must not have previously a char [a-zA-Z0-9_] - bool m_notEndWithChar; //!< The regular expression must not have after the end a char [a-zA-Z0-9_] - // internal access - private: - /** - * @brief - * @param[in,out] - * @return - */ - bool CheckGoodPosition(Edn::VectorType tmpExp, int32_t &pos) - { - int16_t curentCode = tmpExp[pos]; - int16_t endCode = OPCODE_PTHESE_OUT; - char *input = (char*)"(...)"; - if (OPCODE_BRACKET_IN == curentCode) { - endCode = OPCODE_BRACKET_OUT; - input = (char*)"[...]"; - } else if (OPCODE_BRACE_IN == curentCode){ - endCode = OPCODE_BRACE_OUT; - input = (char*)"{x,x}"; - } - pos++; - if (pos >= (int32_t)tmpExp.Size()) { - EDN_ERROR("ended with: ( or { or [ ... not permited"); - return false; - } - //EDN_DEBUG(" ==> Find ELEMENT : ([{"); - // case dependent : - if( OPCODE_BRACKET_IN == curentCode - || OPCODE_BRACE_IN == curentCode) { - while(pos< (int32_t)tmpExp.Size()) { - //EDN_DEBUG("check : " << tmpExp[pos]); - // if we find the end : - if (endCode == tmpExp[pos]) { - return true; - } else { - // otherwise, we check the error in the element ... - char *find = NULL; - switch (tmpExp[pos]) - { - case OPCODE_PTHESE_IN: find = (char*)"("; break; - case OPCODE_BRACKET_IN: find = (char*)"["; break; - case OPCODE_BRACE_IN: find = (char*)"{"; break; - case OPCODE_PTHESE_OUT: find = (char*)")"; break; - case OPCODE_BRACKET_OUT: find = (char*)"]"; break; - case OPCODE_BRACE_OUT: find = (char*)"}"; break; - case OPCODE_STAR: find = (char*)"*"; break; - case OPCODE_DOT: find = (char*)"."; break; - case OPCODE_QUESTION: find = (char*)"?"; break; - case OPCODE_PLUS: find = (char*)"+"; break; - case OPCODE_PIPE: find = (char*)"|"; break; - case OPCODE_START_OF_LINE: find = (char*)"^"; break; - case OPCODE_END_OF_LINE: find = (char*)"$"; break; - case OPCODE_DIGIT: find = (char*)"\\d"; break; - case OPCODE_DIGIT_NOT: find = (char*)"\\D"; break; - case OPCODE_LETTER: find = (char*)"\\l"; break; - case OPCODE_LETTER_NOT: find = (char*)"\\L"; break; - case OPCODE_SPACE: find = (char*)"\\s"; break; - case OPCODE_SPACE_NOT: find = (char*)"\\S"; break; - case OPCODE_WORD: find = (char*)"\\w"; break; - case OPCODE_WORD_NOT: find = (char*)"\\W"; break; - case OPCODE_NO_CHAR: find = (char*)"\\@"; break; - default: break; - } - if (NULL != find) { - EDN_ERROR("can not have : '" << find << "' inside " << input << " element"); - return false; - } - } - pos++; - } - } else { - while(pos< (int32_t)tmpExp.Size()) { - if (endCode == tmpExp[pos]) { - // find the last element - return true; - } else if ( OPCODE_BRACE_OUT == tmpExp[pos]) { - EDN_ERROR("find } inside a (...) without start {"); - return false; - } else if ( OPCODE_BRACKET_OUT == tmpExp[pos]) { - EDN_ERROR("find ] inside a (...) without start ["); - return false; - } else { - if( OPCODE_PTHESE_IN == tmpExp[pos] - || OPCODE_BRACKET_IN == tmpExp[pos] - || OPCODE_BRACE_IN == tmpExp[pos]) - { - if (false==CheckGoodPosition(tmpExp, pos) ) { - return false; - } - } - } - pos++; - } - } - - // we did not find the cloder . ... - if (endCode == OPCODE_BRACKET_OUT) { - EDN_ERROR("Missing ']' at the end"); - } - if (endCode == OPCODE_BRACE_OUT) { - EDN_ERROR("Missing '}' at the end"); - } - if (endCode == OPCODE_PTHESE_OUT) { - EDN_ERROR("Missing ')' at the end"); - } - return false; - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool CheckGoodPosition(Edn::VectorType tmpExp) - { - int32_t pos = 0; - while (pos < (int32_t)tmpExp.Size()) { - //EDN_DEBUG("check : " << tmpExp[pos]); - if( OPCODE_PTHESE_IN == tmpExp[pos] - || OPCODE_BRACKET_IN == tmpExp[pos] - || OPCODE_BRACE_IN == tmpExp[pos]) - { - // attention the i position change inside the finction... - if (false==CheckGoodPosition(tmpExp, pos) ) { - EDN_ERROR("Error at position : " << pos+1 ); - return false; - } else { - //EDN_DEBUG(" <== Find ELEMENT : ]})"); - } - } else if(OPCODE_PTHESE_OUT == tmpExp[pos]) { - EDN_ERROR("can find ')' with no start : ')'"); - return false; - } else if(OPCODE_BRACKET_OUT == tmpExp[pos]) { - EDN_ERROR("can find ']' with no start : '['"); - return false; - } else if(OPCODE_BRACE_OUT == tmpExp[pos]) { - EDN_ERROR("can find '}' with no start : '{'"); - return false; - } - pos++; - } - return true; - }; - - -}; - -#endif diff --git a/jni/edn/tools/NameSpaceEdn/String.cpp b/jni/edn/tools/NameSpaceEdn/String.cpp deleted file mode 100644 index 3049267..0000000 --- a/jni/edn/tools/NameSpaceEdn/String.cpp +++ /dev/null @@ -1,718 +0,0 @@ -/** - ******************************************************************************* - * @file EdnString.cpp - * @brief Editeur De N'ours : normal sting management... (sources) - * @author Edouard DUPIN - * @date 26/01/2011 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ - -#include "Edn.h" -#include "toolsMemory.h" - - -#undef __class__ -#define __class__ "Edn::String" - -std::ostream& Edn::operator <<(std::ostream &os, const Edn::String &obj) -{ - os << (char*)&obj.m_data[0]; - return os; -} - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -Edn::String::~String(void) -{ - m_data.Clear(); -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -Edn::String::String(void) -{ - //EDN_INFO("new Edn::String()"); - m_data.Clear(); - m_data.PushBack('\0'); -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -Edn::String::String(const char myInput) -{ - m_data.Clear(); - m_data.PushBack(myInput); - m_data.PushBack('\0'); -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -Edn::String::String(const char* inputData, int32_t len) -{ - m_data.Clear(); - m_data.PushBack('\0'); - Set(inputData, len); -} - -void Edn::String::Set(const char * inputData, int32_t len) -{ - // overwrite the len if needed : - if ((-1) == len) { - len = strlen(inputData); - } - - if (len != 0) { - // remove the last '\0' - m_data.PopBack(); - // copy the data ... - m_data.PushBack((int8_t*)inputData, len); - // add the last '\0' - m_data.PushBack('\0'); - } -} - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -Edn::String::String(int inputData) -{ - char tmpVal[256]; - // generate the string : - sprintf(tmpVal, "%d", inputData); - // set the internal data : - m_data.Clear(); - m_data.PushBack('\0'); - Set(tmpVal); -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -Edn::String::String(unsigned int inputData) -{ - char tmpVal[256]; - // generate the string : - sprintf(tmpVal, "%d", inputData); - // set the internal data : - m_data.Clear(); - m_data.PushBack('\0'); - Set(tmpVal); -} - -Edn::String::String(const Edn::String &ednS) -{ - //EDN_INFO("Constructeur de recopie"); - m_data = ednS.m_data; -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -const Edn::String& Edn::String::operator= (const Edn::String &ednS ) -{ - //EDN_INFO("OPERATOR de recopie"); - if( this != &ednS ) // avoid copy to itself - { - m_data = ednS.m_data; - } - return *this; -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -const Edn::String& Edn::String::operator= (const char * inputData) -{ - m_data.Clear(); - m_data.PushBack('\0'); - // calculate the size : - uint32_t len = strlen(inputData); - // check the new size ... - if (len > 0 ) { - // copy all data : - Set(inputData, len); - } - return *this; -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -const Edn::String& Edn::String::operator= (Edn::VectorType inputData) -{ - m_data = inputData; - if (m_data.Size()>0) { - if (m_data[m_data.Size()-1] != '\0') { - m_data.PushBack('\0'); - } - } - //EDN_DEBUG("m_dataLen="<= m_data.Size() ) { - return true; - } else { - return false; - } -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -int32_t Edn::String::Size(void) const -{ - if (m_data.Size() == 0) { - return 0; - } else { - return m_data.Size() - 1; - } -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -void Edn::String::Add(int32_t currentID, const char* inputData) -{ - // get the input lenght - int32_t len = strlen(inputData); - if (0 == len) { - EDN_WARNING("no data to add on the current string"); - return; - } else if (currentID < 0) { - EDN_WARNING("Curent ID(" << currentID << ") < 0 ==> Add at the start"); - currentID = 0; - } else if (currentID > Size() ) { - EDN_ERROR("Curent ID(" << currentID << ") > maxSize ... (" << Size() << ") ==> add at the end ..."); - m_data.PushBack((int8_t*)inputData, len); - return; - } - m_data.Insert(currentID, (int8_t*)inputData, len); -} - - -/** - * @brief - * - * @param[in,out] - * - * @return - * - */ -void Edn::String::Remove(int32_t currentID, int32_t len) -{ - if (0 >= len) { - EDN_ERROR("no data to remove on the current string"); - return; - } - // TODO : check the size of the data - m_data.EraseLen(currentID, len); -} - - -/** - * @brief Remove all element in the string - * - * @param --- - * - * @return --- - * - */ -void Edn::String::Clear(void) -{ - m_data.Clear(); - m_data.PushBack('\0'); -} - - - -/** - * @brief find the first accurence after the position indicated - * - * @param[in] element Element that might be find in the string - * @param[in] startPos Stert position to begin the search - * - * @return the position of the first occurence or -1 if not find... - * - */ -int32_t Edn::String::FindForward(const char element, int32_t startPos) -{ - if (startPos < 0) { - startPos = 0; - } else if (startPos >= Size() ) { - return -1; - } - for (int32_t iii=startPos; iii< Size(); iii++) { - if (m_data[iii] == element) { - return iii; - } - } - return -1; -} - - -/** - * @brief find the first accurence before the position indicated. - * - * @param[in] element Element that might be find in the string - * @param[in] startPos Stert position to begin the search - * - * @return the position of the first occurence begining by the end or -1 if not find... - * - */ -int32_t Edn::String::FindBack(const char element, int32_t startPos) -{ - if (startPos < 0) { - return -1; - } else if (startPos >= Size() ) { - startPos = Size(); - } - for (int32_t iii=startPos; iii>=0; iii--) { - if (m_data[iii] == element) { - return iii; - } - } - return -1; -} - - -/** - * @brief Extract data from the data between two position - * - * @param[in] posStart Start position where to extract data - * @param[in] posEnd End position where to extract data - * - * @return the extracted string - * - */ -Edn::String Edn::String::Extract(int32_t posStart, int32_t posEnd) -{ - Edn::String out; - if (posStart < 0) { - posStart = 0; - } else if (posStart >= Size() ) { - return out; - } - if (posEnd < 0) { - return out; - } else if (posEnd >= Size() ) { - posEnd = Size(); - } - out.m_data = m_data.Extract(posStart, posEnd); - out.m_data.PushBack('\0'); - return out; -} - - -/** - * @brief Get a basic vector in int8 data with no \0 at the end of the string - * - * @param --- - * - * @return The desired vector with data - * - */ -Edn::VectorType Edn::String::GetVector(void) -{ - Edn::VectorType out = m_data; - out.PopBack(); - return out; -} - - - -/** - * @brief Unitary test for the string system - * - * @param --- - * - * @return --- - * - */ -void Edn::TestUntaire_String(void) -{ - EDN_WARNING("*********************************************************"); - EDN_WARNING("** Test Unitaire 'EdnString' (START)"); - EDN_WARNING("*********************************************************"); - - int32_t iddd = 0; - Edn::String * monString = new Edn::String(); - EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\""); - delete(monString); - - monString = new Edn::String("test de direct data"); - EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\""); - delete(monString); - - monString = new Edn::String("test de direct data", 7); - EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\""); - delete(monString); - - int32_t testId = -6789; - monString = new Edn::String(testId); - EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\""); - delete(monString); - - uint32_t testId2 = 12345; - monString = new Edn::String((unsigned int)testId2); - EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\""); - delete(monString); - - Edn::String plop = "otherString"; - monString = new Edn::String(plop); - EDN_INFO("phase : " << iddd++ << " : \"" << monString << "\""); - delete(monString); - - - Edn::String s1 = "test de base ..."; - s1 += s1; - EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\""); - s1 += " plop 2 "; - EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\""); - s1 += plop; - EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\""); - s1 = plop; - EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\""); - s1 = "test direct 44"; - EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\""); - Edn::VectorType vb1; - vb1.PushBack('v'); - vb1.PushBack('b'); - vb1.PushBack('1'); - s1 = vb1; - EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\""); - vb1.Clear(); - vb1.PushBack('v'); - vb1.PushBack('b'); - vb1.PushBack('2'); - vb1.PushBack('\0'); - s1 = vb1; - EDN_INFO("phase : " << iddd++ << " : \"" << s1 << "\""); - - if (s1 == "vb2") { - EDN_INFO("phase : " << iddd++ << " : == OK"); - } else { - EDN_ERROR("phase : " << iddd++ << " : == ERROR"); - } - - - if (s1 == "vb3") { - EDN_ERROR("phase : " << iddd++ << " : == ERROR"); - } else { - EDN_INFO("phase : " << iddd++ << " : == OK"); - } - - - if (s1 != "vb3") { - EDN_INFO("phase : " << iddd++ << " : == OK"); - } else { - EDN_ERROR("phase : " << iddd++ << " : == ERROR"); - } - - - if (s1 != "vb2") { - EDN_ERROR("phase : " << iddd++ << " : == ERROR"); - } else { - EDN_INFO("phase : " << iddd++ << " : == OK"); - } - - - Edn::String s2 = "vb2"; - Edn::String s3 = "vb3"; - - if (s1 == s2) { - EDN_INFO("phase : " << iddd++ << " : == OK"); - } else { - EDN_ERROR("phase : " << iddd++ << " : == ERROR"); - } - - - if (s1 == s3) { - EDN_ERROR("phase : " << iddd++ << " : == ERROR"); - } else { - EDN_INFO("phase : " << iddd++ << " : == OK"); - } - - - if (s1 != s3) { - EDN_INFO("phase : " << iddd++ << " : == OK"); - } else { - EDN_ERROR("phase : " << iddd++ << " : == ERROR"); - } - - - if (s1 != s2) { - EDN_ERROR("phase : " << iddd++ << " : == ERROR"); - } else { - EDN_INFO("phase : " << iddd++ << " : == OK"); - } - EDN_WARNING("*********************************************************"); - EDN_WARNING("** Test Unitaire 'EdnString' (STOP)"); - EDN_WARNING("*********************************************************"); -} - diff --git a/jni/edn/tools/NameSpaceEdn/String.h b/jni/edn/tools/NameSpaceEdn/String.h deleted file mode 100644 index 9c2f86d..0000000 --- a/jni/edn/tools/NameSpaceEdn/String.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - ******************************************************************************* - * @file EdnString.h - * @brief Editeur De N'ours : normal sting management... (header) - * @author Edouard DUPIN - * @date 26/01/2011 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ -#ifndef __END__STRING_H__ -#define __END__STRING_H__ - -#include - -namespace Edn -{ - class String - { - public: - // Constructeurs - String(void); - String(const char myInput); - String(const char* inputData, int32_t len = -1);//, bool noAllocation=false); - void Set(const char* inputData, int32_t len=-1); - // basic convertion integer en string - String(int inputData); - String(unsigned int inputData); - //String(const wchar_t *inputData); - String(const Edn::String &ednS); - // destructor : - ~String(void); - - const Edn::String& operator= (const Edn::String &ednS ); // assigment - const Edn::String& operator= (const char * inputData); - const Edn::String& operator= (Edn::VectorType inputData); - bool operator== (const Edn::String& ednS) const; // == operator - bool operator== (const char * inputData) const; - bool operator!= (const Edn::String& ednS) const; // != operator - bool operator!= (const char * inputData) const; - const Edn::String& operator+= (const Edn::String &ednS); // += operator - const Edn::String& operator+= (const char * inputData); - Edn::String operator+ (const Edn::String &ednS); // + operator - Edn::String operator+ (const char * inputData); - //operator const char *() - friend std::ostream& operator <<( std::ostream &os,const Edn::String &obj); - - bool IsEmpty(void) const; - int32_t Size(void) const; - - void Add(int32_t currentID, const char* inputData); - void Remove(int32_t currentID, int32_t len); - void Clear(void); - - Edn::VectorType GetVector(void); - char * c_str(void) { return (char*)&m_data[0]; }; - - // Sting operation : - int32_t FindForward(const char element, int32_t startPos=0); - int32_t FindBack(const char element, int32_t startPos=0x7FFFFFFF); - Edn::String Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF); - - private : - Edn::VectorType m_data; - }; - - void TestUntaire_String(void); - - std::ostream& operator <<(std::ostream &os, const Edn::String &obj); - -} - - - - - -#endif - diff --git a/jni/edn/tools/NameSpaceEdn/Vector.h b/jni/edn/tools/NameSpaceEdn/Vector.h deleted file mode 100644 index b6cb22e..0000000 --- a/jni/edn/tools/NameSpaceEdn/Vector.h +++ /dev/null @@ -1,506 +0,0 @@ -/** - ******************************************************************************* - * @file Vector.h - * @brief Editeur De N'ours : Basic Edn::Vector (template) - * @author Edouard DUPIN - * @date 07/04/2011 - * @par Project - * Edn - * - * @par Copyright - * Copyright 2010 Edouard DUPIN, all right reserved - * - * This software is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY. - * - * Licence summary : - * You can modify and redistribute the sources code and binaries. - * You can send me the bug-fix - * You can not earn money with this Software (if the source extract from Edn - * represent less than 50% of original Sources) - * Term of the licence in in the file licence.txt. - * - ******************************************************************************* - */ -#ifndef __EDN_EdnVector_H__ -#define __EDN_EdnVector_H__ - -#undef __class__ -#define __class__ "Edn::Vector" - -/** - * @brief EdnVector classes ... - * - * @tparam[in] T The type of objects to store. - * @tparam[in] INC Incrementation mode (0 : Exponential to 200 and increment by stemp of 200) - * - * @todo : Need to add : popBack / Assign / Insert / Erase / Swap / Clear - * - * m_data - * ---------- |-----------------------| - * | 0 |-------->| Class Data | - * |--------| |-----------------------| - * | 1 |----| - * |--------| | - * | 2 |====|==============| |-----------------------| - * |--------| | --->| Class Data | - * m_count | 3 |-| | |-----------------------| - * |--------| | | - * | x | | | |-----------------------| - * |--------| | -------->| Class Data | - * | x | | |-----------------------| - * |--------| | - * | x | | - * |--------| | |-----------------------| - * | x | --------------------->| Class Data | - * |--------| |-----------------------| - * | x | - * |--------| - * | x | - * |--------| - * m_size | x | - * ---------- - * - */ -namespace Edn -{ - -template class Vector -{ - public: - class Iterator - { - // Private data : - private: - int32_t m_current; // curent Id on the vector - Edn::Vector * m_Vector; // Pointer on the curent element of the vector - public: - /** - * @brief Basic itarator constructor with no link with an Vector - */ - Iterator(): - m_current(-1), - m_Vector(NULL) - { - // nothing to do ... - } - /** - * @brief Recopy constructor on a specific Vector. - * @param[in] otherIterator The Iterator that might be copy - */ - Iterator(const Iterator & otherIterator): - m_current(otherIterator.m_current), - m_Vector(otherIterator.m_Vector) - { - // nothing to do ... - } - /** - * @brief Asignation operator. - * @param[in] otherIterator The Iterator that might be copy - * @return reference on the curent Iterator - */ - Iterator& operator=(const Iterator & otherIterator) - { - m_current = otherIterator.m_current; - m_Vector = otherIterator.m_Vector; - return *this; - } - /** - * @brief Basic destructor - */ - ~Iterator() - { - m_current = -1; - m_Vector = NULL; - } - /** - * @brief basic boolean cast - * @return true if the element is present in the Vector size - */ - operator bool () - { - if( 0 <= m_current - && m_current < m_EdnVector->Size() ) - { - return true; - } else { - return false; - } - } - /** - * @brief Incremental operator - * @return Reference on the current iterator incremented - */ - Iterator& operator++ () - { - if( NULL != m_EdnVector - && m_current < m_EdnVector->Size() ) - { - m_current++; - } - return *this; - } - /** - * @brief Decremental operator - * @return Reference on the current iterator decremented - */ - Iterator& operator-- () - { - if (m_current >= 0) { - m_current--; - } - return *this; - } - /** - * @brief Incremental operator - * @return Reference on a new iterator and increment the other one - */ - Iterator operator++ (int32_t) - { - Iterator it(*this); - ++(*this); - return it; - } - /** - * @brief Decremental operator - * @return Reference on a new iterator and decrement the other one - * - */ - Iterator operator-- (int32_t) - { - Iterator it(*this); - --(*this); - return it; - } - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - T * operator-> () const - { - EDN_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVector->Size()); - return &m_EdnVector->Get(m_current); - } - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - T & operator* () const - { - EDN_CHECK_INOUT(m_current >= 0 && m_current < m_EdnVector->Size()); - return m_EdnVector->Get(m_current); - } - private: - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - Iterator(Edn::Vector * myVector, int pos): - m_current(pos), - m_Vector(myVector) - { - // nothing to do ... - } - friend class Edn::Vector; - }; - - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - Vector(int count = 0): - m_data(NULL), - m_count(0), - m_size(0) - { - Resize(count); - } - - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - Vector(const Edn::Vector & myVector): - m_size(myVector.m_size), - m_count(myVector.m_count), - m_data(NULL) - { - int32_t i; - EDN_MALLOC_CAST(m_data, m_size, T, reinterpret_cast); - for(i=0; i & EdnVector) - { - int32_t i; - this->~EdnVector(); - m_size = EdnVector.m_size; - m_count = EdnVector.m_count; - EDN_MALLOC_CAST(m_data, m_size, T, reinterpret_cast); - for(i=0; i res - || res >= Size()) - { - return -1 - } else { - return res; - } - } - - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - void PushBack(const T& item) - { - int32_t idx = Size(); - Resize(idx+1); - Get(idx) = item; - } - - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - Iterator Get(int pos) - { - return Iterator(this, pos); - } - - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - Iterator Begin() - { - return Get(0); - } - - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - Iterator End() - { - return Get( Size()-1 ); - } - - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - void Resize(int32_t count) - { - int32_t i; - // Reallocate memory - if (count > m_size) { - ChangeAllocation(count); - } - - // Remove deprecated element - for(i=count; i m_size) { - // generate new size - while(count > m_size) { - if (INC) { - m_size = (m_size + INC) - } else if (m_size==0) { - m_size = 1; - } else { - m_size = m_size * 2; - } - } - // Allocate the curent element - T * data = NULL; - EDN_MALLOC_CAST(data, m_size, T, reinterpret_cast); - for(int i=0; i - * ---------------------------------------- - * | 0 | - * |--------------------------------------| - * | 1 | - * |--------------------------------------| - * | 2 | - * |--------------------------------------| - * m_size | 3 | - * |--------------------------------------| - * | x | - * |--------------------------------------| - * | x | - * |--------------------------------------| - * | x | - * |--------------------------------------| - * | x | - * |--------------------------------------| - * | x | - * |--------------------------------------| - * | x | - * |--------------------------------------| - * m_allocated | x | - * ---------------------------------------- - * - */ - -namespace Edn -{ - -template class VectorType -{ - public: - class Iterator - { - // Private data : - private: - int32_t m_current; //!< curent Id on the vector - VectorType * m_VectorType; //!< Pointer on the curent element of the vectorBin - public: - /** - * @brief Basic itarator constructor with no link with an EdnVector - */ - Iterator(): - m_current(-1), - m_VectorType(NULL) - { - // nothing to do ... - } - /** - * @brief Recopy constructor on a specific EdnVector. - * @param[in] otherIterator The Iterator that might be copy - */ - Iterator(const Iterator & otherIterator): - m_current(otherIterator.m_current), - m_VectorType(otherIterator.m_VectorType) - { - // nothing to do ... - } - /** - * @brief Asignation operator. - * @param[in] otherIterator The Iterator that might be copy - * @return reference on the curent Iterator - */ - Iterator& operator=(const Iterator & otherIterator) - { - m_current = otherIterator.m_current; - m_VectorType = otherIterator.m_VectorType; - return *this; - } - /** - * @brief Basic destructor - */ - ~Iterator() - { - m_current = -1; - m_VectorType = NULL; - } - /** - * @brief basic boolean cast - * @return true if the element is present in the EdnVector size - */ - operator bool () - { - if( 0 <= m_current - && m_current < m_VectorType->Size() ) - { - return true; - } else { - return false; - } - } - /** - * @brief Incremental operator - * @return Reference on the current iterator incremented - */ - Iterator& operator++ () - { - if( NULL != m_VectorType - && m_current < m_VectorType->Size() ) - { - m_current++; - } - return *this; - } - /** - * @brief Decremental operator - * @return Reference on the current iterator decremented - */ - Iterator& operator-- () - { - if (m_current >= 0) { - m_current--; - } - return *this; - } - /** - * @brief Incremental operator - * @return Reference on a new iterator and increment the other one - */ - Iterator operator++ (int32_t) - { - Iterator it(*this); - ++(*this); - return it; - } - /** - * @brief Decremental operator - * @return Reference on a new iterator and decrement the other one - */ - Iterator operator-- (int32_t) - { - Iterator it(*this); - --(*this); - return it; - } - /** - * @brief Get reference on the current Element - * @return the reference on the current Element - */ - MY_TYPE & operator-> () const - { - EDN_CHECK_INOUT(m_current >= 0 && m_current < m_VectorType->Size()); - return &m_VectorType->Get(m_current); - } - /** - * @brief Get reference on the current Element - * @return the reference on the current Element - */ - MY_TYPE & operator* () const - { - EDN_CHECK_INOUT(m_current >= 0 && m_current < m_VectorType->Size()); - return m_VectorType->Get(m_current); - } - private: - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - Iterator(VectorType * Evb, int32_t pos): - m_current(pos), - m_VectorType(Evb) - { - // nothing to do ... - } - friend class VectorType; - }; - - private: - MY_TYPE * m_data; //!< pointer on the curetn table of Data - int32_t m_size; //!< nb Element in the buffer - int32_t m_allocated; //!< Current allocated size - int32_t m_increment; //!< methode of increment - public: - /** - * @brief Create an empty vector - * @param[in] count Minimum request size of the Buffer - */ - VectorType(int32_t count = 0): - m_data(NULL), - m_size(0), - m_allocated(0), - m_increment(1) - { - ChangeAllocation(count); - } - - /** - * @brief Re-copy constructor (copy all needed data) - * @param[in] Evb Vector that might be copy - */ - VectorType(const Edn::VectorType & Evb) - { - m_allocated = Evb.m_allocated; - m_size = Evb.m_size; - m_increment = Evb.m_increment; - m_data = NULL; - //EDN_DEBUG("USE Specific vector allocator ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment); - // allocate all same data - EDN_MALLOC(m_data, m_allocated, MY_TYPE); - EDN_ASSERT(NULL!=m_data, "Error in data allocation"); - // Copy all data ... - memcpy(m_data, Evb.m_data, m_allocated * sizeof(MY_TYPE) ); - } - - /** - * @brief Destructor of the current Class - */ - ~VectorType() - { - if (NULL!=m_data) { - EDN_FREE(m_data); - m_data = NULL; - m_allocated = 0; - m_size = 0; - m_increment = 0; - } - } - - /** - * @brief Re-copy operator - * @param[in] Evb Vector that might be copy - * @return reference on the curent re-copy vector - */ - VectorType& operator=(const Edn::VectorType & Evb) - { - //EDN_DEBUG("USE RECOPY vector ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment); - if( this != &Evb ) // avoid copy to itself - { - if (NULL!=m_data) { - EDN_FREE(m_data); - m_data = NULL; - } - // Set the new value - m_allocated = Evb.m_allocated; - m_size = Evb.m_size; - m_increment = Evb.m_increment; - // allocate all same data - EDN_MALLOC(m_data, m_allocated, MY_TYPE); - EDN_ASSERT(NULL!=m_data, "Error in data allocation"); - // Copy all data ... - memcpy(m_data, Evb.m_data, m_allocated * sizeof(MY_TYPE) ); - } - // Return the curent pointer - return *this; - } - - /** - * @brief Add at the Last position of the Vector - * @param[in] item Element to add at the end of vector - */ - VectorType& operator+= (const Edn::VectorType & Evb) // += operator - { - int32_t nbElememt = Evb.Size(); - int32_t idx = m_size; - Resize(m_size+nbElememt); - memcpy(&m_data[idx], &Evb.m_data[0], nbElememt*sizeof(MY_TYPE) ); - // Return the curent pointer - return *this; - } - - /** - * @brief Set increment mode of this vector (default it match corectly with the number of element inside) - * @param[in] newIncrementNumber methode requested - */ - void SetIncrement(int32_t newIncrementNumber) - { - m_increment = newIncrementNumber; - } - - /** - * @brief Get the number of element in the vector - * @return The number requested - */ - int32_t Size() const - { - return m_size; - } - - /** - * @brief Get the Allocated size in the vector - * @return The size of allocation - */ - int32_t AllocatedSize() const - { - return m_allocated; - } - - /** - * @brief Get a current element in the vector - * @param[in] pos Desired position read - * @return Reference on the Element - */ - MY_TYPE& Get(int32_t pos) - { - return m_data[pos]; - } - - /** - * @brief Get an copy Element an a special position - * @param[in] pos Position in the vector that might be get [0..Size()] - * @return An reference on the copy of selected element - */ - MY_TYPE& operator[] (int32_t pos) - { - return Get(pos); - } - - /** - * @brief Get an Element an a special position - * @param[in] pos Position in the vector that might be get [0..Size()] - * @return An reference on the selected element - */ - const MY_TYPE& operator[] (int32_t pos) const - { - return m_data[pos]; - } - - /** - * @brief Add at the Last position of the Vector - * @param[in] item Element to add at the end of vector - */ - void PushBack(const MY_TYPE& item) - { - int32_t idx = m_size; - Resize(m_size+1); - m_data[idx] = item; - } - - /** - * @brief Add at the Last position of the Vector - * @param[in] item Element to add at the end of vector - */ - void PushBack(const MY_TYPE * item, int32_t nbElement) - { - if (NULL == item) { - return; - } - int32_t idx = m_size; - Resize(m_size+nbElement); - memcpy(&m_data[idx], item, nbElement*sizeof(MY_TYPE) ); - } - - /** - * @brief Remove the last element of the vector - */ - void PopBack(void) - { - if(m_size>0) { - Resize(m_size-1); - } - } - - /** - * @brief Remove all alement in the current vector - */ - void Clear(void) - { - if(m_size>0) { - Resize(0); - } - } - - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - void Insert(int32_t pos, const MY_TYPE& item) - { - if (pos>m_size) { - EDN_ERROR(" can not insert Element at this position : " << pos << " > " << m_size<< " add it at the end ... "); - PushBack(item); - return; - } - int32_t tmpSize = m_size; - // Request resize of the current buffer - Resize(m_size+1); - // move curent data - memmove((m_data + pos + 1), (m_data + pos), (tmpSize - pos)*sizeof(MY_TYPE) ); - // affectation of the current element - m_data[pos] = item; - } - - /** - * @brief - * - * @param[in,out] --- - * - * @return --- - * - */ - void Insert(int32_t pos, const MY_TYPE * item, int32_t nbElement) - { - if (pos>m_size) { - EDN_WARNING(" can not insert Element at this position : " << pos << " > " << m_size << " add it at the end ... "); - PushBack(item, nbElement); - return; - } - int32_t tmpSize = m_size; - // Request resize of the current buffer - Resize(m_size+nbElement); - // move curent data (after the position) - memmove((m_data + pos + nbElement), (m_data + pos), (tmpSize - pos)*sizeof(MY_TYPE) ); - // affectation of all input element - memcpy(&m_data[pos], item, nbElement*sizeof(MY_TYPE) ); - } - - /** - * @brief Remove one element - * - * @param[in] pos Position to remove the data - * - * @return --- - * - */ - void Erase(int32_t pos) - { - if (pos>m_size) { - EDN_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size); - return; - } - int32_t tmpSize = m_size; - // move curent data - memmove((m_data + pos), (m_data + pos + 1), (tmpSize - (pos+1))*sizeof(MY_TYPE) ); - // Request resize of the current buffer - Resize(m_size-1); - } - - /** - * @brief Remove N elements - * - * @param[in] pos Position to remove the data - * @param[in] posEnd Last position number - * - * @return --- - * - */ - void Erase(int32_t pos, int32_t posEnd) - { - if (pos>m_size) { - EDN_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size); - return; - } - if (posEnd>m_size) { - posEnd = m_size; - } - int32_t nbElement = m_size - pos; - int32_t tmpSize = m_size; - // move curent data - memmove((m_data + pos), (m_data + pos + nbElement), (tmpSize - (pos+nbElement))*sizeof(MY_TYPE) ); - // Request resize of the current buffer - Resize(m_size-nbElement); - } - - /** - * @brief Remove N element - * - * @param[in] pos Position to remove the data - * @param[in] nbElement number of element to remove - * - * @return --- - * - */ - void EraseLen(int32_t pos, int32_t nbElement) - { - if (pos>m_size) { - EDN_ERROR(" can not Erase Len Element at this position : " << pos << " > " << m_size); - return; - } - if (pos+nbElement>m_size) { - nbElement = m_size - pos; - } - int32_t tmpSize = m_size; - // move curent data - memmove((m_data + pos), (m_data + pos + nbElement), (tmpSize - (pos+nbElement))*sizeof(MY_TYPE) ); - // Request resize of the current buffer - Resize(m_size-nbElement); - } - - /** - * @brief extract data between two point : - * @param[in] posStart start position to extract data - * @param[in] posEnd End position to extract data - * @return the extracted vector - */ - VectorType Extract(int32_t posStart = 0, int32_t posEnd=0x7FFFFFFF) - { - VectorType out; - if (posStart < 0) { - posStart = 0; - } else if (posStart >= Size() ) { - return out; - } - if (posEnd < 0) { - return out; - } else if (posEnd >= Size() ) { - posEnd = Size(); - } - out.PushBack(&m_data[posStart], posEnd-posStart); - return out; - } - - /** - * @brief Set the minimum allocation in memory for the curent vector ==> reallocate the - * buffer to fit exactly the mumber of element needed - */ - void Fit(void) - { - if (m_size > m_allocated) { - // Reallocate the curent data to the correct size ... - EDN_REALLOC(m_data, m_size, MY_TYPE); - } - // Check result with assert : - EDN_ASSERT(NULL!=m_data, "Error in data Fitting"); - m_allocated = m_size; - } - - /** - * @brief Get an iterator an an specific position - * @param[in] pos Requested position of the iterator in the vector - * @return The Iterator - */ - Iterator Position(int32_t pos) - { - return Iterator(this, pos); - } - - /** - * @brief Get an Iterator on the start position of the Vector - * @return The Iterator - */ - Iterator Begin(void) - { - return Position(0); - } - - /** - * @brief Get an Iterator on the end position of the Vector - * @return The Iterator - */ - Iterator End(void) - { - return Position( Size()-1 ); - } - - private: - /** - * @brief Change the current size of the vector - * @param[in] newSize New requested size of element in the vector - */ - void Resize(int32_t newSize) - { - // Reallocate memory - if (newSize > m_allocated) { - ChangeAllocation(newSize); - } - m_size = newSize; - } - - /** - * @brief Change the current allocation to the corect one (depend on the current size) - * @param[in] newSize Minimum number of element needed - */ - void ChangeAllocation(int32_t newSize) - { - // set the minimal size to 1 - if(newSize <= 0) { - newSize = 1; - } - int32_t requestSize = m_allocated; - // set the size with the corect chose type : - if (newSize == m_allocated) { - return; - } else if (newSize < requestSize) { - // down the size of the vector: - if (0==m_increment) { - // never down size... - } else { - int32_t devide = m_increment; - if (devide == 0) { - devide = 1; - } - int32_t numberOfStep = m_allocated / devide; - if (newSize< ((numberOfStep-2)*devide + devide/2) ) { - //Allow Reallocation of a new size shoerter - requestSize = ((newSize / devide)+1) * devide; - } - } - } else { - while(newSize > requestSize) { - if (0 == requestSize) { - requestSize = 1; - } else if (0==m_increment) { - requestSize = requestSize * 2; - } else { - requestSize = (requestSize + m_increment); - } - } - } - // No reallocation needed : - if (requestSize == m_allocated) { - return; - } - // check if something is allocated : - if (NULL == m_data) { - // no data allocated ==> request an allocation (might be the first) - EDN_MALLOC(m_data, requestSize, MY_TYPE); - } else { - // move datas - EDN_REALLOC(m_data, requestSize, MY_TYPE); - } - // Check result with assert : - EDN_ASSERT(NULL!=m_data, "Error in data allocation"); - // set the new allocation size - m_allocated = requestSize; - } -}; -} - -#undef __class__ -#define __class__ NULL - -#endif - diff --git a/jni/edn/tools/charset/charset.cpp b/jni/edn/tools/charset/charset.cpp index d2dda37..4eb418b 100644 --- a/jni/edn/tools/charset/charset.cpp +++ b/jni/edn/tools/charset/charset.cpp @@ -25,10 +25,10 @@ // cf : http://unicode.org/fr/charts/symbols.html#CombiningDiacriticalMarks -#include "tools_debug.h" -#include "tools_globals.h" -#include "charsetTable.h" -#include "charset.h" +#include +#include +#include +#include // /usr/include/gtk-3.0/gdk/gdkkeysyms.h @@ -101,14 +101,14 @@ void convertUnicodeToIso(charset_te inputCharset, int32_t input_Unicode, char & } -int32_t convertIsoToUnicode(charset_te inputCharset, Edn::VectorType& input_ISO, Edn::VectorType& output_Unicode) +int32_t convertIsoToUnicode(charset_te inputCharset, etk::VectorType& input_ISO, etk::VectorType& output_Unicode) { EDN_WARNING("TODO : not coded..."); return 0; } -int32_t convertUnicodeToIso(charset_te inputCharset, Edn::VectorType& input_Unicode, Edn::VectorType& output_ISO) +int32_t convertUnicodeToIso(charset_te inputCharset, etk::VectorType& input_Unicode, etk::VectorType& output_ISO) { EDN_WARNING("TODO : not coded..."); return 0; @@ -204,14 +204,14 @@ void convertUtf8ToUnicode(char * input_UTF8, int32_t &output_Unicode) } -int32_t convertUnicodeToUtf8(Edn::VectorType& input_Unicode, Edn::VectorType& output_UTF8) +int32_t convertUnicodeToUtf8(etk::VectorType& input_Unicode, etk::VectorType& output_UTF8) { EDN_WARNING("TODO : not coded..."); return 0; } -int32_t convertUtf8ToUnicode(Edn::VectorType& input_UTF8, Edn::VectorType& output_Unicode) +int32_t convertUtf8ToUnicode(etk::VectorType& input_UTF8, etk::VectorType& output_Unicode) { EDN_WARNING("TODO : not coded..."); return 0; @@ -239,14 +239,14 @@ void convertUtf8ToIso(charset_te inputCharset, char * input_UTF8, char & output } -int32_t convertIsoToUtf8(charset_te inputCharset, Edn::VectorType& input_ISO, Edn::VectorType& output_UTF8) +int32_t convertIsoToUtf8(charset_te inputCharset, etk::VectorType& input_ISO, etk::VectorType& output_UTF8) { EDN_WARNING("TODO : not coded..."); return 0; } -int32_t convertUtf8ToIso(charset_te inputCharset, Edn::VectorType& input_UTF8, Edn::VectorType& output_ISO) +int32_t convertUtf8ToIso(charset_te inputCharset, etk::VectorType& input_UTF8, etk::VectorType& output_ISO) { EDN_WARNING("TODO : not coded..."); return 0; @@ -567,7 +567,7 @@ iconv -c --from-code=ISO-8859-15 --to-code=UTF-8 -o fichierUTF8_iso-15 fichierIs #endif - +#if 0 void ConvertInput(GdkEventKey *event, char* Utf8Out, bool &controlKey, bool &moveKey, int32_t &key) { @@ -1170,3 +1170,5 @@ void ConvertInput(GdkEventKey *event, char* Utf8Out, bool &controlKey, bool &mov } } +#endif + diff --git a/jni/edn/tools/charset/charset.h b/jni/edn/tools/charset/charset.h index 0910813..0f8ee4d 100644 --- a/jni/edn/tools/charset/charset.h +++ b/jni/edn/tools/charset/charset.h @@ -26,7 +26,7 @@ #ifndef __CHARSET_H__ #define __CHARSET_H__ -#include "VectorType.h" +#include typedef enum { EDN_CHARSET_UTF8, @@ -47,20 +47,20 @@ typedef enum { } charset_te; // transform ISO <==> Unicode -void convertIsoToUnicode(charset_te inputCharset, char input_ISO, int32_t & output_Unicode); -void convertUnicodeToIso(charset_te inputCharset, int32_t input_Unicode, char & output_ISO); -int32_t convertIsoToUnicode(charset_te inputCharset, Edn::VectorType& input_ISO, Edn::VectorType& output_Unicode); -int32_t convertUnicodeToIso(charset_te inputCharset, Edn::VectorType& input_Unicode, Edn::VectorType& output_ISO); +void convertIsoToUnicode(charset_te inputCharset, char input_ISO, int32_t & output_Unicode); +void convertUnicodeToIso(charset_te inputCharset, int32_t input_Unicode, char & output_ISO); +int32_t convertIsoToUnicode(charset_te inputCharset, etk::VectorType& input_ISO, etk::VectorType& output_Unicode); +int32_t convertUnicodeToIso(charset_te inputCharset, etk::VectorType& input_Unicode, etk::VectorType& output_ISO); // Transform UTF-8 <==> Unicode -void convertUnicodeToUtf8( int32_t input_Unicode, char * output_UTF8); -void convertUtf8ToUnicode( char * input_UTF8, int32_t& output_Unicode); -int32_t convertUnicodeToUtf8( Edn::VectorType& input_Unicode, Edn::VectorType& output_UTF8); -int32_t convertUtf8ToUnicode( Edn::VectorType& input_UTF8, Edn::VectorType& output_Unicode); +void convertUnicodeToUtf8( int32_t input_Unicode, char * output_UTF8); +void convertUtf8ToUnicode( char * input_UTF8, int32_t& output_Unicode); +int32_t convertUnicodeToUtf8( etk::VectorType& input_Unicode, etk::VectorType& output_UTF8); +int32_t convertUtf8ToUnicode( etk::VectorType& input_UTF8, etk::VectorType& output_Unicode); // Transform ISO <==> UTF-8 -void convertIsoToUtf8( charset_te inputCharset, char input_ISO, char * output_UTF8); -void convertUtf8ToIso( charset_te inputCharset, char * input_UTF8, char & output_ISO); -int32_t convertIsoToUtf8( charset_te inputCharset, Edn::VectorType& input_ISO, Edn::VectorType& output_UTF8); -int32_t convertUtf8ToIso( charset_te inputCharset, Edn::VectorType& input_UTF8, Edn::VectorType& output_ISO); +void convertIsoToUtf8( charset_te inputCharset, char input_ISO, char * output_UTF8); +void convertUtf8ToIso( charset_te inputCharset, char * input_UTF8, char & output_ISO); +int32_t convertIsoToUtf8( charset_te inputCharset, etk::VectorType& input_ISO, etk::VectorType& output_UTF8); +int32_t convertUtf8ToIso( charset_te inputCharset, etk::VectorType& input_UTF8, etk::VectorType& output_ISO); void Utf8_SizeElement(const char * data, int32_t lenMax , uint8_t &size, bool &baseValid); int32_t strUtf8Len(const char *input_UTF8); @@ -79,7 +79,7 @@ int32_t strUtf8Len(const char *input_UTF8); #endif //# define GDK_Retur (65516) -void ConvertInput(GdkEventKey *event, char* Utf8Out, bool &controlKey, bool &moveKey, int32_t &key); +//void ConvertInput(GdkEventKey *event, char* Utf8Out, bool &controlKey, bool &moveKey, int32_t &key); void testDisplayConvChar(void); diff --git a/jni/edn/tools/charset/charsetTable.cpp b/jni/edn/tools/charset/charsetTable.cpp index c36e840..b253f05 100644 --- a/jni/edn/tools/charset/charsetTable.cpp +++ b/jni/edn/tools/charset/charsetTable.cpp @@ -24,9 +24,9 @@ */ -#include "tools_debug.h" -#include "tools_globals.h" -#include "charsetTable.h" +#include +#include +#include extern "C" { @@ -296,17 +296,5 @@ extern "C" { 0x000000F0, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x000000FF }; - - - - - - - - - - - - } diff --git a/jni/edn/tools/debug/tools_debug.cpp b/jni/edn/tools/debug/tools_debug.cpp index a35b7f1..264ed74 100644 --- a/jni/edn/tools/debug/tools_debug.cpp +++ b/jni/edn/tools/debug/tools_debug.cpp @@ -23,40 +23,5 @@ ******************************************************************************* */ -#include "tools_debug.h" -#include "time.h" - -// Max string size : (wide screan console nb caractere) -#define EDN_LOG_MAX_LENGTH 250 - - -#define FUNCTION_NAME_SIZE (50) - -void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName) -{ - char tmpName[FUNCTION_NAME_SIZE] = ""; - if (NULL == className) { - snprintf(tmpName, FUNCTION_NAME_SIZE, "(l=%5d) %s ",ligne, funcName); - } else { - snprintf(tmpName, FUNCTION_NAME_SIZE, "(l=%5d) %s::%s ",ligne, className, funcName); - } - tmpName[FUNCTION_NAME_SIZE-4] = ' '; - tmpName[FUNCTION_NAME_SIZE-3] = '|'; - tmpName[FUNCTION_NAME_SIZE-2] = ' '; - tmpName[FUNCTION_NAME_SIZE-1] = '\0'; - std::cout << tmpName; -} - - -void TOOLS_DisplayTime(void) -{ - time_t rawtime; - struct tm * timeinfo; - char tmpdata[50]; - - time ( &rawtime ); - timeinfo = localtime ( &rawtime ); - sprintf(tmpdata, " %2dh %2dmin %2ds | ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); - std::cout << tmpdata ; -} +const char * ednLog = "edn "; diff --git a/jni/edn/tools/debug/tools_debug.h b/jni/edn/tools/debug/tools_debug.h index c8287e5..7bda1f2 100644 --- a/jni/edn/tools/debug/tools_debug.h +++ b/jni/edn/tools/debug/tools_debug.h @@ -26,130 +26,53 @@ #ifndef __TOOLS_DEBUG_H__ #define __TOOLS_DEBUG_H__ -#include -#include "types_generique.h" +#include +#include -// Log Message System For EDN -void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName); -void TOOLS_DisplayTime(void); +extern const char * ednLog; -//regular colors -#define COLOR_BLACK "\e[0;30m" -#define COLOR_RED "\e[0;31m" -#define COLOR_GREEN "\e[0;32m" -#define COLOR_YELLOW "\e[0;33m" -#define COLOR_BLUE "\e[0;34m" -#define COLOR_MAGENTA "\e[0;35m" -#define COLOR_CYAN "\e[0;36m" -#define COLOR_WHITE "\e[0;37m" -//emphasized (bolded) colors -#define COLOR_BOLD_BLACK "\e[1;30m" -#define COLOR_BOLD_RED "\e[1;31m" -#define COLOR_BOLD_GREEN "\e[1;32m" -#define COLOR_BOLD_YELLOW "\e[1;33m" -#define COLOR_BOLD_BLUE "\e[1;34m" -#define COLOR_BOLD_MAGENTA "\e[1;35m" -#define COLOR_BOLD_CYAN "\e[1;36m" -#define COLOR_BOLD_WHITE "\e[1;37m" -//background colors -#define COLOR_BG_BLACK "\e[40m" -#define COLOR_BG_RED "\e[41m" -#define COLOR_BG_GREEN "\e[42m" -#define COLOR_BG_YELLOW "\e[43m" -#define COLOR_BG_BLUE "\e[44m" -#define COLOR_BG_MAGENTA "\e[45m" -#define COLOR_BG_CYAN "\e[46m" -#define COLOR_BG_WHITE "\e[47m" -// Return to the normal color setings -#define COLOR_NORMAL "\e[0m" -//go to the Top of bash -#define GO_TOP "\e[0;0f" - -#undef __class__ -#define __class__ (NULL) - -/* -#define DEFINE_CLASS_NAME(name) #undef __class__ \ - #define __class__ (#name) -at the start of the class : -#undef __class__ -#define __class__ "" -*/ - -#define EDN_DBG_COMMON(color, info, data) do { \ - std::cout << color; \ - TOOLS_DisplayTime(); \ - TOOLS_DisplayFuncName(__LINE__, __class__, __func__); \ - std::cout << "[" << info << "] " << data; \ - std::cout << COLOR_NORMAL < 0 -# define EDN_WARNING(data) EDN_DBG_COMMON(COLOR_MAGENTA, "WW", data) -# define EDN_ERROR(data) EDN_DBG_COMMON(COLOR_BOLD_RED, "EE", data) +# define EDN_WARNING(data) ETK_WARNING(ednLog, data) +# define EDN_ERROR(data) ETK_ERROR(ednLog, data) #else -# define EDN_WARNING(data) do {}while(0) -# define EDN_ERROR(data) do {}while(0) +# define EDN_WARNING(data) do {}while(0) +# define EDN_ERROR(data) do {}while(0) #endif #if EDN_DEBUG_LEVEL > 1 -# define EDN_INFO(data) EDN_DBG_COMMON(COLOR_CYAN, "II", data) +# define EDN_INFO(data) ETK_INFO(ednLog, data) #else -# define EDN_INFO(data) do {}while(0) +# define EDN_INFO(data) do {}while(0) #endif #if EDN_DEBUG_LEVEL > 2 -# define EDN_DEBUG(data) EDN_DBG_COMMON(COLOR_YELLOW, "DD", data) +# define EDN_DEBUG(data) ETK_DEBUG(ednLog, data) #else -# define EDN_DEBUG(data) do {}while(0) +# define EDN_DEBUG(data) do {}while(0) #endif - - -#if EDN_DEBUG_LEVEL > 0 -# define EDN_ASSERT(cond, format, ...) \ - do { \ - if (!(cond)) { \ - EDN_CRITICAL(format, ##__VA_ARGS__); \ - assert(!#cond); \ - } \ - } while (0) +#if EDN_DEBUG_LEVEL > 3 +# define EDN_VERBOSE(data) ETK_VERBOSE(ednLog, data) #else -# define EDN_ASSERT(cond, format, ...) \ - do { \ - assert(cond); \ - } while (0) +# define EDN_VERBOSE(data) do {}while(0) #endif +#define EDN_TODO(data) DRAW_WARNING("TODO : " << data) + +#define EDN_ASSERT(cond, data) ETK_ASSERT(ednLog, cond, data) + #if EDN_DEBUG_LEVEL > 1 -# define EDN_CHECK_INOUT(cond) EDN_ASSERT((cond), "Internal input error : "#cond) +# define EDN_CHECK_INOUT(cond) ETK_CHECK_INOUT_ASSERT(ednLog, cond) #elif EDN_DEBUG_LEVEL > 0 -// Critical warning mode -# define EDN_CHECK_INOUT(cond) \ - do { \ - if (!(cond)) { \ - EDN_CRITICAL("Internal input error : "#cond);\ - } \ - } while (0) +# define EDN_CHECK_INOUT(cond) ETK_CHECK_INOUT_WARNING(ednLog, cond) #else -// Default : No check -# define EDN_CHECK_INOUT(cond) do { } while (0) -#endif - - -// Enable or disable the magic element checking... -#if EDN_DEBUG_LEVEL > 0 - #define CHECK_MAGIC(cond) EDN_ASSERT((cond), "MAGIC check error : "#cond) - #define EDN_ENABLE_CHECK_MAGIC (1) -#else - #define CHECK_MAGIC(cond) do {}while(0) +# define EDN_CHECK_INOUT(cond) do { } while (0) #endif - #endif diff --git a/jni/edn/tools/globals/tools_globals.cpp b/jni/edn/tools/globals/tools_globals.cpp index d1a0f33..3092ec9 100644 --- a/jni/edn/tools/globals/tools_globals.cpp +++ b/jni/edn/tools/globals/tools_globals.cpp @@ -23,9 +23,9 @@ ******************************************************************************* */ -#include "tools_globals.h" -#include "ColorizeManager.h" -#include "MsgBroadcast.h" +#include +#include +#include #undef __class__ #define __class__ "globals" diff --git a/jni/edn/tools/globals/tools_globals.h b/jni/edn/tools/globals/tools_globals.h index f7ba82e..bbd5205 100644 --- a/jni/edn/tools/globals/tools_globals.h +++ b/jni/edn/tools/globals/tools_globals.h @@ -26,7 +26,9 @@ #ifndef __TOOLS_GLOBALS_H__ #define __TOOLS_GLOBALS_H__ -#include "tools_debug.h" +#include +#include + namespace globals { diff --git a/jni/edn/tools/memory/toolsMemory.h b/jni/edn/tools/memory/toolsMemory.h index 8c9b1cc..d0c8875 100644 --- a/jni/edn/tools/memory/toolsMemory.h +++ b/jni/edn/tools/memory/toolsMemory.h @@ -1,6 +1,6 @@ /** ******************************************************************************* - * @file toolsmemory.h + * @file toolsMemory.h * @brief Editeur De N'ours : Memory implementation (headers) * @author Edouard DUPIN * @date 12/01/2011 @@ -27,9 +27,8 @@ #define __TOOLS_MEMORY_H__ - // General -#if EDN_MEMORY_CHECKER > 0 +#ifdef EDN_MEMORY_CHECKER void EDN_MemFree( void * pointerData, const char * variableName, const char * functionName, int32_t line, const char * fileName ); void * EDN_MemMalloc( size_t num, size_t size, uint8_t init, const char * variableName, const char * functionName, int32_t line, const char * fileName ); void EDN_MemShowLogs( void ); diff --git a/jni/edn/tools/tinyXML/tinystr.cpp b/jni/edn/tools/tinyXML/tinystr.cpp deleted file mode 100644 index 6812507..0000000 --- a/jni/edn/tools/tinyXML/tinystr.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original file by Yves Berquin. - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -/* - * THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005. - */ - - -#ifndef TIXML_USE_STL - -#include "tinystr.h" - -// Error value for find primitive -const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); - - -// Null rep. -TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; - - -void TiXmlString::reserve (size_type cap) -{ - if (cap > capacity()) - { - TiXmlString tmp; - tmp.init(length(), cap); - memcpy(tmp.start(), data(), length()); - swap(tmp); - } -} - - -TiXmlString& TiXmlString::assign(const char* str, size_type len) -{ - size_type cap = capacity(); - if (len > cap || cap > 3*(len + 8)) - { - TiXmlString tmp; - tmp.init(len); - memcpy(tmp.start(), str, len); - swap(tmp); - } - else - { - memmove(start(), str, len); - set_size(len); - } - return *this; -} - - -TiXmlString& TiXmlString::append(const char* str, size_type len) -{ - size_type newsize = length() + len; - if (newsize > capacity()) - { - reserve (newsize + capacity()); - } - memmove(finish(), str, len); - set_size(newsize); - return *this; -} - - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) -{ - TiXmlString tmp; - tmp.reserve(a.length() + b.length()); - tmp += a; - tmp += b; - return tmp; -} - -TiXmlString operator + (const TiXmlString & a, const char* b) -{ - TiXmlString tmp; - TiXmlString::size_type b_len = static_cast( strlen(b) ); - tmp.reserve(a.length() + b_len); - tmp += a; - tmp.append(b, b_len); - return tmp; -} - -TiXmlString operator + (const char* a, const TiXmlString & b) -{ - TiXmlString tmp; - TiXmlString::size_type a_len = static_cast( strlen(a) ); - tmp.reserve(a_len + b.length()); - tmp.append(a, a_len); - tmp += b; - return tmp; -} - - -#endif // TIXML_USE_STL diff --git a/jni/edn/tools/tinyXML/tinystr.h b/jni/edn/tools/tinyXML/tinystr.h deleted file mode 100644 index 3c2aa9d..0000000 --- a/jni/edn/tools/tinyXML/tinystr.h +++ /dev/null @@ -1,319 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original file by Yves Berquin. - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -/* - * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005. - * - * - completely rewritten. compact, clean, and fast implementation. - * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems) - * - fixed reserve() to work as per specification. - * - fixed buggy compares operator==(), operator<(), and operator>() - * - fixed operator+=() to take a const ref argument, following spec. - * - added "copy" constructor with length, and most compare operators. - * - added swap(), clear(), size(), capacity(), operator+(). - */ - -#ifndef TIXML_USE_STL - -#ifndef TIXML_STRING_INCLUDED -#define TIXML_STRING_INCLUDED - -#include -#include - -/* The support for explicit isn't that universal, and it isn't really - required - it is used to check that the TiXmlString class isn't incorrectly - used. Be nice to old compilers and macro it here: -*/ -#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) - // Microsoft visual studio, version 6 and higher. - #define TIXML_EXPLICIT explicit -#elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - #define TIXML_EXPLICIT explicit -#else - #define TIXML_EXPLICIT -#endif - - -/* - TiXmlString is an emulation of a subset of the std::string template. - Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. - Only the member functions relevant to the TinyXML project have been implemented. - The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase - a string and there's no more room, we allocate a buffer twice as big as we need. -*/ -class TiXmlString -{ - public : - // The size type used - typedef size_t size_type; - - // Error value for find primitive - static const size_type npos; // = -1; - - - // TiXmlString empty constructor - TiXmlString () : rep_(&nullrep_) - { - } - - // TiXmlString copy constructor - TiXmlString ( const TiXmlString & copy) : rep_(0) - { - init(copy.length()); - memcpy(start(), copy.data(), length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) - { - init( static_cast( strlen(copy) )); - memcpy(start(), copy, length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) - { - init(len); - memcpy(start(), str, len); - } - - // TiXmlString destructor - ~TiXmlString () - { - quit(); - } - - // = operator - TiXmlString& operator = (const char * copy) - { - return assign( copy, (size_type)strlen(copy)); - } - - // = operator - TiXmlString& operator = (const TiXmlString & copy) - { - return assign(copy.start(), copy.length()); - } - - - // += operator. Maps to append - TiXmlString& operator += (const char * suffix) - { - return append(suffix, static_cast( strlen(suffix) )); - } - - // += operator. Maps to append - TiXmlString& operator += (char single) - { - return append(&single, 1); - } - - // += operator. Maps to append - TiXmlString& operator += (const TiXmlString & suffix) - { - return append(suffix.data(), suffix.length()); - } - - - // Convert a TiXmlString into a null-terminated char * - const char * c_str () const { return rep_->str; } - - // Convert a TiXmlString into a char * (need not be null terminated). - const char * data () const { return rep_->str; } - - // Return the length of a TiXmlString - size_type length () const { return rep_->size; } - - // Alias for length() - size_type size () const { return rep_->size; } - - // Checks if a TiXmlString is empty - bool empty () const { return rep_->size == 0; } - - // Return capacity of string - size_type capacity () const { return rep_->capacity; } - - - // single char extraction - const char& at (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // [] operator - char& operator [] (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // find a char in a string. Return TiXmlString::npos if not found - size_type find (char lookup) const - { - return find(lookup, 0); - } - - // find a char in a string from an offset. Return TiXmlString::npos if not found - size_type find (char tofind, size_type offset) const - { - if (offset >= length()) return npos; - - for (const char* p = c_str() + offset; *p != '\0'; ++p) - { - if (*p == tofind) return static_cast< size_type >( p - c_str() ); - } - return npos; - } - - void clear () - { - //Lee: - //The original was just too strange, though correct: - // TiXmlString().swap(*this); - //Instead use the quit & re-init: - quit(); - init(0,0); - } - - /* Function to reserve a big amount of data when we know we'll need it. Be aware that this - function DOES NOT clear the content of the TiXmlString if any exists. - */ - void reserve (size_type cap); - - TiXmlString& assign (const char* str, size_type len); - - TiXmlString& append (const char* str, size_type len); - - void swap (TiXmlString& other) - { - Rep* r = rep_; - rep_ = other.rep_; - other.rep_ = r; - } - - private: - - void init(size_type sz) { init(sz, sz); } - void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } - char* start() const { return rep_->str; } - char* finish() const { return rep_->str + rep_->size; } - - struct Rep - { - size_type size, capacity; - char str[1]; - }; - - void init(size_type sz, size_type cap) - { - if (cap) - { - // Lee: the original form: - // rep_ = static_cast(operator new(sizeof(Rep) + cap)); - // doesn't work in some cases of new being overloaded. Switching - // to the normal allocation, although use an 'int' for systems - // that are overly picky about structure alignment. - const size_type bytesNeeded = sizeof(Rep) + cap; - const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); - rep_ = reinterpret_cast( new int[ intsNeeded ] ); - - rep_->str[ rep_->size = sz ] = '\0'; - rep_->capacity = cap; - } - else - { - rep_ = &nullrep_; - } - } - - void quit() - { - if (rep_ != &nullrep_) - { - // The rep_ is really an array of ints. (see the allocator, above). - // Cast it back before delete, so the compiler won't incorrectly call destructors. - delete [] ( reinterpret_cast( rep_ ) ); - } - } - - Rep * rep_; - static Rep nullrep_; - -} ; - - -inline bool operator == (const TiXmlString & a, const TiXmlString & b) -{ - return ( a.length() == b.length() ) // optimization on some platforms - && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare -} -inline bool operator < (const TiXmlString & a, const TiXmlString & b) -{ - return strcmp(a.c_str(), b.c_str()) < 0; -} - -inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } -inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } -inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } -inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } - -inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } -inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } -inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } -inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); -TiXmlString operator + (const TiXmlString & a, const char* b); -TiXmlString operator + (const char* a, const TiXmlString & b); - - -/* - TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. - Only the operators that we need for TinyXML have been developped. -*/ -class TiXmlOutStream : public TiXmlString -{ -public : - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const TiXmlString & in) - { - *this += in; - return *this; - } - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const char * in) - { - *this += in; - return *this; - } - -} ; - -#endif // TIXML_STRING_INCLUDED -#endif // TIXML_USE_STL diff --git a/jni/edn/tools/tinyXML/tinyxml.cpp b/jni/edn/tools/tinyXML/tinyxml.cpp deleted file mode 100644 index 9be6c6a..0000000 --- a/jni/edn/tools/tinyXML/tinyxml.cpp +++ /dev/null @@ -1,1839 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include - -#ifdef TIXML_USE_STL -#include -#include -#endif - -#include "tinyxml.h" - -FILE* TiXmlFOpen( const char* filename, const char* mode ); - -bool TiXmlBase::condenseWhiteSpace = true; - -// Microsoft compiler security -FILE* TiXmlFOpen( const char* filename, const char* mode ) -{ - #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - FILE* fp = 0; - errno_t err = fopen_s( &fp, filename, mode ); - if ( !err && fp ) - return fp; - return 0; - #else - return fopen( filename, mode ); - #endif -} - -void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) -{ - int i=0; - - while( i<(int)str.length() ) - { - unsigned char c = (unsigned char) str[i]; - - if ( c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - // - // The -1 is a bug fix from Rob Laveaux. It keeps - // an overflow from happening if there is no ';'. - // There are actually 2 ways to exit this loop - - // while fails (error case) and break (semicolon found). - // However, there is no mechanism (currently) for - // this function to return an error. - while ( i<(int)str.length()-1 ) - { - outString->append( str.c_str() + i, 1 ); - ++i; - if ( str[i] == ';' ) - break; - } - } - else if ( c == '&' ) - { - outString->append( entity[0].str, entity[0].strLength ); - ++i; - } - else if ( c == '<' ) - { - outString->append( entity[1].str, entity[1].strLength ); - ++i; - } - else if ( c == '>' ) - { - outString->append( entity[2].str, entity[2].strLength ); - ++i; - } - else if ( c == '\"' ) - { - outString->append( entity[3].str, entity[3].strLength ); - ++i; - } - else if ( c == '\'' ) - { - outString->append( entity[4].str, entity[4].strLength ); - ++i; - } - else if ( c < 32 ) - { - // Easy pass at non-alpha/numeric/symbol - // Below 32 is symbolic. - char buf[ 32 ]; - - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); - #else - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - #endif - - //*ME: warning C4267: convert 'size_t' to 'int' - //*ME: Int-Cast to make compiler happy ... - outString->append( buf, (int)strlen( buf ) ); - ++i; - } - else - { - //char realc = (char) c; - //outString->append( &realc, 1 ); - *outString += (char) c; // somewhat more efficient function call. - ++i; - } - } -} - - -TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() -{ - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; -} - - -TiXmlNode::~TiXmlNode() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } -} - - -void TiXmlNode::CopyTo( TiXmlNode* target ) const -{ - target->SetValue (value.c_str() ); - target->userData = userData; - target->location = location; -} - - -void TiXmlNode::Clear() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } - - firstChild = 0; - lastChild = 0; -} - - -TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) -{ - assert( node->parent == 0 || node->parent == this ); - assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); - - if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) - { - delete node; - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - node->parent = this; - - node->prev = lastChild; - node->next = 0; - - if ( lastChild ) - lastChild->next = node; - else - firstChild = node; // it was an empty list. - - lastChild = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) -{ - if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - - return LinkEndChild( node ); -} - - -TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) -{ - if ( !beforeThis || beforeThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if ( beforeThis->prev ) - { - beforeThis->prev->next = node; - } - else - { - assert( firstChild == beforeThis ); - firstChild = node; - } - beforeThis->prev = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) -{ - if ( !afterThis || afterThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) - { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if ( afterThis->next ) - { - afterThis->next->prev = node; - } - else - { - assert( lastChild == afterThis ); - lastChild = node; - } - afterThis->next = node; - return node; -} - - -TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) -{ - if ( !replaceThis ) - return 0; - - if ( replaceThis->parent != this ) - return 0; - - if ( withThis.ToDocument() ) { - // A document can never be a child. Thanks to Noam. - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = withThis.Clone(); - if ( !node ) - return 0; - - node->next = replaceThis->next; - node->prev = replaceThis->prev; - - if ( replaceThis->next ) - replaceThis->next->prev = node; - else - lastChild = node; - - if ( replaceThis->prev ) - replaceThis->prev->next = node; - else - firstChild = node; - - delete replaceThis; - node->parent = this; - return node; -} - - -bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) -{ - if ( !removeThis ) { - return false; - } - - if ( removeThis->parent != this ) - { - assert( 0 ); - return false; - } - - if ( removeThis->next ) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; - - if ( removeThis->prev ) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; - - delete removeThis; - return true; -} - -const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = firstChild; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = lastChild; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild(); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling(); - } -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild( val ); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling( val ); - } -} - - -const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = next; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = prev; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -void TiXmlElement::RemoveAttribute( const char * name ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING str( name ); - TiXmlAttribute* node = attributeSet.Find( str ); - #else - TiXmlAttribute* node = attributeSet.Find( name ); - #endif - if ( node ) - { - attributeSet.Remove( node ); - delete node; - } -} - -const TiXmlElement* TiXmlNode::FirstChildElement() const -{ - const TiXmlNode* node; - - for ( node = FirstChild(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = FirstChild( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement() const -{ - const TiXmlNode* node; - - for ( node = NextSibling(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = NextSibling( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlDocument* TiXmlNode::GetDocument() const -{ - const TiXmlNode* node; - - for( node = this; node; node = node->parent ) - { - if ( node->ToDocument() ) - return node->ToDocument(); - } - return 0; -} - - -TiXmlElement::TiXmlElement (const char * _value) - : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} - - -#ifdef TIXML_USE_STL -TiXmlElement::TiXmlElement( const std::string& _value ) - : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} -#endif - - -TiXmlElement::TiXmlElement( const TiXmlElement& copy) - : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) -{ - firstChild = lastChild = 0; - copy.CopyTo( this ); -} - - -void TiXmlElement::operator=( const TiXmlElement& base ) -{ - ClearThis(); - base.CopyTo( this ); -} - - -TiXmlElement::~TiXmlElement() -{ - ClearThis(); -} - - -void TiXmlElement::ClearThis() -{ - Clear(); - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } -} - - -const char* TiXmlElement::Attribute( const char* name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return node->Value(); - return 0; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( attrib ) - return &attrib->ValueStr(); - return 0; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, int* i ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - const char* result = 0; - - if ( attrib ) { - result = attrib->Value(); - if ( i ) { - attrib->QueryIntValue( i ); - } - } - return result; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - const std::string* result = 0; - - if ( attrib ) { - result = &attrib->ValueStr(); - if ( i ) { - attrib->QueryIntValue( i ); - } - } - return result; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, double* d ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - const char* result = 0; - - if ( attrib ) { - result = attrib->Value(); - if ( d ) { - attrib->QueryDoubleValue( d ); - } - } - return result; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - const std::string* result = 0; - - if ( attrib ) { - result = &attrib->ValueStr(); - if ( d ) { - attrib->QueryDoubleValue( d ); - } - } - return result; -} -#endif - - -int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( !attrib ) - return TIXML_NO_ATTRIBUTE; - return attrib->QueryIntValue( ival ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( !attrib ) - return TIXML_NO_ATTRIBUTE; - return attrib->QueryIntValue( ival ); -} -#endif - - -int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( !attrib ) - return TIXML_NO_ATTRIBUTE; - return attrib->QueryDoubleValue( dval ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( !attrib ) - return TIXML_NO_ATTRIBUTE; - return attrib->QueryDoubleValue( dval ); -} -#endif - - -void TiXmlElement::SetAttribute( const char * name, int val ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); - if ( attrib ) { - attrib->SetIntValue( val ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, int val ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); - if ( attrib ) { - attrib->SetIntValue( val ); - } -} -#endif - - -void TiXmlElement::SetDoubleAttribute( const char * name, double val ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); - if ( attrib ) { - attrib->SetDoubleValue( val ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetDoubleAttribute( const std::string& name, double val ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); - if ( attrib ) { - attrib->SetDoubleValue( val ); - } -} -#endif - - -void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname ); - if ( attrib ) { - attrib->SetValue( cvalue ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name ); - if ( attrib ) { - attrib->SetValue( _value ); - } -} -#endif - - -void TiXmlElement::Print( FILE* cfile, int depth ) const -{ - int i; - assert( cfile ); - for ( i=0; iNext() ) - { - fprintf( cfile, " " ); - attrib->Print( cfile, depth ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a node - // 2) An element with only a text child is printed as text - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if ( !firstChild ) - { - fprintf( cfile, " />" ); - } - else if ( firstChild == lastChild && firstChild->ToText() ) - { - fprintf( cfile, ">" ); - firstChild->Print( cfile, depth + 1 ); - fprintf( cfile, "", value.c_str() ); - } - else - { - fprintf( cfile, ">" ); - - for ( node = firstChild; node; node=node->NextSibling() ) - { - if ( !node->ToText() ) - { - fprintf( cfile, "\n" ); - } - node->Print( cfile, depth+1 ); - } - fprintf( cfile, "\n" ); - for( i=0; i", value.c_str() ); - } -} - - -void TiXmlElement::CopyTo( TiXmlElement* target ) const -{ - // superclass: - TiXmlNode::CopyTo( target ); - - // Element class: - // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; - for( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next() ) - { - target->SetAttribute( attribute->Name(), attribute->Value() ); - } - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - -bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this, attributeSet.First() ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -TiXmlNode* TiXmlElement::Clone() const -{ - TiXmlElement* clone = new TiXmlElement( Value() ); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -const char* TiXmlElement::GetText() const -{ - const TiXmlNode* child = this->FirstChild(); - if ( child ) { - const TiXmlText* childText = child->ToText(); - if ( childText ) { - return childText->Value(); - } - } - return 0; -} - - -TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - ClearError(); -} - -TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} - - -#ifdef TIXML_USE_STL -TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} -#endif - - -TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDocument::operator=( const TiXmlDocument& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) -{ - return LoadFile( Value(), encoding ); -} - - -bool TiXmlDocument::SaveFile() const -{ - return SaveFile( Value() ); -} - -bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) -{ - TIXML_STRING filename( _filename ); - value = filename; - - // reading in binary mode so that tinyxml can normalize the EOL - FILE* file = TiXmlFOpen( value.c_str (), "rb" ); - - if ( file ) - { - bool result = LoadFile( file, encoding ); - fclose( file ); - return result; - } - else - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } -} - -bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) -{ - if ( !file ) - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Delete the existing data: - Clear(); - location.Clear(); - - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek( file, 0, SEEK_END ); - length = ftell( file ); - fseek( file, 0, SEEK_SET ); - - // Strange case, but good to handle up front. - if ( length <= 0 ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Subtle bug here. TinyXml did use fgets. But from the XML spec: - // 2.11 End-of-Line Handling - // - // - // ...the XML processor MUST behave as if it normalized all line breaks in external - // parsed entities (including the document entity) on input, before parsing, by translating - // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to - // a single #xA character. - // - // - // It is not clear fgets does that, and certainly isn't clear it works cross platform. - // Generally, you expect fgets to translate from the convention of the OS to the c/unix - // convention, and not work generally. - - /* - while( fgets( buf, sizeof(buf), file ) ) - { - data += buf; - } - */ - - char* buf = new char[ length+1 ]; - buf[0] = 0; - - if ( fread( buf, length, 1, file ) != 1 ) { - delete [] buf; - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Process the buffer in place to normalize new lines. (See comment above.) - // Copies from the 'p' to 'q' pointer, where p can advance faster if - // a newline-carriage return is hit. - // - // Wikipedia: - // Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or - // CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)... - // * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others - // * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS - // * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9 - - const char* p = buf; // the read head - char* q = buf; // the write head - const char CR = 0x0d; - const char LF = 0x0a; - - buf[length] = 0; - while( *p ) { - assert( p < (buf+length) ); - assert( q <= (buf+length) ); - assert( q <= p ); - - if ( *p == CR ) { - *q++ = LF; - p++; - if ( *p == LF ) { // check for CR+LF (and skip LF) - p++; - } - } - else { - *q++ = *p++; - } - } - assert( q <= (buf+length) ); - *q = 0; - - Parse( buf, 0, encoding ); - - delete [] buf; - return !Error(); -} - - -bool TiXmlDocument::SaveFile( const char * filename ) const -{ - // The old c stuff lives on... - FILE* fp = TiXmlFOpen( filename, "w" ); - if ( fp ) - { - bool result = SaveFile( fp ); - fclose( fp ); - return result; - } - return false; -} - - -bool TiXmlDocument::SaveFile( FILE* fp ) const -{ - if ( useMicrosoftBOM ) - { - const unsigned char TIXML_UTF_LEAD_0 = 0xefU; - const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; - const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - - fputc( TIXML_UTF_LEAD_0, fp ); - fputc( TIXML_UTF_LEAD_1, fp ); - fputc( TIXML_UTF_LEAD_2, fp ); - } - Print( fp, 0 ); - return (ferror(fp) == 0); -} - - -void TiXmlDocument::CopyTo( TiXmlDocument* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->error = error; - target->errorId = errorId; - target->errorDesc = errorDesc; - target->tabsize = tabsize; - target->errorLocation = errorLocation; - target->useMicrosoftBOM = useMicrosoftBOM; - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - - -TiXmlNode* TiXmlDocument::Clone() const -{ - TiXmlDocument* clone = new TiXmlDocument(); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlDocument::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - node->Print( cfile, depth ); - fprintf( cfile, "\n" ); - } -} - - -bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -const TiXmlAttribute* TiXmlAttribute::Next() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} - -/* -TiXmlAttribute* TiXmlAttribute::Next() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} -*/ - -const TiXmlAttribute* TiXmlAttribute::Previous() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} - -/* -TiXmlAttribute* TiXmlAttribute::Previous() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} -*/ - -void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - TIXML_STRING n, v; - - EncodeString( name, &n ); - EncodeString( value, &v ); - - if (value.find ('\"') == TIXML_STRING::npos) { - if ( cfile ) { - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; - } - } - else { - if ( cfile ) { - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; - } - } -} - - -int TiXmlAttribute::QueryIntValue( int* ival ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -int TiXmlAttribute::QueryDoubleValue( double* dval ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -void TiXmlAttribute::SetIntValue( int _value ) -{ - char buf [64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); - #else - sprintf (buf, "%d", _value); - #endif - SetValue (buf); -} - -void TiXmlAttribute::SetDoubleValue( double _value ) -{ - char buf [256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value); - #else - sprintf (buf, "%g", _value); - #endif - SetValue (buf); -} - -int TiXmlAttribute::IntValue() const -{ - return atoi (value.c_str ()); -} - -double TiXmlAttribute::DoubleValue() const -{ - return atof (value.c_str ()); -} - - -TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) -{ - copy.CopyTo( this ); -} - - -void TiXmlComment::operator=( const TiXmlComment& base ) -{ - Clear(); - base.CopyTo( this ); -} - - -void TiXmlComment::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlComment::CopyTo( TiXmlComment* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlComment::Clone() const -{ - TiXmlComment* clone = new TiXmlComment(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlText::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - if ( cdata ) - { - int i; - fprintf( cfile, "\n" ); - for ( i=0; i\n", value.c_str() ); // unformatted output - } - else - { - TIXML_STRING buffer; - EncodeString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); - } -} - - -void TiXmlText::CopyTo( TiXmlText* target ) const -{ - TiXmlNode::CopyTo( target ); - target->cdata = cdata; -} - - -bool TiXmlText::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlText::Clone() const -{ - TiXmlText* clone = 0; - clone = new TiXmlText( "" ); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlDeclaration::TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ) - : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} - - -#ifdef TIXML_USE_STL -TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ) - : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} -#endif - - -TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) - : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) -{ - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) -{ - Clear(); - copy.CopyTo( this ); -} - - -void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - if ( cfile ) fprintf( cfile, "" ); - if ( str ) (*str) += "?>"; -} - - -void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->version = version; - target->encoding = encoding; - target->standalone = standalone; -} - - -bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlDeclaration::Clone() const -{ - TiXmlDeclaration* clone = new TiXmlDeclaration(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlUnknown::Print( FILE* cfile, int depth ) const -{ - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlUnknown::Clone() const -{ - TiXmlUnknown* clone = new TiXmlUnknown(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlAttributeSet::TiXmlAttributeSet() -{ - sentinel.next = &sentinel; - sentinel.prev = &sentinel; -} - - -TiXmlAttributeSet::~TiXmlAttributeSet() -{ - assert( sentinel.next == &sentinel ); - assert( sentinel.prev == &sentinel ); -} - - -void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) -{ - #ifdef TIXML_USE_STL - assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. - #else - assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. - #endif - - addMe->next = &sentinel; - addMe->prev = sentinel.prev; - - sentinel.prev->next = addMe; - sentinel.prev = addMe; -} - -void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) -{ - TiXmlAttribute* node; - - for( node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node == removeMe ) - { - node->prev->next = node->next; - node->next->prev = node->prev; - node->next = 0; - node->prev = 0; - return; - } - } - assert( 0 ); // we tried to remove a non-linked attribute. -} - - -#ifdef TIXML_USE_STL -TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} - -TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) -{ - TiXmlAttribute* attrib = Find( _name ); - if ( !attrib ) { - attrib = new TiXmlAttribute(); - Add( attrib ); - attrib->SetName( _name ); - } - return attrib; -} -#endif - - -TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} - - -TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name ) -{ - TiXmlAttribute* attrib = Find( _name ); - if ( !attrib ) { - attrib = new TiXmlAttribute(); - Add( attrib ); - attrib->SetName( _name ); - } - return attrib; -} - - -#ifdef TIXML_USE_STL -std::istream& operator>> (std::istream & in, TiXmlNode & base) -{ - TIXML_STRING tag; - tag.reserve( 8 * 1000 ); - base.StreamIn( &in, &tag ); - - base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); - return in; -} -#endif - - -#ifdef TIXML_USE_STL -std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out << printer.Str(); - - return out; -} - - -std::string& operator<< (std::string& out, const TiXmlNode& base ) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out.append( printer.Str() ); - - return out; -} -#endif - - -TiXmlHandle TiXmlHandle::FirstChild() const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement() const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild(); - for ( i=0; - child && iNextSibling(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild( value ); - for ( i=0; - child && iNextSibling( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement(); - for ( i=0; - child && iNextSiblingElement(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement( value ); - for ( i=0; - child && iNextSiblingElement( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) -{ - DoIndent(); - buffer += "<"; - buffer += element.Value(); - - for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) - { - buffer += " "; - attrib->Print( 0, 0, &buffer ); - } - - if ( !element.FirstChild() ) - { - buffer += " />"; - DoLineBreak(); - } - else - { - buffer += ">"; - if ( element.FirstChild()->ToText() - && element.LastChild() == element.FirstChild() - && element.FirstChild()->ToText()->CDATA() == false ) - { - simpleTextPrint = true; - // no DoLineBreak()! - } - else - { - DoLineBreak(); - } - } - ++depth; - return true; -} - - -bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) -{ - --depth; - if ( !element.FirstChild() ) - { - // nothing. - } - else - { - if ( simpleTextPrint ) - { - simpleTextPrint = false; - } - else - { - DoIndent(); - } - buffer += ""; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlText& text ) -{ - if ( text.CDATA() ) - { - DoIndent(); - buffer += ""; - DoLineBreak(); - } - else if ( simpleTextPrint ) - { - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - } - else - { - DoIndent(); - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) -{ - DoIndent(); - declaration.Print( 0, 0, &buffer ); - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlComment& comment ) -{ - DoIndent(); - buffer += ""; - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) -{ - DoIndent(); - buffer += "<"; - buffer += unknown.Value(); - buffer += ">"; - DoLineBreak(); - return true; -} - diff --git a/jni/edn/tools/tinyXML/tinyxml.h b/jni/edn/tools/tinyXML/tinyxml.h deleted file mode 100644 index 0182291..0000000 --- a/jni/edn/tools/tinyXML/tinyxml.h +++ /dev/null @@ -1,1799 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - - -#ifndef TINYXML_INCLUDED -#define TINYXML_INCLUDED - -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable : 4530 ) -#pragma warning( disable : 4786 ) -#endif - -#include -#include -#include -#include -#include - -// Help out windows: -#if defined( _DEBUG ) && !defined( DEBUG ) -#define DEBUG -#endif - -#ifdef TIXML_USE_STL - #include - #include - #include - #define TIXML_STRING std::string -#else - #include "tinystr.h" - #define TIXML_STRING TiXmlString -#endif - -// Deprecated library function hell. Compilers want to use the -// new safe versions. This probably doesn't fully address the problem, -// but it gets closer. There are too many compilers for me to fully -// test. If you get compilation troubles, undefine TIXML_SAFE -#define TIXML_SAFE - -#ifdef TIXML_SAFE - #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - // Microsoft visual studio, version 2005 and higher. - #define TIXML_SNPRINTF _snprintf_s - #define TIXML_SSCANF sscanf_s - #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) - // Microsoft visual studio, version 6 and higher. - //#pragma message( "Using _sn* functions." ) - #define TIXML_SNPRINTF _snprintf - #define TIXML_SSCANF sscanf - #elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - //#warning( "Using sn* functions." ) - #define TIXML_SNPRINTF snprintf - #define TIXML_SSCANF sscanf - #else - #define TIXML_SNPRINTF snprintf - #define TIXML_SSCANF sscanf - #endif -#endif - -class TiXmlDocument; -class TiXmlElement; -class TiXmlComment; -class TiXmlUnknown; -class TiXmlAttribute; -class TiXmlText; -class TiXmlDeclaration; -class TiXmlParsingData; - -const int TIXML_MAJOR_VERSION = 2; -const int TIXML_MINOR_VERSION = 6; -const int TIXML_PATCH_VERSION = 1; - -/* Internal structure for tracking location of items - in the XML file. -*/ -struct TiXmlCursor -{ - TiXmlCursor() { Clear(); } - void Clear() { row = col = -1; } - - int row; // 0 based. - int col; // 0 based. -}; - - -/** - Implements the interface to the "Visitor pattern" (see the Accept() method.) - If you call the Accept() method, it requires being passed a TiXmlVisitor - class to handle callbacks. For nodes that contain other nodes (Document, Element) - you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves - are simply called with Visit(). - - If you return 'true' from a Visit method, recursive parsing will continue. If you return - false, no children of this node or its sibilings will be Visited. - - All flavors of Visit methods have a default implementation that returns 'true' (continue - visiting). You need to only override methods that are interesting to you. - - Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. - - You should never change the document from a callback. - - @sa TiXmlNode::Accept() -*/ -class TiXmlVisitor -{ -public: - virtual ~TiXmlVisitor() {} - - /// Visit a document. - virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } - /// Visit a document. - virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } - - /// Visit an element. - virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } - /// Visit an element. - virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } - - /// Visit a declaration - virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } - /// Visit a text node - virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } - /// Visit a comment node - virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } - /// Visit an unknow node - virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } -}; - -// Only used by Attribute::Query functions -enum -{ - TIXML_SUCCESS, - TIXML_NO_ATTRIBUTE, - TIXML_WRONG_TYPE -}; - - -// Used by the parsing routines. -enum TiXmlEncoding -{ - TIXML_ENCODING_UNKNOWN, - TIXML_ENCODING_UTF8, - TIXML_ENCODING_LEGACY -}; - -const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; - -/** TiXmlBase is a base class for every class in TinyXml. - It does little except to establish that TinyXml classes - can be printed and provide some utility functions. - - In XML, the document and elements can contain - other elements and other types of nodes. - - @verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) - - A Decleration contains: Attributes (not on tree) - @endverbatim -*/ -class TiXmlBase -{ - friend class TiXmlNode; - friend class TiXmlElement; - friend class TiXmlDocument; - -public: - TiXmlBase() : userData(0) {} - virtual ~TiXmlBase() {} - - /** All TinyXml classes can print themselves to a filestream - or the string class (TiXmlString in non-STL mode, std::string - in STL mode.) Either or both cfile and str can be null. - - This is a formatted print, and will insert - tabs and newlines. - - (For an unformatted stream, use the << operator.) - */ - virtual void Print( FILE* cfile, int depth ) const = 0; - - /** The world does not agree on whether white space should be kept or - not. In order to make everyone happy, these global, static functions - are provided to set whether or not TinyXml will condense all white space - into a single space or not. The default is to condense. Note changing this - value is not thread safe. - */ - static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } - - /// Return the current white space setting. - static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } - - /** Return the position, in the original source file, of this node or attribute. - The row and column are 1-based. (That is the first row and first column is - 1,1). If the returns values are 0 or less, then the parser does not have - a row and column value. - - Generally, the row and column value will be set when the TiXmlDocument::Load(), - TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set - when the DOM was created from operator>>. - - The values reflect the initial load. Once the DOM is modified programmatically - (by adding or changing nodes and attributes) the new values will NOT update to - reflect changes in the document. - - There is a minor performance cost to computing the row and column. Computation - can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. - - @sa TiXmlDocument::SetTabSize() - */ - int Row() const { return location.row + 1; } - int Column() const { return location.col + 1; } ///< See Row() - - void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. - void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. - const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. - - // Table that returs, for a given lead byte, the total number of bytes - // in the UTF-8 sequence. - static const int utf8ByteTable[256]; - - virtual const char* Parse( const char* p, - TiXmlParsingData* data, - TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; - - /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, - or they will be transformed into entities! - */ - static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); - - enum - { - TIXML_NO_ERROR = 0, - TIXML_ERROR, - TIXML_ERROR_OPENING_FILE, - TIXML_ERROR_PARSING_ELEMENT, - TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, - TIXML_ERROR_READING_ELEMENT_VALUE, - TIXML_ERROR_READING_ATTRIBUTES, - TIXML_ERROR_PARSING_EMPTY, - TIXML_ERROR_READING_END_TAG, - TIXML_ERROR_PARSING_UNKNOWN, - TIXML_ERROR_PARSING_COMMENT, - TIXML_ERROR_PARSING_DECLARATION, - TIXML_ERROR_DOCUMENT_EMPTY, - TIXML_ERROR_EMBEDDED_NULL, - TIXML_ERROR_PARSING_CDATA, - TIXML_ERROR_DOCUMENT_TOP_ONLY, - - TIXML_ERROR_STRING_COUNT - }; - -protected: - - static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); - - inline static bool IsWhiteSpace( char c ) - { - return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); - } - inline static bool IsWhiteSpace( int c ) - { - if ( c < 256 ) - return IsWhiteSpace( (char) c ); - return false; // Again, only truly correct for English/Latin...but usually works. - } - - #ifdef TIXML_USE_STL - static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); - static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); - #endif - - /* Reads an XML name into the string provided. Returns - a pointer just past the last character of the name, - or 0 if the function has an error. - */ - static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); - - /* Reads text. Returns a pointer past the given end tag. - Wickedly complex options, but it keeps the (sensitive) code in one place. - */ - static const char* ReadText( const char* in, // where to start - TIXML_STRING* text, // the string read - bool ignoreWhiteSpace, // whether to keep the white space - const char* endTag, // what ends this text - bool ignoreCase, // whether to ignore case in the end tag - TiXmlEncoding encoding ); // the current encoding - - // If an entity has been found, transform it into a character. - static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); - - // Get a character, while interpreting entities. - // The length can be from 0 to 4 bytes. - inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) - { - assert( p ); - if ( encoding == TIXML_ENCODING_UTF8 ) - { - *length = utf8ByteTable[ *((const unsigned char*)p) ]; - assert( *length >= 0 && *length < 5 ); - } - else - { - *length = 1; - } - - if ( *length == 1 ) - { - if ( *p == '&' ) - return GetEntity( p, _value, length, encoding ); - *_value = *p; - return p+1; - } - else if ( *length ) - { - //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), - // and the null terminator isn't needed - for( int i=0; p[i] && i<*length; ++i ) { - _value[i] = p[i]; - } - return p + (*length); - } - else - { - // Not valid text. - return 0; - } - } - - // Return true if the next characters in the stream are any of the endTag sequences. - // Ignore case only works for english, and should only be relied on when comparing - // to English words: StringEqual( p, "version", true ) is fine. - static bool StringEqual( const char* p, - const char* endTag, - bool ignoreCase, - TiXmlEncoding encoding ); - - static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; - - TiXmlCursor location; - - /// Field containing a generic user pointer - void* userData; - - // None of these methods are reliable for any language except English. - // Good for approximation, not great for accuracy. - static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); - static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); - inline static int ToLower( int v, TiXmlEncoding encoding ) - { - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( v < 128 ) return tolower( v ); - return v; - } - else - { - return tolower( v ); - } - } - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); - -private: - TiXmlBase( const TiXmlBase& ); // not implemented. - void operator=( const TiXmlBase& base ); // not allowed. - - struct Entity - { - const char* str; - unsigned int strLength; - char chr; - }; - enum - { - NUM_ENTITY = 5, - MAX_ENTITY_LENGTH = 6 - - }; - static Entity entity[ NUM_ENTITY ]; - static bool condenseWhiteSpace; -}; - - -/** The parent class for everything in the Document Object Model. - (Except for attributes). - Nodes have siblings, a parent, and children. A node can be - in a document, or stand on its own. The type of a TiXmlNode - can be queried, and it can be cast to its more defined type. -*/ -class TiXmlNode : public TiXmlBase -{ - friend class TiXmlDocument; - friend class TiXmlElement; - -public: - #ifdef TIXML_USE_STL - - /** An input stream operator, for every class. Tolerant of newlines and - formatting, but doesn't expect them. - */ - friend std::istream& operator >> (std::istream& in, TiXmlNode& base); - - /** An output stream operator, for every class. Note that this outputs - without any newlines or formatting, as opposed to Print(), which - includes tabs and new lines. - - The operator<< and operator>> are not completely symmetric. Writing - a node to a stream is very well defined. You'll get a nice stream - of output, without any extra whitespace or newlines. - - But reading is not as well defined. (As it always is.) If you create - a TiXmlElement (for example) and read that from an input stream, - the text needs to define an element or junk will result. This is - true of all input streams, but it's worth keeping in mind. - - A TiXmlDocument will read nodes until it reads a root element, and - all the children of that root element. - */ - friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); - - /// Appends the XML node or attribute to a std::string. - friend std::string& operator<< (std::string& out, const TiXmlNode& base ); - - #endif - - /** The types of XML nodes supported by TinyXml. (All the - unsupported types are picked up by UNKNOWN.) - */ - enum NodeType - { - TINYXML_DOCUMENT, - TINYXML_ELEMENT, - TINYXML_COMMENT, - TINYXML_UNKNOWN, - TINYXML_TEXT, - TINYXML_DECLARATION, - TINYXML_TYPECOUNT - }; - - virtual ~TiXmlNode(); - - /** The meaning of 'value' changes for the specific type of - TiXmlNode. - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - - The subclasses will wrap this function. - */ - const char *Value() const { return value.c_str (); } - - #ifdef TIXML_USE_STL - /** Return Value() as a std::string. If you only use STL, - this is more efficient than calling Value(). - Only available in STL mode. - */ - const std::string& ValueStr() const { return value; } - #endif - - const TIXML_STRING& ValueTStr() const { return value; } - - /** Changes the value of the node. Defined as: - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - */ - void SetValue(const char * _value) { value = _value;} - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Delete all the children of this node. Does not affect 'this'. - void Clear(); - - /// One step up the DOM. - TiXmlNode* Parent() { return parent; } - const TiXmlNode* Parent() const { return parent; } - - const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. - TiXmlNode* FirstChild() { return firstChild; } - const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. - /// The first child of this node with the matching 'value'. Will be null if none found. - TiXmlNode* FirstChild( const char * _value ) { - // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) - // call the method, cast the return back to non-const. - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); - } - const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. - TiXmlNode* LastChild() { return lastChild; } - - const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. - TiXmlNode* LastChild( const char * _value ) { - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. - #endif - - /** An alternate way to walk the children of a node. - One way to iterate over nodes is: - @verbatim - for( child = parent->FirstChild(); child; child = child->NextSibling() ) - @endverbatim - - IterateChildren does the same thing with the syntax: - @verbatim - child = 0; - while( child = parent->IterateChildren( child ) ) - @endverbatim - - IterateChildren takes the previous child as input and finds - the next one. If the previous child is null, it returns the - first. IterateChildren will return null when done. - */ - const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); - } - - /// This flavor of IterateChildren searches for children with a particular 'value' - const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - #endif - - /** Add a new node related to this. Adds a child past the LastChild. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); - - - /** Add a new node related to this. Adds a child past the LastChild. - - NOTE: the node to be added is passed by pointer, and will be - henceforth owned (and deleted) by tinyXml. This method is efficient - and avoids an extra copy, but should be used with care as it - uses a different memory model than the other insert functions. - - @sa InsertEndChild - */ - TiXmlNode* LinkEndChild( TiXmlNode* addThis ); - - /** Add a new node related to this. Adds a child before the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); - - /** Add a new node related to this. Adds a child after the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); - - /** Replace a child of this node. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); - - /// Delete a child of this node. - bool RemoveChild( TiXmlNode* removeThis ); - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling() const { return prev; } - TiXmlNode* PreviousSibling() { return prev; } - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling( const char * ) const; - TiXmlNode* PreviousSibling( const char *_prev ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Navigate to a sibling node. - const TiXmlNode* NextSibling() const { return next; } - TiXmlNode* NextSibling() { return next; } - - /// Navigate to a sibling node with the given 'value'. - const TiXmlNode* NextSibling( const char * ) const; - TiXmlNode* NextSibling( const char* _next ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement() const; - TiXmlElement* NextSiblingElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement( const char * ) const; - TiXmlElement* NextSiblingElement( const char *_next ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement() const; - TiXmlElement* FirstChildElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); - } - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement( const char * _value ) const; - TiXmlElement* FirstChildElement( const char * _value ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /** Query the type (as an enumerated value, above) of this node. - The possible types are: DOCUMENT, ELEMENT, COMMENT, - UNKNOWN, TEXT, and DECLARATION. - */ - int Type() const { return type; } - - /** Return a pointer to the Document this node lives in. - Returns null if not in a document. - */ - const TiXmlDocument* GetDocument() const; - TiXmlDocument* GetDocument() { - return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); - } - - /// Returns true if this node has no children. - bool NoChildren() const { return !firstChild; } - - virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - /** Create an exact duplicate of this node and return it. The memory must be deleted - by the caller. - */ - virtual TiXmlNode* Clone() const = 0; - - /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the - XML tree will be conditionally visited and the host will be called back - via the TiXmlVisitor interface. - - This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML is unchanged by using this - interface versus any other.) - - The interface has been based on ideas from: - - - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern - - Which are both good references for "visiting". - - An example of using Accept(): - @verbatim - TiXmlPrinter printer; - tinyxmlDoc.Accept( &printer ); - const char* xmlcstr = printer.CStr(); - @endverbatim - */ - virtual bool Accept( TiXmlVisitor* visitor ) const = 0; - -protected: - TiXmlNode( NodeType _type ); - - // Copy to the allocated object. Shared functionality between Clone, Copy constructor, - // and the assignment operator. - void CopyTo( TiXmlNode* target ) const; - - #ifdef TIXML_USE_STL - // The real work of the input operator. - virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; - #endif - - // Figure out what is at *p, and parse it. Returns null if it is not an xml node. - TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); - - TiXmlNode* parent; - NodeType type; - - TiXmlNode* firstChild; - TiXmlNode* lastChild; - - TIXML_STRING value; - - TiXmlNode* prev; - TiXmlNode* next; - -private: - TiXmlNode( const TiXmlNode& ); // not implemented. - void operator=( const TiXmlNode& base ); // not allowed. -}; - - -/** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. - - @note The attributes are not TiXmlNodes, since they are not - part of the tinyXML document object model. There are other - suggested ways to look at this problem. -*/ -class TiXmlAttribute : public TiXmlBase -{ - friend class TiXmlAttributeSet; - -public: - /// Construct an empty attribute. - TiXmlAttribute() : TiXmlBase() - { - document = 0; - prev = next = 0; - } - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlAttribute( const std::string& _name, const std::string& _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - #endif - - /// Construct an attribute with a name and value. - TiXmlAttribute( const char * _name, const char * _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - - const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. - const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. - #ifdef TIXML_USE_STL - const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. - #endif - int IntValue() const; ///< Return the value of this attribute, converted to an integer. - double DoubleValue() const; ///< Return the value of this attribute, converted to a double. - - // Get the tinyxml string representation - const TIXML_STRING& NameTStr() const { return name; } - - /** QueryIntValue examines the value string. It is an alternative to the - IntValue() method with richer error checking. - If the value is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. - - A specialized but useful call. Note that for success it returns 0, - which is the opposite of almost all other TinyXml calls. - */ - int QueryIntValue( int* _value ) const; - /// QueryDoubleValue examines the value string. See QueryIntValue(). - int QueryDoubleValue( double* _value ) const; - - void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. - void SetValue( const char* _value ) { value = _value; } ///< Set the value. - - void SetIntValue( int _value ); ///< Set the value from an integer. - void SetDoubleValue( double _value ); ///< Set the value from a double. - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetName( const std::string& _name ) { name = _name; } - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Get the next sibling attribute in the DOM. Returns null at end. - const TiXmlAttribute* Next() const; - TiXmlAttribute* Next() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); - } - - /// Get the previous sibling attribute in the DOM. Returns null at beginning. - const TiXmlAttribute* Previous() const; - TiXmlAttribute* Previous() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); - } - - bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } - bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } - bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } - - /* Attribute parsing starts: first letter of the name - returns: the next char after the value end quote - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - // Prints this Attribute to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - - // [internal use] - // Set the document pointer so the attribute can report errors. - void SetDocument( TiXmlDocument* doc ) { document = doc; } - -private: - TiXmlAttribute( const TiXmlAttribute& ); // not implemented. - void operator=( const TiXmlAttribute& base ); // not allowed. - - TiXmlDocument* document; // A pointer back to a document, for error reporting. - TIXML_STRING name; - TIXML_STRING value; - TiXmlAttribute* prev; - TiXmlAttribute* next; -}; - - -/* A class used to manage a group of attributes. - It is only used internally, both by the ELEMENT and the DECLARATION. - - The set can be changed transparent to the Element and Declaration - classes that use it, but NOT transparent to the Attribute - which has to implement a next() and previous() method. Which makes - it a bit problematic and prevents the use of STL. - - This version is implemented with circular lists because: - - I like circular lists - - it demonstrates some independence from the (typical) doubly linked list. -*/ -class TiXmlAttributeSet -{ -public: - TiXmlAttributeSet(); - ~TiXmlAttributeSet(); - - void Add( TiXmlAttribute* attribute ); - void Remove( TiXmlAttribute* attribute ); - - const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - - TiXmlAttribute* Find( const char* _name ) const; - TiXmlAttribute* FindOrCreate( const char* _name ); - -# ifdef TIXML_USE_STL - TiXmlAttribute* Find( const std::string& _name ) const; - TiXmlAttribute* FindOrCreate( const std::string& _name ); -# endif - - -private: - //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), - //*ME: this class must be also use a hidden/disabled copy-constructor !!! - TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed - void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) - - TiXmlAttribute sentinel; -}; - - -/** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. -*/ -class TiXmlElement : public TiXmlNode -{ -public: - /// Construct an element. - TiXmlElement (const char * in_value); - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlElement( const std::string& _value ); - #endif - - TiXmlElement( const TiXmlElement& ); - - void operator=( const TiXmlElement& base ); - - virtual ~TiXmlElement(); - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - */ - const char* Attribute( const char* name ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an integer, - the integer value will be put in the return 'i', if 'i' - is non-null. - */ - const char* Attribute( const char* name, int* i ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an double, - the double value will be put in the return 'd', if 'd' - is non-null. - */ - const char* Attribute( const char* name, double* d ) const; - - /** QueryIntAttribute examines the attribute - it is an alternative to the - Attribute() method with richer error checking. - If the attribute is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. If the attribute - does not exist, then TIXML_NO_ATTRIBUTE is returned. - */ - int QueryIntAttribute( const char* name, int* _value ) const; - /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). - int QueryDoubleAttribute( const char* name, double* _value ) const; - /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). - int QueryFloatAttribute( const char* name, float* _value ) const { - double d; - int result = QueryDoubleAttribute( name, &d ); - if ( result == TIXML_SUCCESS ) { - *_value = (float)d; - } - return result; - } - - #ifdef TIXML_USE_STL - /// QueryStringAttribute examines the attribute - see QueryIntAttribute(). - int QueryStringAttribute( const char* name, std::string* _value ) const { - const char* cstr = Attribute( name ); - if ( cstr ) { - *_value = std::string( cstr ); - return TIXML_SUCCESS; - } - return TIXML_NO_ATTRIBUTE; - } - - /** Template form of the attribute query which will try to read the - attribute into the specified type. Very easy, very powerful, but - be careful to make sure to call this with the correct type. - - NOTE: This method doesn't work correctly for 'string' types that contain spaces. - - @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE - */ - template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - - std::stringstream sstream( node->ValueStr() ); - sstream >> *outValue; - if ( !sstream.fail() ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; - } - - int QueryValueAttribute( const std::string& name, std::string* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - *outValue = node->ValueStr(); - return TIXML_SUCCESS; - } - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char* name, const char * _value ); - - #ifdef TIXML_USE_STL - const std::string* Attribute( const std::string& name ) const; - const std::string* Attribute( const std::string& name, int* i ) const; - const std::string* Attribute( const std::string& name, double* d ) const; - int QueryIntAttribute( const std::string& name, int* _value ) const; - int QueryDoubleAttribute( const std::string& name, double* _value ) const; - - /// STL std::string form. - void SetAttribute( const std::string& name, const std::string& _value ); - ///< STL std::string form. - void SetAttribute( const std::string& name, int _value ); - ///< STL std::string form. - void SetDoubleAttribute( const std::string& name, double value ); - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char * name, int value ); - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetDoubleAttribute( const char * name, double value ); - - /** Deletes an attribute with the given name. - */ - void RemoveAttribute( const char * name ); - #ifdef TIXML_USE_STL - void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. - #endif - - const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. - TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } - const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. - TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the TiXmlText child - and accessing it directly. - - If the first child of 'this' is a TiXmlText, the GetText() - returns the character string of the Text node, else null is returned. - - This is a convenient method for getting the text of simple contained text: - @verbatim - This is text - const char* str = fooElement->GetText(); - @endverbatim - - 'str' will be a pointer to "This is text". - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then the value of str would be null. The first child node isn't a text node, it is - another element. From this XML: - @verbatim - This is text - @endverbatim - GetText() will return "This is ". - - WARNING: GetText() accesses a child node - don't become confused with the - similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are - safe type casts on the referenced node. - */ - const char* GetText() const; - - /// Creates a new Element and returns it - the returned element is a copy. - virtual TiXmlNode* Clone() const; - // Print the Element to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: next char past '<' - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - - void CopyTo( TiXmlElement* target ) const; - void ClearThis(); // like clear, but initializes 'this' object as well - - // Used to be public [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - /* [internal use] - Reads the "value" of the element -- another element, or text. - This should terminate with the current end tag. - */ - const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - -private: - TiXmlAttributeSet attributeSet; -}; - - -/** An XML comment. -*/ -class TiXmlComment : public TiXmlNode -{ -public: - /// Constructs an empty comment. - TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {} - /// Construct a comment from text. - TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { - SetValue( _value ); - } - TiXmlComment( const TiXmlComment& ); - void operator=( const TiXmlComment& base ); - - virtual ~TiXmlComment() {} - - /// Returns a copy of this Comment. - virtual TiXmlNode* Clone() const; - // Write this Comment to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: at the ! of the !-- - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlComment* target ) const; - - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif -// virtual void StreamOut( TIXML_OSTREAM * out ) const; - -private: - -}; - - -/** XML text. A text node can have 2 ways to output the next. "normal" output - and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with - SetCDATA() and query it with CDATA(). -*/ -class TiXmlText : public TiXmlNode -{ - friend class TiXmlElement; -public: - /** Constructor for text element. By default, it is treated as - normal, encoded text. If you want it be output as a CDATA text - element, set the parameter _cdata to 'true' - */ - TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) - { - SetValue( initValue ); - cdata = false; - } - virtual ~TiXmlText() {} - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) - { - SetValue( initValue ); - cdata = false; - } - #endif - - TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); } - void operator=( const TiXmlText& base ) { base.CopyTo( this ); } - - // Write this text object to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /// Queries whether this represents text using a CDATA section. - bool CDATA() const { return cdata; } - /// Turns on or off a CDATA representation of text. - void SetCDATA( bool _cdata ) { cdata = _cdata; } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - /// [internal use] Creates a new Element and returns it. - virtual TiXmlNode* Clone() const; - void CopyTo( TiXmlText* target ) const; - - bool Blank() const; // returns true if all white space and new lines - // [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - bool cdata; // true if this should be input and output as a CDATA style text element -}; - - -/** In correct XML the declaration is the first entry in the file. - @verbatim - - @endverbatim - - TinyXml will happily read or write files without a declaration, - however. There are 3 possible attributes to the declaration: - version, encoding, and standalone. - - Note: In this version of the code, the attributes are - handled as special cases, not generic attributes, simply - because there can only be at most 3 and they are always the same. -*/ -class TiXmlDeclaration : public TiXmlNode -{ -public: - /// Construct an empty declaration. - TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {} - -#ifdef TIXML_USE_STL - /// Constructor. - TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ); -#endif - - /// Construct. - TiXmlDeclaration( const char* _version, - const char* _encoding, - const char* _standalone ); - - TiXmlDeclaration( const TiXmlDeclaration& copy ); - void operator=( const TiXmlDeclaration& copy ); - - virtual ~TiXmlDeclaration() {} - - /// Version. Will return an empty string if none was found. - const char *Version() const { return version.c_str (); } - /// Encoding. Will return an empty string if none was found. - const char *Encoding() const { return encoding.c_str (); } - /// Is this a standalone document? - const char *Standalone() const { return standalone.c_str (); } - - /// Creates a copy of this Declaration and returns it. - virtual TiXmlNode* Clone() const; - // Print this declaration to a FILE stream. - virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlDeclaration* target ) const; - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - - TIXML_STRING version; - TIXML_STRING encoding; - TIXML_STRING standalone; -}; - - -/** Any tag that tinyXml doesn't recognize is saved as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. - - DTD tags get thrown into TiXmlUnknowns. -*/ -class TiXmlUnknown : public TiXmlNode -{ -public: - TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {} - virtual ~TiXmlUnknown() {} - - TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); } - void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } - - /// Creates a copy of this Unknown and returns it. - virtual TiXmlNode* Clone() const; - // Print this Unknown to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected: - void CopyTo( TiXmlUnknown* target ) const; - - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - -}; - - -/** Always the top level node. A document binds together all the - XML pieces. It can be saved, loaded, and printed to the screen. - The 'value' of a document node is the xml file name. -*/ -class TiXmlDocument : public TiXmlNode -{ -public: - /// Create an empty document, that has no name. - TiXmlDocument(); - /// Create a document with a name. The name of the document is also the filename of the xml. - TiXmlDocument( const char * documentName ); - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlDocument( const std::string& documentName ); - #endif - - TiXmlDocument( const TiXmlDocument& copy ); - void operator=( const TiXmlDocument& copy ); - - virtual ~TiXmlDocument() {} - - /** Load a file using the current document value. - Returns true if successful. Will delete any existing - document data before loading. - */ - bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the current document value. Returns true if successful. - bool SaveFile() const; - /// Load a file using the given filename. Returns true if successful. - bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given filename. Returns true if successful. - bool SaveFile( const char * filename ) const; - /** Load a file using the given FILE*. Returns true if successful. Note that this method - doesn't stream - the entire object pointed at by the FILE* - will be interpreted as an XML file. TinyXML doesn't stream in XML from the current - file location. Streaming may be added in the future. - */ - bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given FILE*. Returns true if successful. - bool SaveFile( FILE* ) const; - - #ifdef TIXML_USE_STL - bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. - { - return LoadFile( filename.c_str(), encoding ); - } - bool SaveFile( const std::string& filename ) const ///< STL std::string version. - { - return SaveFile( filename.c_str() ); - } - #endif - - /** Parse the given null terminated block of xml data. Passing in an encoding to this - method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml - to use that encoding, regardless of what TinyXml might otherwise try to detect. - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - - /** Get the root element -- the only top level element -- of the document. - In well formed XML, there should only be one. TinyXml is tolerant of - multiple elements at the document level. - */ - const TiXmlElement* RootElement() const { return FirstChildElement(); } - TiXmlElement* RootElement() { return FirstChildElement(); } - - /** If an error occurs, Error will be set to true. Also, - - The ErrorId() will contain the integer identifier of the error (not generally useful) - - The ErrorDesc() method will return the name of the error. (very useful) - - The ErrorRow() and ErrorCol() will return the location of the error (if known) - */ - bool Error() const { return error; } - - /// Contains a textual (english) description of the error if one occurs. - const char * ErrorDesc() const { return errorDesc.c_str (); } - - /** Generally, you probably want the error string ( ErrorDesc() ). But if you - prefer the ErrorId, this function will fetch it. - */ - int ErrorId() const { return errorId; } - - /** Returns the location (if known) of the error. The first column is column 1, - and the first row is row 1. A value of 0 means the row and column wasn't applicable - (memory errors, for example, have no row/column) or the parser lost the error. (An - error in the error reporting, in that case.) - - @sa SetTabSize, Row, Column - */ - int ErrorRow() const { return errorLocation.row+1; } - int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() - - /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) - to report the correct values for row and column. It does not change the output - or input in any way. - - By calling this method, with a tab size - greater than 0, the row and column of each node and attribute is stored - when the file is loaded. Very useful for tracking the DOM back in to - the source file. - - The tab size is required for calculating the location of nodes. If not - set, the default of 4 is used. The tabsize is set per document. Setting - the tabsize to 0 disables row/column tracking. - - Note that row and column tracking is not supported when using operator>>. - - The tab size needs to be enabled before the parse or load. Correct usage: - @verbatim - TiXmlDocument doc; - doc.SetTabSize( 8 ); - doc.Load( "myfile.xml" ); - @endverbatim - - @sa Row, Column - */ - void SetTabSize( int _tabsize ) { tabsize = _tabsize; } - - int TabSize() const { return tabsize; } - - /** If you have handled the error, it can be reset with this call. The error - state is automatically cleared if you Parse a new XML block. - */ - void ClearError() { error = false; - errorId = 0; - errorDesc = ""; - errorLocation.row = errorLocation.col = 0; - //errorLocation.last = 0; - } - - /** Write the document to standard out using formatted printing ("pretty print"). */ - void Print() const { Print( stdout, 0 ); } - - /* Write the document to a string using formatted printing ("pretty print"). This - will allocate a character array (new char[]) and return it as a pointer. The - calling code pust call delete[] on the return char* to avoid a memory leak. - */ - //char* PrintToMemory() const; - - /// Print this Document to a FILE stream. - virtual void Print( FILE* cfile, int depth = 0 ) const; - // [internal use] - void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - - virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - // [internal use] - virtual TiXmlNode* Clone() const; - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - void CopyTo( TiXmlDocument* target ) const; - - bool error; - int errorId; - TIXML_STRING errorDesc; - int tabsize; - TiXmlCursor errorLocation; - bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. -}; - - -/** - A TiXmlHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml - DOM structure. It is a separate utility class. - - Take an example: - @verbatim - - - - - - - @endverbatim - - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very - easy to write a *lot* of code that looks like: - - @verbatim - TiXmlElement* root = document.FirstChildElement( "Document" ); - if ( root ) - { - TiXmlElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - TiXmlElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - TiXmlElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. - @endverbatim - - And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity - of such code. A TiXmlHandle checks for null pointers so it is perfectly safe - and correct to use: - - @verbatim - TiXmlHandle docHandle( &document ); - TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); - if ( child2 ) - { - // do something useful - @endverbatim - - Which is MUCH more concise and useful. - - It is also safe to copy handles - internally they are nothing more than node pointers. - @verbatim - TiXmlHandle handleCopy = handle; - @endverbatim - - What they should not be used for is iteration: - - @verbatim - int i=0; - while ( true ) - { - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); - if ( !child ) - break; - // do something - ++i; - } - @endverbatim - - It seems reasonable, but it is in fact two embedded while loops. The Child method is - a linear walk to find the element, so this code would iterate much more than it needs - to. Instead, prefer: - - @verbatim - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); - - for( child; child; child=child->NextSiblingElement() ) - { - // do something - } - @endverbatim -*/ -class TiXmlHandle -{ -public: - /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } - /// Copy constructor - TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } - TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } - - /// Return a handle to the first child node. - TiXmlHandle FirstChild() const; - /// Return a handle to the first child node with the given name. - TiXmlHandle FirstChild( const char * value ) const; - /// Return a handle to the first child element. - TiXmlHandle FirstChildElement() const; - /// Return a handle to the first child element with the given name. - TiXmlHandle FirstChildElement( const char * value ) const; - - /** Return a handle to the "index" child with the given name. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( const char* value, int index ) const; - /** Return a handle to the "index" child. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( int index ) const; - /** Return a handle to the "index" child element with the given name. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( const char* value, int index ) const; - /** Return a handle to the "index" child element. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( int index ) const; - - #ifdef TIXML_USE_STL - TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } - TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } - - TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } - TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } - #endif - - /** Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* ToNode() const { return node; } - /** Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } - /** Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } - /** Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } - - /** @deprecated use ToNode. - Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* Node() const { return ToNode(); } - /** @deprecated use ToElement. - Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* Element() const { return ToElement(); } - /** @deprecated use ToText() - Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* Text() const { return ToText(); } - /** @deprecated use ToUnknown() - Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* Unknown() const { return ToUnknown(); } - -private: - TiXmlNode* node; -}; - - -/** Print to memory functionality. The TiXmlPrinter is useful when you need to: - - -# Print to memory (especially in non-STL mode) - -# Control formatting (line endings, etc.) - - When constructed, the TiXmlPrinter is in its default "pretty printing" mode. - Before calling Accept() you can call methods to control the printing - of the XML document. After TiXmlNode::Accept() is called, the printed document can - be accessed via the CStr(), Str(), and Size() methods. - - TiXmlPrinter uses the Visitor API. - @verbatim - TiXmlPrinter printer; - printer.SetIndent( "\t" ); - - doc.Accept( &printer ); - fprintf( stdout, "%s", printer.CStr() ); - @endverbatim -*/ -class TiXmlPrinter : public TiXmlVisitor -{ -public: - TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), - buffer(), indent( " " ), lineBreak( "\n" ) {} - - virtual bool VisitEnter( const TiXmlDocument& doc ); - virtual bool VisitExit( const TiXmlDocument& doc ); - - virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); - virtual bool VisitExit( const TiXmlElement& element ); - - virtual bool Visit( const TiXmlDeclaration& declaration ); - virtual bool Visit( const TiXmlText& text ); - virtual bool Visit( const TiXmlComment& comment ); - virtual bool Visit( const TiXmlUnknown& unknown ); - - /** Set the indent characters for printing. By default 4 spaces - but tab (\t) is also useful, or null/empty string for no indentation. - */ - void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } - /// Query the indention string. - const char* Indent() { return indent.c_str(); } - /** Set the line breaking string. By default set to newline (\n). - Some operating systems prefer other characters, or can be - set to the null/empty string for no indenation. - */ - void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } - /// Query the current line breaking string. - const char* LineBreak() { return lineBreak.c_str(); } - - /** Switch over to "stream printing" which is the most dense formatting without - linebreaks. Common when the XML is needed for network transmission. - */ - void SetStreamPrinting() { indent = ""; - lineBreak = ""; - } - /// Return the result. - const char* CStr() { return buffer.c_str(); } - /// Return the length of the result string. - size_t Size() { return buffer.size(); } - - #ifdef TIXML_USE_STL - /// Return the result. - const std::string& Str() { return buffer; } - #endif - -private: - void DoIndent() { - for( int i=0; i -#include - -#include "tinyxml.h" - -//#define DEBUG_PARSER -#if defined( DEBUG_PARSER ) -# if defined( DEBUG ) && defined( _MSC_VER ) -# include -# define TIXML_LOG OutputDebugString -# else -# define TIXML_LOG printf -# endif -#endif - -// Note tha "PutString" hardcodes the same list. This -// is less flexible than it appears. Changing the entries -// or order will break putstring. -TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = -{ - { "&", 5, '&' }, - { "<", 4, '<' }, - { ">", 4, '>' }, - { """, 6, '\"' }, - { "'", 6, '\'' } -}; - -// Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html -// Including the basic of this table, which determines the #bytes in the -// sequence from the lead byte. 1 placed for invalid sequences -- -// although the result will be junk, pass it through as much as possible. -// Beware of the non-characters in UTF-8: -// ef bb bf (Microsoft "lead bytes") -// ef bf be -// ef bf bf - -const unsigned char TIXML_UTF_LEAD_0 = 0xefU; -const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; -const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - -const int TiXmlBase::utf8ByteTable[256] = -{ - // 0 1 2 3 4 5 6 7 8 9 a b c d e f - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte - 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid -}; - - -void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) -{ - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) - *length = 1; - else if ( input < 0x800 ) - *length = 2; - else if ( input < 0x10000 ) - *length = 3; - else if ( input < 0x200000 ) - *length = 4; - else - { *length = 0; return; } // This code won't covert this correctly anyway. - - output += *length; - - // Scary scary fall throughs. - switch (*length) - { - case 4: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 3: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 2: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 1: - --output; - *output = (char)(input | FIRST_BYTE_MARK[*length]); - } -} - - -/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalpha( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalpha( anyByte ); -// } -} - - -/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalnum( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalnum( anyByte ); -// } -} - - -class TiXmlParsingData -{ - friend class TiXmlDocument; - public: - void Stamp( const char* now, TiXmlEncoding encoding ); - - const TiXmlCursor& Cursor() { return cursor; } - - private: - // Only used by the document! - TiXmlParsingData( const char* start, int _tabsize, int row, int col ) - { - assert( start ); - stamp = start; - tabsize = _tabsize; - cursor.row = row; - cursor.col = col; - } - - TiXmlCursor cursor; - const char* stamp; - int tabsize; -}; - - -void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) -{ - assert( now ); - - // Do nothing if the tabsize is 0. - if ( tabsize < 1 ) - { - return; - } - - // Get the current row, column. - int row = cursor.row; - int col = cursor.col; - const char* p = stamp; - assert( p ); - - while ( p < now ) - { - // Treat p as unsigned, so we have a happy compiler. - const unsigned char* pU = (const unsigned char*)p; - - // Code contributed by Fletcher Dunn: (modified by lee) - switch (*pU) { - case 0: - // We *should* never get here, but in case we do, don't - // advance past the terminating null character, ever - return; - - case '\r': - // bump down to the next line - ++row; - col = 0; - // Eat the character - ++p; - - // Check for \r\n sequence, and treat this as a single character - if (*p == '\n') { - ++p; - } - break; - - case '\n': - // bump down to the next line - ++row; - col = 0; - - // Eat the character - ++p; - - // Check for \n\r sequence, and treat this as a single - // character. (Yes, this bizarre thing does occur still - // on some arcane platforms...) - if (*p == '\r') { - ++p; - } - break; - - case '\t': - // Eat the character - ++p; - - // Skip to next tab stop - col = (col / tabsize + 1) * tabsize; - break; - - case TIXML_UTF_LEAD_0: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( *(p+1) && *(p+2) ) - { - // In these cases, don't advance the column. These are - // 0-width spaces. - if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) - p += 3; - else - { p +=3; ++col; } // A normal character. - } - } - else - { - ++p; - ++col; - } - break; - - default: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // Eat the 1 to 4 byte utf8 character. - int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; - if ( step == 0 ) - step = 1; // Error case from bad encoding, but handle gracefully. - p += step; - - // Just advance one column, of course. - ++col; - } - else - { - ++p; - ++col; - } - break; - } - } - cursor.row = row; - cursor.col = col; - assert( cursor.row >= -1 ); - assert( cursor.col >= -1 ); - stamp = p; - assert( stamp ); -} - - -const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) -{ - if ( !p || !*p ) - { - return 0; - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - while ( *p ) - { - const unsigned char* pU = (const unsigned char*)p; - - // Skip the stupid Microsoft UTF-8 Byte order marks - if ( *(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==TIXML_UTF_LEAD_1 - && *(pU+2)==TIXML_UTF_LEAD_2 ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbeU ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbfU ) - { - p += 3; - continue; - } - - if ( IsWhiteSpace( *p ) ) // Still using old rules for white space. - ++p; - else - break; - } - } - else - { - while ( *p && IsWhiteSpace( *p ) ) - ++p; - } - - return p; -} - -#ifdef TIXML_USE_STL -/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) -{ - for( ;; ) - { - if ( !in->good() ) return false; - - int c = in->peek(); - // At this scope, we can't get to a document. So fail silently. - if ( !IsWhiteSpace( c ) || c <= 0 ) - return true; - - *tag += (char) in->get(); - } -} - -/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) -{ - //assert( character > 0 && character < 128 ); // else it won't work in utf-8 - while ( in->good() ) - { - int c = in->peek(); - if ( c == character ) - return true; - if ( c <= 0 ) // Silent failure: can't get document at this scope - return false; - - in->get(); - *tag += (char) c; - } - return false; -} -#endif - -// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The -// "assign" optimization removes over 10% of the execution time. -// -const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) -{ - // Oddly, not supported on some comilers, - //name->clear(); - // So use this: - *name = ""; - assert( p ); - - // Names start with letters or underscores. - // Of course, in unicode, tinyxml has no idea what a letter *is*. The - // algorithm is generous. - // - // After that, they can be letters, underscores, numbers, - // hyphens, or colons. (Colons are valid ony for namespaces, - // but tinyxml can't tell namespaces from names.) - if ( p && *p - && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) - { - const char* start = p; - while( p && *p - && ( IsAlphaNum( (unsigned char ) *p, encoding ) - || *p == '_' - || *p == '-' - || *p == '.' - || *p == ':' ) ) - { - //(*name) += *p; // expensive - ++p; - } - if ( p-start > 0 ) { - name->assign( start, p-start ); - } - return p; - } - return 0; -} - -const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) -{ - // Presume an entity, and pull it out. - TIXML_STRING ent; - int i; - *length = 0; - - if ( *(p+1) && *(p+1) == '#' && *(p+2) ) - { - unsigned long ucs = 0; - ptrdiff_t delta = 0; - unsigned mult = 1; - - if ( *(p+2) == 'x' ) - { - // Hexadecimal. - if ( !*(p+3) ) return 0; - - const char* q = p+3; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != 'x' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else if ( *q >= 'a' && *q <= 'f' ) - ucs += mult * (*q - 'a' + 10); - else if ( *q >= 'A' && *q <= 'F' ) - ucs += mult * (*q - 'A' + 10 ); - else - return 0; - mult *= 16; - --q; - } - } - else - { - // Decimal. - if ( !*(p+2) ) return 0; - - const char* q = p+2; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != '#' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else - return 0; - mult *= 10; - --q; - } - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - } - else - { - *value = (char)ucs; - *length = 1; - } - return p + delta + 1; - } - - // Now try to match it. - for( i=0; iappend( cArr, len ); - } - } - else - { - bool whitespace = false; - - // Remove leading white space: - p = SkipWhiteSpace( p, encoding ); - while ( p && *p - && !StringEqual( p, endTag, caseInsensitive, encoding ) ) - { - if ( *p == '\r' || *p == '\n' ) - { - whitespace = true; - ++p; - } - else if ( IsWhiteSpace( *p ) ) - { - whitespace = true; - ++p; - } - else - { - // If we've found whitespace, add it before the - // new character. Any whitespace just becomes a space. - if ( whitespace ) - { - (*text) += ' '; - whitespace = false; - } - int len; - char cArr[4] = { 0, 0, 0, 0 }; - p = GetChar( p, cArr, &len, encoding ); - if ( len == 1 ) - (*text) += cArr[0]; // more efficient - else - text->append( cArr, len ); - } - } - } - if ( p && *p ) - p += strlen( endTag ); - return p; -} - -#ifdef TIXML_USE_STL - -void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - // The basic issue with a document is that we don't know what we're - // streaming. Read something presumed to be a tag (and hope), then - // identify it, and call the appropriate stream method on the tag. - // - // This "pre-streaming" will never read the closing ">" so the - // sub-tag can orient itself. - - if ( !StreamTo( in, '<', tag ) ) - { - SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - while ( in->good() ) - { - int tagIndex = (int) tag->length(); - while ( in->good() && in->peek() != '>' ) - { - int c = in->get(); - if ( c <= 0 ) - { - SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - break; - } - (*tag) += (char) c; - } - - if ( in->good() ) - { - // We now have something we presume to be a node of - // some sort. Identify it, and call the node to - // continue streaming. - TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); - - if ( node ) - { - node->StreamIn( in, tag ); - bool isElement = node->ToElement() != 0; - delete node; - node = 0; - - // If this is the root element, we're done. Parsing will be - // done by the >> operator. - if ( isElement ) - { - return; - } - } - else - { - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - } - } - // We should have returned sooner. - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); -} - -#endif - -const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) -{ - ClearError(); - - // Parse away, at the document level. Since a document - // contains nothing but other tags, most of what happens - // here is skipping white space. - if ( !p || !*p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - // Note that, for a document, this needs to come - // before the while space skip, so that parsing - // starts from the pointer we are given. - location.Clear(); - if ( prevData ) - { - location.row = prevData->cursor.row; - location.col = prevData->cursor.col; - } - else - { - location.row = 0; - location.col = 0; - } - TiXmlParsingData data( p, TabSize(), location.row, location.col ); - location = data.Cursor(); - - if ( encoding == TIXML_ENCODING_UNKNOWN ) - { - // Check for the Microsoft UTF-8 lead bytes. - const unsigned char* pU = (const unsigned char*)p; - if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 - && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 - && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) - { - encoding = TIXML_ENCODING_UTF8; - useMicrosoftBOM = true; - } - } - - p = SkipWhiteSpace( p, encoding ); - if ( !p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - while ( p && *p ) - { - TiXmlNode* node = Identify( p, encoding ); - if ( node ) - { - p = node->Parse( p, &data, encoding ); - LinkEndChild( node ); - } - else - { - break; - } - - // Did we get encoding info? - if ( encoding == TIXML_ENCODING_UNKNOWN - && node->ToDeclaration() ) - { - TiXmlDeclaration* dec = node->ToDeclaration(); - const char* enc = dec->Encoding(); - assert( enc ); - - if ( *enc == 0 ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice - else - encoding = TIXML_ENCODING_LEGACY; - } - - p = SkipWhiteSpace( p, encoding ); - } - - // Was this empty? - if ( !firstChild ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); - return 0; - } - - // All is well. - return p; -} - -void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - // The first error in a chain is more accurate - don't set again! - if ( error ) - return; - - assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); - error = true; - errorId = err; - errorDesc = errorString[ errorId ]; - - errorLocation.Clear(); - if ( pError && data ) - { - data->Stamp( pError, encoding ); - errorLocation = data->Cursor(); - } -} - - -TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) -{ - TiXmlNode* returnNode = 0; - - p = SkipWhiteSpace( p, encoding ); - if( !p || !*p || *p != '<' ) - { - return 0; - } - - p = SkipWhiteSpace( p, encoding ); - - if ( !p || !*p ) - { - return 0; - } - - // What is this thing? - // - Elements start with a letter or underscore, but xml is reserved. - // - Comments: "; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // [ 1475201 ] TinyXML parses entities in comments - // Oops - ReadText doesn't work, because we don't want to parse the entities. - // p = ReadText( p, &value, false, endTag, false, encoding ); - // - // from the XML spec: - /* - [Definition: Comments may appear anywhere in a document outside other markup; in addition, - they may appear within the document type declaration at places allowed by the grammar. - They are not part of the document's character data; an XML processor MAY, but need not, - make it possible for an application to retrieve the text of comments. For compatibility, - the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity - references MUST NOT be recognized within comments. - - An example of a comment: - - - */ - - value = ""; - // Keep all the white space. - while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) - { - value.append( p, 1 ); - ++p; - } - if ( p && *p ) - p += strlen( endTag ); - - return p; -} - - -const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) return 0; - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - // Read the name, the '=' and the value. - const char* pErr = p; - p = ReadName( p, &name, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; - } - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p || *p != '=' ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - ++p; // skip '=' - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - const char* end; - const char SINGLE_QUOTE = '\''; - const char DOUBLE_QUOTE = '\"'; - - if ( *p == SINGLE_QUOTE ) - { - ++p; - end = "\'"; // single quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else if ( *p == DOUBLE_QUOTE ) - { - ++p; - end = "\""; // double quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else - { - // All attribute values should be in single or double quotes. - // But this is such a common error that the parser will try - // its best, even without them. - value = ""; - while ( p && *p // existence - && !IsWhiteSpace( *p ) // whitespace - && *p != '/' && *p != '>' ) // tag end - { - if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { - // [ 1451649 ] Attribute values with trailing quotes not handled correctly - // We did not have an opening quote but seem to have a - // closing one. Give up and throw an error. - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - value += *p; - ++p; - } - } - return p; -} - -#ifdef TIXML_USE_STL -void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->peek(); - if ( !cdata && (c == '<' ) ) - { - return; - } - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - (*tag) += (char) c; - in->get(); // "commits" the peek made above - - if ( cdata && c == '>' && tag->size() >= 3 ) { - size_t len = tag->size(); - if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { - // terminator of cdata. - return; - } - } - } -} -#endif - -const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - value = ""; - TiXmlDocument* document = GetDocument(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - - const char* const startTag = ""; - - if ( cdata || StringEqual( p, startTag, false, encoding ) ) - { - cdata = true; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // Keep all the white space, ignore the encoding, etc. - while ( p && *p - && !StringEqual( p, endTag, false, encoding ) - ) - { - value += *p; - ++p; - } - - TIXML_STRING dummy; - p = ReadText( p, &dummy, false, endTag, false, encoding ); - return p; - } - else - { - bool ignoreWhite = true; - - const char* end = "<"; - p = ReadText( p, &value, ignoreWhite, end, false, encoding ); - if ( p ) - return p-1; // don't truncate the '<' - return 0; - } -} - -#ifdef TIXML_USE_STL -void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - (*tag) += (char) c; - - if ( c == '>' ) - { - // All is well. - return; - } - } -} -#endif - -const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) -{ - p = SkipWhiteSpace( p, _encoding ); - // Find the beginning, find the end, and look for - // the stuff in-between. - TiXmlDocument* document = GetDocument(); - if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); - return 0; - } - if ( data ) - { - data->Stamp( p, _encoding ); - location = data->Cursor(); - } - p += 5; - - version = ""; - encoding = ""; - standalone = ""; - - while ( p && *p ) - { - if ( *p == '>' ) - { - ++p; - return p; - } - - p = SkipWhiteSpace( p, _encoding ); - if ( StringEqual( p, "version", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - version = attrib.Value(); - } - else if ( StringEqual( p, "encoding", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - encoding = attrib.Value(); - } - else if ( StringEqual( p, "standalone", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - standalone = attrib.Value(); - } - else - { - // Read over whatever it is. - while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) - ++p; - } - } - return 0; -} - -bool TiXmlText::Blank() const -{ - for ( unsigned i=0; i