static_assert(std::is_same<PositionalParameter<typenamePar::ConverterType,Par::optional>,Par>::value,"ParsePositionalParameters argument(s) must be PositionalParameter");
// Check if parameter already initialised. This is code error.
if(param.Initialised())
{
err="Parameter "+param.Name()+" already initialised. This is code error.";
return;
}
// List is ended
if(i>=ol->Size())
{
// Parameter is optional, skip it
if(Par::optional)Parse(i,ol,args...);
// Parameter is required, this is an error
elseerr="Parameter "+param.Name()+" is required, but can't be setted because list is ended";
}
// Initialise from some list element
else
{
boolres=param.Init(ol->At(i),err);
// All Ok, continue to next element in list
if(res)Parse(i+1,ol,args...);
else
{
// All Ok, optional parameter may be absent, try to initialise next parameter by same list element
if(Par::optional)Parse(i,ol,args...);
// Error, required parameter not initialised
elseerr="Can't initialise parameter "+param.Name()+" from list element number "+ToString(i)+": "+err;
}
}
}
// Bottom of recursion
voidParse(ObjectList::IndexTypei,constObjectList*ol){if(i<ol->Size())err="There are excess elements in list";}
// ob - object from which we initialise parameter param.
// init - is ob was already used for initialise something.
// args - other parameters
// Function try to initialise parameter param, if param accepted real type of ob for initialisation, else function try to initialise next parameter in args.
// Function return error if initialisation of parameter failed or if two parameters can be initialised from ob.
static_assert(std::is_same<NamedParameter<typenamePar::ConverterType,Par::optional>,Par>::value||std::is_same<NamedFreeParameter<typenamePar::ConverterType,Par::optional,typenamePar::AcceptableObject>,Par>::value,"ParseNamedParameters argument(s) must be NamedParameter or NamedFreeParameter");
OBType<typenamePar::AcceptableObject>o(ob);
if(o&&init)
{
err="Object of type "+ob->Type()+" used for initialisation of two parameters. This is code error.";
returnfalse;
}
if(!o)returnParseSingle(ob,init,args...);// Type mismatch, goto next parameter
if(param.Initialised())
{
err="Parameter "+param.Name()+" can't be initialised from object of type "+ob->Type()+" because it already initialised.";
returnfalse;
}
std::stringierr;
if(!param.Init(ob,ierr))
{
err="Parameter "+param.Name()+" can't be initialised from object of type "+ob->Type()+": "+ierr;
static_assert(std::is_same<NamedParameter<typenamePar::ConverterType,Par::optional>,Par>::value||std::is_same<NamedFreeParameter<typenamePar::ConverterType,Par::optional,typenamePar::AcceptableObject>,Par>::value,"ParseNamedParameters argument(s) must be NamedParameter or NamedFreeParameter");
boolcmp=param.Compare(op->Name());
if(cmp&&!pname.empty())
{
err="Element "+op->Name()+" can be used for initialisation of two parameters: "+pname+" and "+param.Name();
returnfalse;
}
if(!cmp)returnParsePair(op,pname,args...);// Name mismatch, goto next parameter
pname=param.Name();
if(param.Initialised())
{
err="Parameter "+param.Name()+" can't be initialised from element "+op->Name()+" because it already initialised.";
returnfalse;
}
std::stringierr;
if(!param.Init(op->Value(),ierr))
{
err="Parameter "+param.Name()+" can't be initialised from element "+op->Name()+": "+ierr;