From 87316c738a91e11a64e3ada8bdc8d704657f7bbb Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 13 Jul 2016 22:27:54 +0200 Subject: [PATCH] [DEV] start rework that does not work --- doc/build.md | 66 +++++++++++++++++++++++++++++++++++ doc/mainpage.md | 71 ++++++++++++++++++++++++++++++++++++++ doc/read.md | 80 +++++++++++++++++++++++++++++++++++++++++++ doc/write.md | 61 +++++++++++++++++++++++++++++++++ egami/egami.cpp | 2 +- lutin_egami-sample.py | 45 ++++++++++++++++++++++++ sample/main.cpp | 32 +++++++++++++++++ sample/read.cpp | 54 +++++++++++++++++++++++++++++ sample/read.h | 11 ++++++ sample/read.xml | 8 +++++ sample/write.cpp | 44 ++++++++++++++++++++++++ sample/write.h | 12 +++++++ 12 files changed, 485 insertions(+), 1 deletion(-) create mode 100644 doc/build.md create mode 100644 doc/mainpage.md create mode 100644 doc/read.md create mode 100644 doc/write.md create mode 100644 lutin_egami-sample.py create mode 100644 sample/main.cpp create mode 100644 sample/read.cpp create mode 100644 sample/read.h create mode 100644 sample/read.xml create mode 100644 sample/write.cpp create mode 100644 sample/write.h diff --git a/doc/build.md b/doc/build.md new file mode 100644 index 0000000..fda02c0 --- /dev/null +++ b/doc/build.md @@ -0,0 +1,66 @@ +Build lib & build sample {#exml_build} +======================== + +@tableofcontents + +Download: {#exml_build_download} +========= + +exml use some tools to manage source and build it: + +lutin (build-system): {#exml_build_download_lutin} +--------------------- + +```{.sh} + pip install lutin --user + # optionnal dependency of lutin (manage image changing size for application release) + pip install pillow --user +``` + + +dependency: {#exml_build_download_dependency} +----------- + +```{.sh} + mkdir framework + cd framework + git clone https://github.com/atria-soft/elog.git + git clone https://github.com/atria-soft/etk.git + git clone https://github.com/atria-soft/ememory.git + cd .. +``` + +sources: {#exml_build_download_sources} +-------- + +```{.sh} + cd framework + git clone https://github.com/atria-soft/exml.git + cd .. +``` + +Build: {#exml_build_build} +====== + + +library: {#exml_build_build_library} +-------- + +```{.sh} + lutin -mdebug exml +``` + +Sample: {#exml_build_build_sample} +------- + +```{.sh} + lutin -mdebug exml-sample +``` + + +Run sample: {#exml_build_run_sample} +=========== + +```{.sh} + lutin -mdebug exml-sample?run +``` diff --git a/doc/mainpage.md b/doc/mainpage.md new file mode 100644 index 0000000..7f11df8 --- /dev/null +++ b/doc/mainpage.md @@ -0,0 +1,71 @@ +EXML library {#mainpage} +============ + +@tableofcontents + +What is EXML: {#exml_mainpage_what} +================== + +EXML, or Ewol XML interface is a simple, small, efficient, C++ XML parser/generator that can be easily integrating into other programs. + +What it does: {#exml_mainpage_what_it_does} +------------- + +EXML parses an XML document, and builds from that a Document Object Model (DOM) that can be read, modified, and saved. + +XML stands for "eXtensible Markup Language." It is a general purpose human and machine readable markup language to describe arbitrary data. +All those random file formats created to store application data can all be replaced with XML. One parser for everything. + +http://wikipedia.org/wiki/XML + +There are different ways to access and interact with XML data. +EXML uses a Document Object Model (DOM), meaning the XML data is parsed into a C++ objects that can be browsed and manipulated, and then written to disk. +You can also construct an XML document from scratch with C++ objects and write this to disk. + +EXML is designed to be easy and fast to learn. + +EXML is dependent of the STL (compatible with MacOs stl (CXX)) + +What it doesn't do: {#exml_mainpage_what_it_not_does} +------------------- + +EXML doesn't parse or use DTDs (Document Type Definitions) or XSLs (eXtensible Stylesheet Language). + +What languages are supported? {#exml_mainpage_language} +============================= + +EXML is written in C++. + + +Are there any licensing restrictions? {#exml_mainpage_license_restriction} +===================================== + +EXML is **FREE software** and _all sub-library are FREE and staticly linkable !!!_ + + +License (APACHE-2.0) {#exml_mainpage_license} +==================== + +Copyright EXML Edouard DUPIN + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + +Other pages {#exml_mainpage_sub_page} +=========== + + - @ref exml_build + - @ref exml_tutorial_read + - @ref exml_tutorial_write + - [**ewol coding style**](http://atria-soft.github.io/ewol/ewol_coding_style.html) + diff --git a/doc/read.md b/doc/read.md new file mode 100644 index 0000000..40398ef --- /dev/null +++ b/doc/read.md @@ -0,0 +1,80 @@ +Read an XML content {#exml_tutorial_read} +=================== + +@tableofcontents + +The first thing to do when reading or writing a XML file/stream, is to declare the Document interface + +Include exml +@snippet read.cpp exml_sample_include + +Declare document interface +@snippet read.cpp exml_sample_declare_doc + + +Read an XML file {#exml_tutorial_read_file} +================ + +File to read: "read.xml" +@include read.xml + +Reading a file is done like this: +@snippet read.cpp exml_sample_read_file + +The file naming is manage by @ref etk::FSNode that provide "DATA:" start string for internal application asset. You can use external path like "./plop/file.xml" too. + + +Read an XML Stream {#exml_tutorial_read_stream} +================== + +Reading a stream is done like this: +@snippet read.cpp exml_sample_read_stream1 + +In C and C++ it is very hard to read string with the \\" then to simplify parsing of xml the parser engine support the use of simple ' interface: +@snippet read.cpp exml_sample_read_stream2 + + +Access at all Element datas {#exml_tutorial_read_folow} +=========================== + +In an exml::Element (or exml::Document) the sub-nodes are accessible threw an abstraction class stores in an element name **nodes** + +Get a node with its name: +@snippet read.cpp exml_sample_read_get_node + +Reading all file nodes: +@snippet read.cpp exml_sample_read_folow_nodes + +**note:** the itElem is a simple exml::Node that can be all the xml type. you can change the type by calling: toDocument(), toElement(), toString() ... + +In a C style mode: +@snippet read.cpp exml_sample_read_folow_nodes_c + + + +In an exml::Element (or exml::Document or exml::Declaration) the sub-nodes are accessible threw an abstraction class stores in an element name **attributes** + +Reading all Attributes of one node: +@snippet read.cpp exml_sample_read_folow_attributes + +In a C style mode: +@snippet read.cpp exml_sample_read_folow_attributes_c + +Get an attribute data: +@snippet read.cpp exml_sample_read_get_direct_attribute + + + + +In an exml::Element (or exml::Document) the internal data text can be accessible threw the interface: + +Get all the data in an element in text mode: +@snippet read.cpp exml_sample_read_get_all_under_string + + + +All example file {#exml_tutorial_read_all} +================ + +@snippet read.cpp exml_sample_read_all + diff --git a/doc/write.md b/doc/write.md new file mode 100644 index 0000000..4c82b14 --- /dev/null +++ b/doc/write.md @@ -0,0 +1,61 @@ +Write an XML content {#exml_tutorial_write} +==================== + +@tableofcontents + +The first thing to do when reading or writing a XML file/stream, is to declare the Document interface + +Include exml +@snippet read.cpp exml_sample_include + +Declare document interface +@snippet read.cpp exml_sample_declare_doc + + +Write an XML file {#exml_tutorial_write_file} +================= + +Write an xml tree is done like: +@snippet write.cpp exml_sample_write_file + + +Write an XML Stream {#exml_tutorial_write_stream} +=================== + +Writing a stream is done like this: +@snippet write.cpp exml_sample_write_stream + +Operation on Tree {#exml_tutorial_write_operation} +================= + +Add Node/Declaration: +@snippet write.cpp exml_sample_write_add_declaration + +Add an Node/Element: +@snippet write.cpp exml_sample_write_add_element + +Remove a Node/Element: +@snippet write.cpp exml_sample_write_rm_node + + +Add an attribute (simple version): +@snippet write.cpp exml_sample_write_add_attribute_simple + +Add an attribute (complex version): +@snippet write.cpp exml_sample_write_add_attribute_complex + +Remove an attribute: +@snippet write.cpp exml_sample_write_rm_attribute + +Object concept {#exml_tutorial_concept} +============== + +the exml concept is to abstract the implementation of the internal system. All the element are maped on shared memory. +Then if you asign an element to an other, it is the same. You need to clone it if you want to have new standalone element. + + +All example file {#exml_tutorial_write_all} +================ + +@snippet write.cpp exml_sample_write_all + diff --git a/egami/egami.cpp b/egami/egami.cpp index 69743de..6b5256d 100644 --- a/egami/egami.cpp +++ b/egami/egami.cpp @@ -173,7 +173,7 @@ bool egami::generateDistanceFieldFile(const std::string& _input, const std::stri if (data.exist() == false) { return false; } - // Generate distance field : + // Generate distance field: egami::ImageMono input; /* input.resize(data.getSize()); diff --git a/lutin_egami-sample.py b/lutin_egami-sample.py new file mode 100644 index 0000000..9daa77a --- /dev/null +++ b/lutin_egami-sample.py @@ -0,0 +1,45 @@ +#!/usr/bin/python +import lutin.module as module +import lutin.tools as tools + + +def get_type(): + return "BINARY" + +def get_sub_type(): + return "TEST" + +def get_desc(): + return "Test software for egami" + +def get_licence(): + return "APACHE-2" + +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def create(target, module_name): + my_module = module.Module(__file__, module_name, get_type()) + my_module.add_module_depend(['egami', 'test-debug']) + my_module.add_src_file([ + 'test/main.cpp', + 'test/read.cpp', + 'test/write.cpp' + ]) + my_module.copy_path('sample/read.bmp') + my_module.copy_path('sample/read.svg') + my_module.copy_path('sample/read.png') + return my_module + + + + + + + diff --git a/sample/main.cpp b/sample/main.cpp new file mode 100644 index 0000000..e535cd9 --- /dev/null +++ b/sample/main.cpp @@ -0,0 +1,32 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include "read.h" +#include "write.h" + +int main(int argc, const char *argv[]) { + // the only one init for etk: + etk::init(argc, argv); + for (int32_t iii=0; iii +//! [egami_sample_include] +#include +//! [egami_sample_include] +#include "read.h" + + +static void readBMP() { + //! [egami_sample_declare_image] + // create an empty Image (no type and no inside data) + egami::Image image; + //! [egami_sample_declare_image] + //! [egami_sample_read_file_bmp] + image = egami::load("DATA:read.bmp"); + //! [egami_sample_read_file_bmp] + TEST_INFO("image exist (BMP): " << image.exist()); +} + +static void readSVG() { + //! [egami_sample_read_file_svg] + egami::Image image = egami::load("DATA:read.svg"); + //! [egami_sample_read_file_svg] + TEST_INFO("image exist (SVG): " << image.exist()); + //! [egami_sample_read_file_svg_rescale] + image = egami::load("DATA:read.svg", ivec(800,600)); + //! [egami_sample_read_file_svg_rescale] + TEST_INFO("image exist (SVG-rescale): " << image.exist()); + //! [egami_sample_read_file_svg_scale_factor] + image = egami::load("DATA:read.svg", 0.5); + //! [egami_sample_read_file_svg_scale_factor] + TEST_INFO("image exist (SVG-scale): " << image.exist()); +} + +static void readPNG() { + //! [egami_sample_read_file_png] + egami::Image image = egami::load("DATA:read.png"); + //! [egami_sample_read_file_png] + TEST_INFO("image exist (PNG): " << image.exist()); +} + + +void appl::read() { + readBMP(); + readSVG(); + readPNG(); +} +//! [egami_sample_read_all] \ No newline at end of file diff --git a/sample/read.h b/sample/read.h new file mode 100644 index 0000000..5c677ff --- /dev/null +++ b/sample/read.h @@ -0,0 +1,11 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ + +#pragma once + +namespace appl { + void read(); +} diff --git a/sample/read.xml b/sample/read.xml new file mode 100644 index 0000000..83d3c1e --- /dev/null +++ b/sample/read.xml @@ -0,0 +1,8 @@ + + + + coucou + + + + \ No newline at end of file diff --git a/sample/write.cpp b/sample/write.cpp new file mode 100644 index 0000000..896f37b --- /dev/null +++ b/sample/write.cpp @@ -0,0 +1,44 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ + +//! [egami_sample_write_all] +#include +#include +#include "write.h" + + +static void writeBMP() { + //! [egami_sample_create_image] + // create an empty Image (no type and no inside data) + egami::Image image(ivec2(25,25)); + image.set(ivec2(5,5), etk::Color<>(0x88, 0xFF, 0x00, 0xFF); + image.set(ivec2(12,15), etk::Color<>(0x88, 0xFF, 0x00, 0xFF); + image.set(ivec2(4,9), etk::Color<>(0x88, 0xFF, 0x00, 0xFF); + // ... + //! [egami_sample_create_image] + //! [egami_sample_write_file_bmp] + bool ret = egami::store(image, "DATA:read.bmp"); + //! [egami_sample_write_file_bmp] + TEST_INFO("image write (BMP): " << ret); +} + +static void writeSVG() { + TEST_INFO("image write (SVG): Not Avaliiable"); +} + +static void writePNG() { + TEST_INFO("image write (PNG): Not Avaliiable"); +} + + +void appl::write() { + writeBMP(); + writeSVG(); + writePNG(); +} +//! [egami_sample_write_all] + + diff --git a/sample/write.h b/sample/write.h new file mode 100644 index 0000000..daba8bd --- /dev/null +++ b/sample/write.h @@ -0,0 +1,12 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2016, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ + +#pragma once + +namespace appl { + void write(); +} +