FieldBuilder: better method names
This commit is contained in:
@@ -716,29 +716,29 @@ UnionConstPtr FieldBuilder::createUnion()
|
||||
return field;
|
||||
}
|
||||
|
||||
FieldBuilderPtr FieldBuilder::addStructure(std::string const & name)
|
||||
FieldBuilderPtr FieldBuilder::addNestedStructure(std::string const & name)
|
||||
{
|
||||
return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, structure, false));
|
||||
}
|
||||
|
||||
|
||||
FieldBuilderPtr FieldBuilder::addUnion(std::string const & name)
|
||||
FieldBuilderPtr FieldBuilder::addNestedUnion(std::string const & name)
|
||||
{
|
||||
return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, union_, false));
|
||||
}
|
||||
|
||||
|
||||
FieldBuilderPtr FieldBuilder::addStructureArray(std::string const & name)
|
||||
FieldBuilderPtr FieldBuilder::addNestedStructureArray(std::string const & name)
|
||||
{
|
||||
return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, structure, true));
|
||||
}
|
||||
|
||||
FieldBuilderPtr FieldBuilder::addUnionArray(std::string const & name)
|
||||
FieldBuilderPtr FieldBuilder::addNestedUnionArray(std::string const & name)
|
||||
{
|
||||
return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, union_, true));
|
||||
}
|
||||
|
||||
FieldBuilderPtr FieldBuilder::createNested()
|
||||
FieldBuilderPtr FieldBuilder::addNested()
|
||||
{
|
||||
if (!parentBuilder.get())
|
||||
throw std::runtime_error("this method can only be called to create nested fields");
|
||||
|
||||
@@ -708,51 +708,51 @@ public:
|
||||
|
||||
/**
|
||||
* Add new nested {@code Structure}.
|
||||
* {@code createNested()} method must be called
|
||||
* {@code addNested()} method must be called
|
||||
* to complete creation of the nested {@code Structure}.
|
||||
* @param name nested structure name.
|
||||
* @return a new instance of a {@code FieldBuilder} is returned.
|
||||
* @see #createNested()
|
||||
* @see #addNested()
|
||||
*/
|
||||
FieldBuilderPtr addStructure(std::string const & name);
|
||||
FieldBuilderPtr addNestedStructure(std::string const & name);
|
||||
|
||||
/**
|
||||
* Add new nested {@code Union}.
|
||||
* {@code createNested()} method must be called
|
||||
* {@code addNested()} method must be called
|
||||
* to complete creation of the nested {@code Union}.
|
||||
* @param name nested union name.
|
||||
* @return a new instance of a {@code FieldBuilder} is returned.
|
||||
* @see #createNested()
|
||||
* @see #addNested()
|
||||
*/
|
||||
FieldBuilderPtr addUnion(std::string const & name);
|
||||
FieldBuilderPtr addNestedUnion(std::string const & name);
|
||||
|
||||
/**
|
||||
* Add new nested {@code Structure[]}.
|
||||
* {@code createNested()} method must be called
|
||||
* {@code addNested()} method must be called
|
||||
* to complete creation of the nested {@code Structure}.
|
||||
* @param name nested structure name.
|
||||
* @return a new instance of a {@code FieldBuilder} is returned.
|
||||
* @see #createNested()
|
||||
* @see #addNested()
|
||||
*/
|
||||
FieldBuilderPtr addStructureArray(std::string const & name);
|
||||
FieldBuilderPtr addNestedStructureArray(std::string const & name);
|
||||
|
||||
/**
|
||||
* Add new nested {@code Union[]}.
|
||||
* {@code createNested()} method must be called
|
||||
* {@code addNested()} method must be called
|
||||
* to complete creation of the nested {@code Union}.
|
||||
* @param name nested union name.
|
||||
* @return a new instance of a {@code FieldBuilder} is returned.
|
||||
* @see #createNested()
|
||||
* @see #addNested()
|
||||
*/
|
||||
FieldBuilderPtr addUnionArray(std::string const & name);
|
||||
FieldBuilderPtr addNestedUnionArray(std::string const & name);
|
||||
|
||||
/**
|
||||
* Complete the creation of a nested object.
|
||||
* @see #addStructure(String)
|
||||
* @see #addUnion(String)
|
||||
* @see #addNestedStructure(String)
|
||||
* @see #addNestedUnion(String)
|
||||
* @return a previous (parent) {@code FieldBuilder}.
|
||||
*/
|
||||
FieldBuilderPtr createNested();
|
||||
FieldBuilderPtr addNested();
|
||||
|
||||
private:
|
||||
FieldBuilder();
|
||||
|
||||
@@ -189,11 +189,11 @@ void testEquals() {
|
||||
UnionConstPtr punion = getFieldCreate()->createFieldBuilder()->
|
||||
add("double", pvDouble)->
|
||||
add("double2", pvDouble)->
|
||||
addStructureArray("nested")->
|
||||
addNestedStructureArray("nested")->
|
||||
setId("nestedId")->
|
||||
add("short", pvShort)->
|
||||
add("long", pvLong)->
|
||||
createNested()->
|
||||
addNested()->
|
||||
addArray("intArray", pvInt)->
|
||||
createUnion();
|
||||
PVUnionPtr union1 = factory->createPVUnion(punion);
|
||||
@@ -683,11 +683,11 @@ void testIntrospectionSerialization()
|
||||
// union
|
||||
UnionConstPtr punion = factory->createFieldBuilder()->
|
||||
add("double", pvDouble)->
|
||||
addStructureArray("nested")->
|
||||
addNestedStructureArray("nested")->
|
||||
setId("nestedId")->
|
||||
add("short", pvShort)->
|
||||
add("long", pvLong)->
|
||||
createNested()->
|
||||
addNested()->
|
||||
addArray("intArray", pvInt)->
|
||||
createUnion();
|
||||
serializatioTest(punion);
|
||||
|
||||
@@ -86,19 +86,19 @@ void test_invalid()
|
||||
{
|
||||
fieldCreate->createFieldBuilder()->
|
||||
add("f1", pvByte)->
|
||||
createNested();
|
||||
testFail("createNested() allowed in non-nested FieldBuilder");
|
||||
addNested();
|
||||
testFail("addNested() allowed in non-nested FieldBuilder");
|
||||
}
|
||||
catch (std::runtime_error& re) {
|
||||
// ok
|
||||
testPass("createNested() disallowed in non-nested FieldBuilder");
|
||||
testPass("addNested() disallowed in non-nested FieldBuilder");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
fieldCreate->createFieldBuilder()->
|
||||
add("f1", pvByte)->
|
||||
addStructure("nested")->
|
||||
addNestedStructure("nested")->
|
||||
add("n1", pvUInt)->
|
||||
createStructure();
|
||||
testFail("createStructure() allowed in nested FieldBuilder");
|
||||
@@ -119,11 +119,11 @@ void test_nestedStructure()
|
||||
std::string NESTED_ID = "nestedID";
|
||||
StructureConstPtr s = fieldCreate->createFieldBuilder()->
|
||||
add("double", pvDouble)->
|
||||
addStructure("nested")->
|
||||
addNestedStructure("nested")->
|
||||
setId(NESTED_ID)->
|
||||
add("short", pvShort)->
|
||||
add("long", pvLong)->
|
||||
createNested()->
|
||||
addNested()->
|
||||
addArray("intArray", pvInt)->
|
||||
createStructure();
|
||||
testOk1(s.get() != 0);
|
||||
@@ -175,11 +175,11 @@ void test_nestedStructureArray()
|
||||
std::string NESTED_ID = "nestedID";
|
||||
StructureConstPtr s = fieldCreate->createFieldBuilder()->
|
||||
add("double", pvDouble)->
|
||||
addStructureArray("nested")->
|
||||
addNestedStructureArray("nested")->
|
||||
setId(NESTED_ID)->
|
||||
add("short", pvShort)->
|
||||
add("long", pvLong)->
|
||||
createNested()->
|
||||
addNested()->
|
||||
addArray("intArray", pvInt)->
|
||||
createStructure();
|
||||
testOk1(s.get() != 0);
|
||||
|
||||
Reference in New Issue
Block a user