eXtremeDB XML[通俗易懂]

eXtremeDB XML[通俗易懂]ForC/C++applicationstheeXtremeDBschemacompileroption“–x”causes mcocomptogenerateinterfacefunctionstoretrieve,createandreplace(update) thecontentsofanobjectwiththecontent

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用
For C/C++ applications the eXtremeDB schema compiler option “–x” causes 

mcocomp to generate interface functions to retrieve, create and replace (update) 

the contents of an object with the content of an XML string. In addition to the 

common use of XML interfaces for porting data, these XML interface functions 

can be used, for instance, in concert with the eXtremeDB event notifications, to 

cause live data to be shared between eXtremeDB and other systems when an 

object of interest changes in the database.

The XML interfaces can also be used to facilitate simple schema evolution by 

exporting the database to XML, adding/dropping fields, indexes, and classes, and 

importing the saved XML into the new database.

XML export and import

The XML export and import functions are used in conjunction with user-defined 

file I/O helper functions to stream eXtremeDB database contents to and from 

persistent media files: 

MCO_RET mco_db_xml_export(mco_trans_h t, 

void* stream_handle, 

mco_stream_write output_stream_writer);

MCO_RET mco_db_xml_import(mco_trans_h t, 

void* stream_handle, 

mco_stream_read input_stream_reader);

When mco_db_xml_export() is called the internal runtime implementation calls 

the user-defined handler output_stream_writer to manage the output stream. 

And likewise mco_db_xml_import() causes the handler input_stream_reader

to be called. Simple file I/O handlers look like the following:

mco_size_sig_t file_writer(void* stream_handle /* FILE* */, 

const void* from, mco_size_t nbytes)

{

return (mco_size_t) fwrite(from, 1, nbytes, (FILE*) stream_handle);

}

mco_size_sig_t file_reader(void* stream_handle /* FILE* */, 

void* to, mco_size_t max_nbytes)

{

return (mco_size_t) fread(to, 1, max_nbytes, (FILE*) stream_handle);

}

Chapter 13 : eXtremeDB XML Interfaces

264    eXtremeDB User’s Guide

Function mco_db_xml_export() may be called within a READ_ONLY transaction 

but, as expected,  mco_db_xml_import() must be called within a READ_WRITE 

transaction. When importing data into an existing database, new data will be 

added into the database and no existing data will be lost.

mco_db_xml_import()calls the internal function mco_w_xml_create_object()

to create a new object in the database for each object loaded from the XML 

stream. Since the import procedure runs in the context of single transaction, there 

are only two possible results: either the whole data set will be imported 

successfully or no data will be imported. For example, if an object being imported 

creates a duplicate for any unique index, the entire transaction will be rolled back. 

It is necessary to explain how eXtremeDB handles unique identifiers, i.e. fields of 

the types oid, autoid and autooid. As explained above, the import procedure 

only creates new objects and never updates existing objects. So if a class contains 

an oid field, the oid value from the XML stream is used in the newly created 

object. Care must be taken to assure that imported oid values do not duplicate 

values in existing database objects.

In the case of “automatic id” fields of type autoid and autooid, the import 

procedure behaves according to the current XML policy settings. The policy 

switches ignore_autoid and ignore_autooid, when set to value MCO_YES,

cause the procedure to ignore values for fields of this type in the XML stream and 

mco_w_xml_create_object() will generate the id values for the newly created 

objects just as if they were created by calling the classname_new() function. 

The default setting of the XML policy is MCO_YES for both switches as the safest 

setting to preserve database integrity

Policies:

typedef struct mco_xml_policy_t_ 
{

MCO_NUM_BASE int_base;
MCO_NUM_BASE quad_base;
MCO_TEXT_CODING text_coding;
MCO_TEXT_CODING blob_coding;
MCO_FLOAT_FORMAT float_format;
mco_bool indent; 
mco_bool ignore_field;  /* ignore field in xml that is not in 
* class */
mco_bool encode_spec;  /* encode chars with code < 32, except LF */
mco_bool encode_lf;  /* encode line feeds */
mco_bool encode_nat;  /* encode national chars (code > 127) */
mco_bool truncate_sp;  /* truncate trailing spaces in chars */
mco_bool use_xml_attrs; /* alternative XML representation, using */
/* attributes */
mco_bool ignore_autoid;  /* ignore autoid value in create operations */
mco_bool ignore_autooid; /* ignore auto_oid in create operations  */

mco_xml_policy_t;

The policy default values are set as follows:
static mco_xml_policy_t default_xml_policy = { 
MCO_NUM_DEC,  /* int_base is decimal */
MCO_NUM_HEX,  /* quad_base is hexadecimal   */
MCO_TEXT_ASCII,  /* text_coding (strings) are ASCII */
MCO_TEXT_BASE64,  /* blob_coding is Base64 */
MCO_FLOAT_EXPONENT, /* float_format is exponential */
MCO_YES,  /* text is indented */
MCO_NO,  /* all fields must be present in */
/* the incoming XML */
MCO_YES,  /* encode special chars (< 32) */
MCO_YES,  /* encode line feeds */
MCO_NO,   /* encode national chars (> 127) */
MCO_YES  /* truncate trailing spaces */
MCO_NO,  /* don’t use attributes */
MCO_YES,  /* ignore autoid values in input */
MCO_YES    /* ignore autooid values in input */
};

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/182063.html原文链接:https://javaforall.net

(0)
上一篇 2022年10月14日 下午3:00
下一篇 2022年10月14日 下午3:16


相关推荐

  • ft232芯片怎么样_引脚悬空是什么电平

    ft232芯片怎么样_引脚悬空是什么电平概述:FF4232H芯片一款专门用于USB到RS232/RS485/RS422之间的电平转换芯片,数据收发和协议转换工作全由芯片独立完成,无需人工干预,不用编写芯片的固件,给设计者带来了极大的便利。利用该芯片只需要加少量的外围电路就可以实现相应的转换。FT4232H采用64-LDLeadFreeLQFPorQFN封装工艺。一、FT4232H功能和特性1、单芯片到4路串口的转换,整个接口协…

    2022年8月10日
    7
  • PowerMockito实战

    PowerMockito实战单元测试一 依赖 powermock 相关依赖 dependency groupId org powermock groupId artifactId powermock module junit4 artifactId version 1 7 4 version scope test scope dependency

    2025年8月4日
    4
  • 天谕最炫民族风曲谱_最炫民族风萨克斯五线谱

    天谕最炫民族风曲谱_最炫民族风萨克斯五线谱天谕手游最炫民族风乐谱代码是什么?《最炫民族风》是凤凰传奇演唱的一首流行歌曲,由张超作词和谱曲,发行于2009年5月27日,是其第三张专辑《最炫民族风》的主打歌。接下来小编为大家带来了天谕手游最炫民族风乐谱代码分享,希望可以帮助到大家。最炫民族风【音轨1】l8r1r1r1r1r1r1r1r1r1r1v>d1&d2&dv15bb1&b2v15f+v15f+2.&…

    2026年2月19日
    6
  • linux目录结构详解_文件系统目录结构采用

    linux目录结构详解_文件系统目录结构采用前言平常linux系统用的也不少,那么linux下的每个目录都是用来干什么的,小伙伴们有仔细研究过吗?让我们来了解下吧Linux系统目录结构登录系统后,在当前命令窗口下输入命令:[root@

    2022年7月31日
    7
  • stress加压

    stress加压安装 stress 模拟 linux 系统资源消耗 1 安装 yum 源 yuminstallep release y2 安装 stress yuminstallst y3 使用样例 stress c1 t604 测试场景举例 1 测试 CPU 负荷输入命令 stress c4 增加 4 个 cpu 进程 处理 sqrt 函数函数 以提高系统 CPU 负荷 2 内存测试输入命令 stress i4 vm10 vm bytes1G vm hang100 ti

    2026年3月16日
    1
  • win10php环境配置教程,win10php环境搭建详细教程

    win10php环境配置教程,win10php环境搭建详细教程大家在将系统更新为Win10系统后,对php环境搭建方法并不是很清楚。那么win10php环境搭建要怎么操作呢?其实win10php环境搭建的方法跟Win7/Win8.1系统的php环境搭建是相同道理的。如果还不懂win10php环境搭建的话,就看看小编带来的win10php环境搭建详细教程吧!首先,到微软官网下载符合系统位数的Apache和PHP一、安装并配置ApacheApache版本:Apa…

    2022年6月16日
    33

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号