2012-05-30 00:19:22 +02:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
|
|
(c) 2012 Adrien Prokopowicz <prokopy@users.sourceforge.net>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
|
MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
|
#ifndef UTILS_H
|
|
|
|
|
#define UTILS_H
|
|
|
|
|
|
|
|
|
|
#include "main.h"
|
2012-11-22 12:40:57 +01:00
|
|
|
|
#include <stdlib.h>
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
|
|
|
|
|
|
typedef unsigned int uint;
|
|
|
|
|
|
|
|
|
|
#define DELETE(_ob) if(_ob) {delete _ob; _ob = 0;}
|
|
|
|
|
#define UNREF(_ob) if(_ob) GB.Unref(POINTER(&(_ob)))
|
|
|
|
|
|
|
|
|
|
#define SCHAR_N 0xA // \n
|
|
|
|
|
#define SCHAR_R 0xD // \r
|
|
|
|
|
|
|
|
|
|
#define CHAR_STARTTAG 0x3C // <
|
|
|
|
|
#define CHAR_ENDTAG 0x3E // >
|
|
|
|
|
|
|
|
|
|
#define CHAR_SINGLEQUOTE 0x27 // '
|
|
|
|
|
#define CHAR_DOUBLEQUOTE 0x22 // "
|
|
|
|
|
|
|
|
|
|
#define CHAR_SLASH 0x2F
|
|
|
|
|
#define CHAR_BACKSLASH 0x5C
|
|
|
|
|
#define CHAR_EQUAL 0x3D // =
|
|
|
|
|
#define CHAR_AND 0x26 // &
|
|
|
|
|
#define CHAR_PI 0x3F // ?
|
|
|
|
|
#define CHAR_EXCL 0x21 // !
|
|
|
|
|
#define CHAR_DASH 0x2D // -
|
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
|
#define CHAR_SPACE 0x20
|
|
|
|
|
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
|
#define CHAR_a 0x61 // a
|
|
|
|
|
#define CHAR_z 0x7A // z
|
|
|
|
|
|
|
|
|
|
#define CHAR_ERROR 0xFFFD // <20>
|
|
|
|
|
|
2012-07-31 20:24:47 +02:00
|
|
|
|
#ifdef OS_MACOSX
|
|
|
|
|
#include <string.h>
|
|
|
|
|
void *memrchr(const void *s, int c, size_t n);
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-07-19 00:43:35 +02:00
|
|
|
|
wchar_t nextUTF8Char(const char *&data, size_t len);
|
2012-05-30 00:19:22 +02:00
|
|
|
|
const void* memchrs(const char *source, size_t lensource, const char *comp, size_t lencomp);
|
|
|
|
|
const void* memrchrs(const void *source, size_t lensource, const void *comp, size_t lencomp);
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
|
|
|
|
|
|
|
2012-07-17 13:36:30 +02:00
|
|
|
|
bool isNameStartChar(const wchar_t car);
|
|
|
|
|
bool isNameChar(const wchar_t car);
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
|
bool isWhiteSpace(const wchar_t s);
|
|
|
|
|
bool isWhiteSpace(const char s);
|
|
|
|
|
|
2012-08-10 11:53:13 +02:00
|
|
|
|
void Trim(const char* &str, size_t &len);
|
2012-06-15 03:33:48 +02:00
|
|
|
|
void insertString(char *&src, size_t &lenSrc, const char *insert, size_t lenInsert, char *&posInsert);
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
|
|
2012-06-05 23:17:45 +02:00
|
|
|
|
#include <exception>
|
|
|
|
|
|
|
|
|
|
class XMLParseException : public exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
XMLParseException(const char* nerror, const char *text, const size_t lenText, const char *posFailed) throw();
|
2013-02-25 01:55:30 +01:00
|
|
|
|
XMLParseException(const char* nerror, size_t posFailed) throw();
|
2012-06-05 23:17:45 +02:00
|
|
|
|
virtual ~XMLParseException() throw();
|
|
|
|
|
|
|
|
|
|
virtual const char* what() const throw();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void AnalyzeText(const char *text, const size_t lenText, const char *posFailed) throw();
|
|
|
|
|
|
|
|
|
|
char *near;
|
|
|
|
|
char *error;
|
|
|
|
|
size_t lenError;
|
|
|
|
|
size_t lenNear;
|
|
|
|
|
size_t line;
|
|
|
|
|
size_t column;
|
|
|
|
|
|
|
|
|
|
char *errorWhat;
|
|
|
|
|
};
|
|
|
|
|
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
|
|
|
|
|
|
#endif // UTILS_H
|