20 #include "SheafSystem/arg_list.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/error_message.h" 24 #include "SheafSystem/namespace_poset.h" 25 #include "SheafSystem/poset_dof_iterator.h" 26 #include "SheafSystem/poset_path.h" 27 #include "SheafSystem/primitive_attributes.h" 28 #include "SheafSystem/schema_poset_member.h" 29 #include "SheafSystem/std_iostream.h" 30 #include "SheafSystem/std_string.h" 31 #include "SheafSystem/std_cstring.h" 33 #include "SheafSystem/block.impl.h" 43 _parse_state(GET_NAME)
59 : _args(xinput._args),
60 _parse_state(xinput._parse_state)
79 _parse_state(GET_NAME)
98 ensure(!xarg.
empty() ?
back() == xarg :
true);
108 _parse_state(GET_NAME)
128 ensure(
empty() == (strlen(xarg_name) == 0));
153 bool result = _args.ct() == 0;
157 ensure( result == (
ct() == 0));
168 index(
const std::string& xname)
const 174 require(!xname.empty());
179 for(
int i=0; i<_args.ct(); ++i)
181 if(_args[i].
name == xname)
190 ensure((-1 <= result) && (result < static_cast<int>(
ct())));
209 const string& result = _args[xi].name;
231 int result = _args[xi].type();
244 type(
const std::string& xname)
const 249 require(!xname.empty());
254 int result =
arg(xname).
type();
316 require(!xname.empty());
334 value(
const std::string& xname)
const 339 require(!xname.empty());
390 _args.push_back(xother._args[i]);
414 if(xinput.
id() == C_STRING)
416 if(*xinput.
value().c_string_primitive ==
'\0')
418 _parse_state = ERROR;
419 post_fatal_error_message(
"Empty string given for argument name");
423 _args.push_back(
arg_type(xinput.
value().c_string_primitive));
424 _parse_state = GET_VALUE;
429 _parse_state = ERROR;
430 post_fatal_error_message(
"Found argument value when expecting argument name");
437 _args.back().value = xinput;
438 _parse_state = GET_NAME;
442 _parse_state = ERROR;
443 post_fatal_error_message(
"Unrecognized parse_state");
468 result = (_parse_state == GET_NAME);
492 result = (_parse_state == GET_VALUE);
516 result = (_parse_state == ERROR);
531 bool xuse_table_schema,
532 bool xauto_access)
const 546 result =
conforms_to(lschema, xuse_table_schema, xauto_access);
548 lschema.detach_from_state();
561 bool xuse_table_schema,
562 bool xauto_access)
const 584 if(!arg_conforms_to(ldof_itr->
item()))
621 bool xuse_table_schema,
622 bool xauto_access)
const 632 require(xschema_path.
conforms_to(xstd_schema_path, xauto_access));
642 lschema.detach_from_state();
657 bool xuse_table_schema,
658 bool xauto_access)
const 688 ldof_itr->put_anchor(xschema.
index());
689 ldof_itr->reset(
false);
695 while(!ldof_itr->is_done())
697 if(!arg_conforms_to(ldof_itr->item()))
707 result = ldof_itr->is_done();
711 ldof_itr->force_is_done();
736 _args.assign(lempty);
739 _parse_state = GET_NAME;
784 for(
int i=0; i<p.
ct(); ++i)
786 os << p._args[i] << endl;
814 if(larg.
name.empty())
818 p._args.push_back(larg);
838 os << p.
name <<
'\t';
869 getline(is, p.
name,
'\t');
871 if(is && !p.
name.empty())
879 is >> ltype >> lterm;
887 getline(is, lstr,
'\n');
896 post_fatal_error_message(
"Failed to parse arg_list.");
952 int lschema_type = xschema.
type();
955 result = ( (larg_id >= 0) && (lschema_type ==
type(larg_id)) );
957 #ifdef DIAGNOSTIC_OUTPUT 959 cout <<
" schema: " << xschema.
name()
960 <<
" " << xschema.
type();
966 cout <<
" arg: " <<
name(larg_id)
967 <<
" " <<
type(larg_id);
972 cout <<
" arg: not present";
975 cout <<
" conforms_to: " << boolalpha << result << noboolalpha << endl;
994 require((0 <= xi) && (xi <
ct()));
1016 require((0 <= xi) && (xi <
ct()));
1020 const arg_type& result = _args[xi];
1037 require(!xname.empty());
1046 return index(xname) >= 0;
1059 size_type lother_ct = xother._args.ct();
1061 for(
size_type i=0; ((i<lother_ct) && result); ++i)
1063 const arg_type& larg = xother._args[i];
1064 const string& lname = larg.
name;
1070 result = (
arg(lname) == larg);
1089 require(!xname.empty());
1094 int i =
index(xname);
1108 arg(
const std::string& xname)
const 1113 require(!xname.empty());
1118 int i =
index(xname);
1163 const arg_type& result = _args.back();
1184 define_old_variable(
int old_ct =
ct());
1186 _args.push_back(xarg);
1190 ensure(
ct() == old_ct + 1);
arg_list & operator+=(const arg_list &xother)
Append arg_list xother.
virtual void force_is_done()
Force the iterator to be done.
primitive_value value
The value of the argument.
arg_type & arg(int xi)
The xi-th arg.
int type(int xi) const
The type of the xi-th argument.
bool empty() const
True if and only if name is empty.
virtual void next()
Makes this the next member of the subset.
void clear()
Removes all arguments.
bool state_is_read_accessible(bool xauto_access) const
bool conforms_to(const schema_poset_member &xother) const
True if the dofs defined by this agree in type and in order with the dofs defined by xother...
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
schema_poset_member & item()
The current member of the iteration (mutable version).
arg_type & back()
The last arg.
bool contains_arg(const std::string &xname) const
True if and only if this contains an arg with name xname.
bool parsing_value() const
True if next token should be an argument value.
A path defined by a poset name and a member name separated by a forward slash ('/'). For example: "cell_definitions/triangle".
virtual bool is_done() const
True if iteration finished.
virtual void get_read_access() const
Get read access to the state associated with this.
const scoped_index & index() const
The index of the component state this handle is attached to.
The internal argument type.
virtual primitive_type type() const
The primitive type index of the dof defined by this.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
std::string name
The name of the argument.
A whitespace separated list of arguments. Insertion operaters are used to insert arguments into the l...
bool conforms_to(const poset_path &xother, bool xauto_access) const
True if the schema member this refers to conforms to the schema member xother refers to in the curren...
bool parsing_error() const
True if argument input has found an error.
std::string to_string() const
Converts this to a string (for stream insertion).
primitive_type
Type ids for sheaf primitives.
primitive_value & value(int xi)
The value of the xi-th argument.
bool contains_args(const arg_list &xother) const
True if and only if this contains all the args of xother.
virtual void detach_from_state()
Detach this handle from its state, if any.
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
bool empty() const
True if and only if there are no arguments in the list.
std::string name(pod_index_type xdof_id, bool xis_table_dof) const
The name of the table dof (xis_table_dof true) or row dof referred to by xdof_id in the schema define...
SHEAF_DLL_SPEC bool is_primitive_index(pod_index_type xindex)
True if xindex is a valid primitive index.
unsigned int ct() const
The number of arguments.
primitive_type type() const
The type of the argument.
bool conforms_to_extension(const namespace_poset &xns, const poset_path &xschema_path, const poset_path &xstd_schema_path, bool xuse_table_schema, bool xauto_access) const
True if the values in this conform to the table schema (xuse_table_schema true) or row schema (xuse_t...
bool from_string(const std::string &x)
Converts this from a string (from stream extraction); returns true if operation successful, false otherwise.
primitive_buffer_type & value()
The value of this.
bool member_exists(bool xauto_access) const
bool conforms_to(const namespace_poset &xns, const poset_path &xschema_path, bool xuse_table_schema, bool xauto_access) const
True if the values in this conform to the table schema (xuse_table_schema true) or row schema (xuse_t...
primitive_type & id()
Type id of the primitive type.
int index(const std::string &xname) const
The index of the argument with name xname.
SHEAF_DLL_SPEC std::istream & operator>>(std::istream &is, dof_tuple_type &xdt)
Extract dof_tuple_type xdt from istream& is.
Iterates in postorder over dofs of a schema member anchor. Attaches a handle of type schema_poset_mem...
virtual poset_dof_iterator * dof_iterator(bool xis_table_dofs, int xversion=CURRENT_MEMBER_VERSION) const
A postorder iterator over the table (xis_table_dofs == true) or row (xis_table_dofs == false) dofs de...
friend SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const arg_list &xf)
Insert arg_list p into ostream os.
primitive_type id() const
The id for the primitive type associated with this.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
void put_type(primitive_type xid)
Sets the type of the argument to xid.
bool parsing_name() const
True if next token should be an argument name.
Abstract object wrapper for an instance of a primitive type.
arg_list()
Default constructor.
virtual int ct(bool xreset=false)
The number of members of the iteration set, from the current member to the end, inclusive. If xreset, reset before computing the count.
void push_back(const arg_type &xarg)
const std::string & name(int xi) const
The name of the xi-th argument.
A client handle for a poset member which has been prepared for use as a schema.