English 中文(简体)
C的变式数据型图书馆
原标题:Variant datatype library for C

Is there a decent open-source C library for storing and manipulating
dynamically-typed variables (a.k.a. variants)? I m primarily interested in atomic values (int8, int16, int32, uint, strings, blobs, etc.), while JSON-style arrays and objects as well as custom objects would also be nice. A major case where such a library would be useful is in working with SQL databases.

这样一个图书馆最明显的特征是所有支持价值观的单一类型,例如:

struct Variant {
    enum Type type;
    union {
        int8_t int8_;
        int16_t int16_;
        // ...
    };
};

其他特点可能包括将变式物体转换至/从C类结构(使用具有约束力的表格)、将价值转换到/从地貌以及并入现有的数据库图书馆,如Kalkite。

注:我不认为这是一个重复的问题:。 C中通用数据类型的任何图书馆:,指的是“频率、树木、地图、清单”。 我所谈论的内容更多地侧重于使数据库的工作与使用解释性语言的数据库的工作大致一样顺利。

问题回答

GLib has implementation of generic value types in form of GValue: http://library.gnome.org/devel/gobject/unstable/gobject-Generic-values.html

虽然我怀疑原始作者仍然回答(至少4年之后),但我想增加我的两点。

首先,请允许我指出,你要求的东西被称为一种总合型,通常以功能语言支持(即,这是一个语言设计特征,而不是一个图书馆问题)。

第二,令人非常怀疑的是,你会找到一个C-library案,原因很简单,任何这种图书馆都会支持一套可能不符合你需要的固定变量。

为了完整起见,您不妨请msg Pack/a>。

我建议在地理坐标数据库连接器上阅读该手册。 MySQL的链接器提供了在result上获取外地类型的信息。

您可创建Factory功能,填补基于外地类型的结构。 具有讽刺意味的是,由于C部有基地类型,你不得不使用<>代码>,避免*点,并改用已知的结构类型。 (通过<代码> 删除*/代码> 是你试图删除的类型)。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签