[DEV] start rework that does not work

This commit is contained in:
Edouard DUPIN 2016-07-13 22:27:54 +02:00
parent 4475968d31
commit 87316c738a
12 changed files with 485 additions and 1 deletions

66
doc/build.md Normal file
View File

@ -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
```

71
doc/mainpage.md Normal file
View File

@ -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
<http://www.apache.org/licenses/LICENSE-2.0>
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)

80
doc/read.md Normal file
View File

@ -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

61
doc/write.md Normal file
View File

@ -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

View File

@ -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());

45
lutin_egami-sample.py Normal file
View File

@ -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 <yui.heero@gmail.com>"]
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

32
sample/main.cpp Normal file
View File

@ -0,0 +1,32 @@
/** @file
* @author Edouard DUPIN
* @copyright 2016, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <test-debug/debug.h>
#include <etk/etk.h>
#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<argc ; ++iii) {
std::string data = argv[iii];
if ( data == "-h"
|| data == "--help") {
TEST_PRINT("Help : ");
TEST_PRINT(" ./xxx [options]");
TEST_PRINT(" -h/--help: this help");
exit(0);
}
}
TEST_INFO("read [START] ***************************");
appl::read();
TEST_INFO("read [STOP ] ***************************");
TEST_INFO("write [START] ***************************");
appl::write();
TEST_INFO("write [STOP ] ***************************");
return 0;
}

54
sample/read.cpp Normal file
View File

@ -0,0 +1,54 @@
/** @file
* @author Edouard DUPIN
* @copyright 2016, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
//! [egami_sample_read_all]
#include <test-debug/debug.h>
//! [egami_sample_include]
#include <egami/egami.h>
//! [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]

11
sample/read.h Normal file
View File

@ -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();
}

8
sample/read.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<!-- my comment -->
<exml attributeExample="my data attribute">
coucou
<!-- comment -->
<subNodeA/>
<subNodeB/>
</exml>

44
sample/write.cpp Normal file
View File

@ -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 <test-debug/debug.h>
#include <egami/egami.h>
#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]

12
sample/write.h Normal file
View File

@ -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();
}