| Top |
| typedef | XMQDoc |
| typedef | XMQNode |
| typedef | XMQParseState |
| typedef | XMQParseCallbacks |
| enum | XMQContentType |
| enum | XMQRenderFormat |
| enum | XMQFlagBits |
| enum | XMQColorName |
| struct | XMQReader |
| struct | XMQWriter |
| typedef | XMQOutputSettings |
| enum | XMQProceed |
| enum | XMQParseError |
| enum | XMQCoreType |
| typedef | XMQLineConfig |
bool (*XMQWrite) (void *writer_state,const char *start,const char *stop);
Any function implementing XMQWrite must handle stop == NULL.
XMQContentType xmqDetectContentType (const char *start,const char *stop);
Detect the content type xmq/xml/html/json by examining a few leading non-whitespace words/characters.
XMQParseCallbacks * xmqNewParseCallbacks ();
Allocate an empty XMQParseCallback structure. All callbacks are NULL and none will be called.
void
xmqFreeParseCallbacks (XMQParseCallbacks *cb);
Free the XMQParseCallback structure.
void xmqSetupParseCallbacksColorizeTokens (XMQParseCallbacks *state,XMQRenderFormat render_format);
Used to colorize xmq input, without building a parse tree.
void
xmqSetupParseCallbacksDebugTokens (XMQParseCallbacks *state);
Used to debug location, type of tokens.
void
xmqSetupParseCallbacksDebugContent (XMQParseCallbacks *state);
Used debug the decoded content.
bool xmqTokenizeBuffer (XMQParseState *state,const char *start,const char *stop);
XMQParseState * xmqNewParseState (XMQParseCallbacks *callbacks,XMQOutputSettings *settings);
Now prepare a parse state that is used to actually parse an xmq file. The print settings can be referenced from the callbacks for example when tokenizing.
void
xmqFreeParseState (XMQParseState *state);
Free the memory allocated for the state.
void xmqSetStateSourceName (XMQParseState *state,const char *source_name);
Set the source name to make error message more readable when parsing fails. The source name is often the file name, but can be "-" for stdin or anything you like.
int
xmqStateErrno (XMQParseState *state);
If the parse fails then use this function to get the integer value of XMQParseError.
const char *
xmqStateErrorMsg (XMQParseState *state);
If the parse fails then use this function to get a string explaining the error.
void xmqSetPrintAllParsesIXML (XMQParseState *state,bool all_parses);
If the parse is ambiguous generate all possible trees.
void xmqSetTryToRecoverIXML (XMQParseState *state,bool try_recover);
If the parse fails then try to recover. Default is to fail.
void xmqSetDocSourceName (XMQDoc *doq,const char *source_name);
Set the source name to make error message more readable when parsing fails. The source name is often the file name, but can be "-" for stdin or anything you like.
const char *
xmqGetDocSourceName (XMQDoc *doq);
Returns the source name used to make error message more readable when parsing fails. The source name is often the file name, but can be "-" for stdin or anything you like.
XMQContentType
xmqGetOriginalContentType (XMQDoc *doq);
If available, return the original content type (xmq/htmq/xml/html/json/text) of this document.
size_t
xmqGetOriginalSize (XMQDoc *doq);
If available, return the size of the original content, ie the loaded file size.
void xmqSetOriginalSize (XMQDoc *doq,size_t size);
Override the original size of the document.
void *
xmqGetImplementationDoc (XMQDoc *doq);
Get the underlying implementation doc, could be an xmlDocPtr from libxml2 for example.
void xmqSetImplementationDoc (XMQDoc *doq,void *doc);
Set the underlying implementation doc, could be an xmlDocPtr from libxml2 for example.
bool xmqParseFile (XMQDoc *doc,const char *file,const char *implicit_root,int flags);
Parse a file, or if file is NULL, read from stdin.
bool xmqParseBuffer (XMQDoc *doc,const char *start,const char *stop,const char *implicit_root,int flags);
Parse a buffer or a file and create a document. The xmq format permits multiple root nodes if an implicit root is supplied.
bool xmqParseReader (XMQDoc *doc,XMQReader *reader,const char *implicit_root,int flags);
Parse data fetched with a reader and create a document. The xmq format permits multiple root nodes if an implicit root is supplied.
void xmqSetPreferDoubleQuotes (XMQOutputSettings *os,bool prefer_double_quotes);
void xmqSetOutputFormat (XMQOutputSettings *os,XMQContentType output_format);
const char * xmqGetStringRel (XMQDoc *doc,const char *xpath,XMQNode *relative);
int xmqForeachRel (XMQDoc *doq,const char *xpath,XMQNodeCallback cb,void *user_data,XMQNode *relative);
int xmqReplaceEntityWithNode (XMQDoc *doq,const char *entity,XMQDoc *idoq,XMQNode *inode);
void
xmqLogFilter (const char *log_filter);
Enable/Disable debug/trace logging for certain prefixes.
void
xmqSetLogHumanReadable (bool e);
Enable/Disable verbose/debug/tracing output as human readable. The default is in xmq format.
bool xmqParseBufferWithType (XMQDoc *doc,const char *start,const char *stop,const char *implicit_root,XMQContentType ct,int flags);
Parse buffer.
bool xmqParseFileWithType (XMQDoc *doc,const char *file,const char *implicit_root,XMQContentType ct,int flags);
Load and parse file. If file is NULL read from stdin.
bool xmqParseBufferWithIXML (XMQDoc *doc,const char *start,const char *stop,XMQDoc *ixml_grammar,int flags);
Parse buffer using the supplied IXML grammar.
bool xmqParseFileWithIXML (XMQDoc *doc,const char *file,XMQDoc *ixml_grammar,int flags);
Load a file and parse it using the supplied IXML grammar. If file is NULL read from stdin.
void
xmqSetupDefaultColors (XMQOutputSettings *settings);
Set the default colors for settings based on the theme and background color.
void xmqOverrideSettings (XMQOutputSettings *settings,const char *indentation_space,const char *explicit_space,const char *explicit_tab,const char *explicit_cr,const char *explicit_nl);
void xmqRenderHtmlSettings (XMQOutputSettings *settings,const char *use_id,const char *use_class);
void xmqOverrideColor (XMQOutputSettings *settings,const char *render_style,XMQColorName cn,const char *pre,const char *post,const char *ns);
Change the color strings for the given color type. You have to run xmqSetupDefaultColors first.
char * xmqLineDoc (XMQLineConfig *lc,XMQDoc *doc);
Generate from the doc a compact single line xmq string containing no newlines at all, for logging.
char * xmqLinePrintf (XMQLineConfig *lc,const char *element_name,...);
Generate a compact single line xmq string containing no newlines at all, for logging.
The content is constructed from printf formatted strings:
xmqLinePrintf(&lc,
"car{",
"model=", "s", modelstring,
"id=", "d", idnumber,
"description=", "desc: s", multilinedescription,
"}");
Generates:
car{model=Volvo id=123 description=('desc: lines of'&10;'next line')}
typedef struct XMQNode XMQNode;
Structure referencing a node/attr in the xmq/xml/json document.
An opaque structure to maintain the parse state and the list of callbacks to be invoked when parsing xmq.
typedef struct XMQParseCallbacks XMQParseCallbacks;
Store your own parse callbacks into this structure and register your own callback structure with the XMQParseState. Then you will get your own callbacks when parsing xmq and using these callbacks you can implement your own document builder or token handler.
Specify the file/buffer content type.
The xmq output can be rendered as PLAIN, or for human consumption in TERMINAL, HTML, HTMQ, TEX or RAW.
If a 0 is provided as the flags to the parse functions, then it will parse using the these default settings: When loading xml/html: trim the whitespace from the input to generate the most likely desired xmq output. merge character entities When loading xmq/htmq: no trimming but merge character entities such as &10; and consecutive text quotes
If you load xml with XMQ_TRIM_NONE (--trim=none) there will be a lot of unnecessary whitespace stored in the xmq, like &32;	&10; etc. You can then view the xmq with XMQ_TRIM_HEURISTIC (--trim=heuristic) to drop the whitespace.
If you load xmq with --nomerge then character entities and separate text blocks will be kept as is. The --nomerge currently does not work for XML/HTML since libxml2 does not have a setting for merge.
|
Do not trim any whitespace. |
||
|
Remove leading/ending whitespace, but try to keep significant, remove incidental indentation. |
||
|
Trim exactly according to XML rules. Depends on your XSD,space:preserve and more and is COMPLICATED! |
||
|
Do not merge text and character entities. |
||
|
When ixml parse is ambiguous generate all parses. |
||
|
When ixml parse fails, try to recover. |
struct XMQReader {
void *reader_state;
size_t (*read)(void *reader_state, char *start, char *stop);
};
The xmq parser uses the reader to fetch data into a buffer (start <= i < stop). You can create your own reader with a function that takes a pointer to the reader state. Returns the number of bytes stored in buffer, maximum stored is stop-start.
struct XMQWriter {
void *writer_state;
XMQWrite write;
};
The xmq printer uses the writer to write data supplied from a buffer (start <= i < stop). You can create your own writer with a function that takes a pointer to the writer state. The writer function must return true if the writing was successful.
points to the writer state |
||
XMQWrite |
invoked with the writer state to store output data. Must accept stop == NULL which assumes start is null terminated. |
Possible parse errors.
|
file not found or cannot be opened for reading. |
||
|
out of memory. |
||
|
expected xmq but auto detect sees early that it is not xmq. |
||
|
an xmq quote is not closed, ie single quotes are missing. |
||
|
an entity is missing the semicolon. |
||
|
a comment has not been closed. |
||
|
a comment close is not balanced. |
||
|
an body is missing a closing brace. |
||
|
the attribute list is missing the closing parentheses. |
||
|
too many closing single quotes. |
||
|
an unexpected closing brace. |
||
|
tabs are not permitted as token separators. |
||
|
an invalid character found. |
||
|
the doctype could not be parsed. |
||
|
an invalid json escape sequence. |
||
|
an invalid character. |
||
|
x |
||
|
x |
||
|
x |
||
|
x |
||
|
x |
||
|
x |
||
|
x |
||
|
x |
||
|
Signed 8 bit integer. |
||
|
Signed 16 bit integer. |
||
|
Signed 32 bit integer. |
||
|
Signed 64 bit integer. |
||
|
Signed 128 bit integer. |
||
|
Unsigned 8 bit integer. |
||
|
Unsigned 16 bit integer. |
||
|
Unsigned 32 bit integer. |
||
|
Unsigned 64 bit integer. |
||
|
Unsigned 128 bit integer. |
||
|
Zero to infinite sized unicode string. No zero bytes. |
||
|
Either a v4 or a v6. |
||
|
128.0.0.1 |
||
|
::0 |