![]() |
赤紫蘇2.リファレンス |
||
|
aka:choice binderクラス |
|||
| akaxiso2.0-beta2 | |||
|
|
|||
binderクラスは、aka:choiceの実体であるコンテナを操作するためのヘルパクラスです。 binderクラスは、aka:choiceのleafクラスの関連型として定義されています。 template<class T, class L> struct aka::sequential_choice<T, L>::binder; template<class T, class L> struct aka::associative_choice<T, L>::binder; aka::sequential_choice<>::binderクラスには、push_back()メソッドが定義されています。push_back()メソッドには、要素オブジェクトとタグ名を指定します。与えられたタグ名が、aka:choiceのleafクラスにて定義されていない場合には、例外(aka::errorクラス)を投げます。 使用例を以下にあげます。 // aka:choiceクラスの定義
typedef std::list<aka::item> items;
struct items_leaf : aka::sequential_choice<items, items_leaf> {
void model() {
item("item1", xiso::leaf<std::string>);
}
};
//使用例
void func_foo() {
.....
items container;
items_leaf::binder(container) items_binder;
std::string item("test");
items_binder.push_back(item, "item1");
.....
}
以上のコードで、タグ名"item1"と、itemインスタンスのコピーが対応付けられ、aka::itemのインスタンスが作成されます。その後、作成されたaka::itemインスタンスが、コンテナ(container)へと挿入されます。 aka::associative_choice<>::binderクラスには、insert()メソッドが定義されています。これも、上記と同様の使用法となります。 |
|||
