10#ifndef GUPI_hpp_included
11#define GUPI_hpp_included 1
27#define GUPI_documentationChars "documentation"
28#define GUPI_titleChars "title"
29#define GUPI_abstractChars "abstract"
30#define GUPI_bodyChars "body"
31#define GUPI_endfCompatibleChars "endfCompatible"
32#define GUPI_doiChars "doi"
33#define GUPI_publicationDateChars "publicationDate"
34#define GUPI_versionChars "version"
50 WriteInfo( std::string
const &a_incrementalIndent =
" ",
int a_valuesPerLine = 100, std::string
const &a_sep =
" " );
55 void addNodeStarter( std::string
const &indent, std::string
const &a_moniker, std::string
const &a_attributes =
"" ) {
56 m_lines.push_back( indent +
"<" + a_moniker + a_attributes +
">" ); }
57 void addNodeStarterEnder( std::string
const &indent, std::string
const &a_moniker, std::string
const &a_attributes =
"" ) {
58 m_lines.push_back( indent +
"<" + a_moniker + a_attributes +
"/>" ); }
60 std::string
addAttribute( std::string
const &a_name, std::string
const &a_value )
const {
return(
" " + a_name +
"=\"" + a_value +
"\"" ); }
62 std::string
nodeStarter( std::string
const &indent, std::string
const &a_moniker, std::string
const &a_attributes =
"" )
63 {
return( indent +
"<" + a_moniker + a_attributes +
">" ); }
64 std::string
nodeEnder( std::string
const &a_moniker ) {
return(
"</" + a_moniker +
">" ); }
83 static std::string
buildXLinkItemKey( std::string
const &a_name, std::string
const &a_key ) {
85 if( a_key.size( ) == 0 )
return(
"" );
86 return(
"[@" + a_name +
"='" + a_key +
"']" );
90 std::string m_moniker;
92 std::string m_attribute;
94 Ancestry *findInAncestry2( std::size_t a_index, std::vector<std::string>
const &a_segments );
95 Ancestry const *findInAncestry2( std::size_t a_index, std::vector<std::string>
const &a_segments )
const ;
98 Ancestry( std::string
const &a_moniker, std::string
const &a_attribute =
"" );
102 std::string
const &
moniker( )
const {
return( m_moniker ); }
103 void setMoniker( std::string
const &a_moniker ) { m_moniker = a_moniker; }
107 std::string
attribute( )
const {
return( m_attribute ); }
113 bool isRoot( )
const {
return( this->m_ancestor ==
nullptr ); }
131 virtual void toXMLList(
WriteInfo &a_writeInfo, std::string
const &a_indent =
"" )
const ;
143 std::string m_keyName;
144 std::string m_keyValue;
147 Entry( std::string
const &a_moniker, std::string
const &a_keyName, std::string
const &a_keyValue );
151 std::string
const &
keyName( )
const {
return( m_keyName ); }
152 std::string
const &
keyValue( )
const {
return( m_keyValue ); }
159 if( m_keyValue ==
"" )
return(
"" );
195 std::string
const &
body( )
const {
return m_body; }
198 std::string
const &
label( )
const {
return m_label; }
214 std::string m_publicationDate;
215 std::string m_version;
226 std::string
const &
doi( )
const {
return m_doi; }
228 std::string
const &
version( )
const {
return m_version; }
250 std::string m_keyName;
252 std::map<std::string,std::size_t> m_map;
254 Suite( Suite
const *a_suite );
257 Suite( std::string
const &a_keyName );
258 Suite( std::string
const &a_moniker, std::string
const &a_keyName );
262 std::string
const &
keyName( )
const {
return( m_keyName ); }
263 std::size_t
size( )
const {
return( m_entries.size( ) ); }
265 std::size_t
operator[]( std::string
const &a_label )
const ;
273 template<
typename T> T *
get( std::size_t a_Index );
274 template<
typename T> T
const *
get( std::size_t a_Index )
const ;
275 template<
typename T> T *
get( std::string
const &a_label );
276 template<
typename T> T
const *
get( std::string
const &a_label )
const ;
282 bool has( std::string
const &a_label )
const {
return(
find( a_label ) != m_entries.end( ) ); }
287 std::vector<const_iterator>
findAllOfMoniker( std::string
const &a_moniker )
const ;
303 Entry *entry = m_entries[a_index];
304 T *
object =
dynamic_cast<T *
>( entry );
306 if(
object ==
nullptr )
throw LUPI::Exception(
"GIDI::Suite::get( std::size_t ): invalid cast" );
319template<
typename T> T
const *
Suite::get( std::size_t a_index )
const {
321 Entry *entry = m_entries[a_index];
322 T *
object =
dynamic_cast<T *
>( entry );
324 if(
object ==
nullptr )
throw LUPI::Exception(
"GIDI::Suite::get( std::size_t ): invalid cast" );
337template<
typename T> T *
Suite::get( std::string
const &a_label ) {
339 auto index = (*this)[a_label];
340 Entry *entry = m_entries[index];
341 T *
object =
dynamic_cast<T *
>( entry );
343 if(
object ==
nullptr )
throw LUPI::Exception(
"GIDI::Suite::get( std::string const & ): invalid cast" );
356template<
typename T> T
const *
Suite::get( std::string
const &a_label )
const {
358 auto index = (*this)[a_label];
359 Entry *entry = m_entries[index];
360 T *
object =
dynamic_cast<T *
>( entry );
362 if(
object ==
nullptr )
throw LUPI::Exception(
"GIDI::Suite::get( std::string const & ): invalid cast" );
void setMoniker(std::string const &a_moniker)
virtual Ancestry * findInAncestry3(std::string const &a_item)=0
Ancestry * findInAncestry(std::string const &a_href)
Ancestry & operator=(Ancestry const &a_ancestry)
virtual Ancestry const * findInAncestry3(std::string const &a_item) const =0
static std::string buildXLinkItemKey(std::string const &a_name, std::string const &a_key)
void setAncestor(Ancestry *a_ancestor)
std::string const & moniker() const
virtual LUPI_HOST void serialize(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
Ancestry(std::string const &a_moniker, std::string const &a_attribute="")
std::string toXLink() const
Ancestry const * ancestor() const
bool isParent(Ancestry *a_parent)
bool isChild(Ancestry *a_instance)
virtual void toXMLList(WriteInfo &a_writeInfo, std::string const &a_indent="") const
std::string attribute() const
virtual std::string xlinkItemKey() const
std::string const & doi() const
Text const & body() const
Ancestry const * findInAncestry3(LUPI_maybeUnused std::string const &a_item) const
std::string const & publicationDate() const
Documentation(HAPI::Node const &a_node)
Text const & abstract() const
std::string const & version() const
Text const & title() const
Ancestry * findInAncestry3(LUPI_maybeUnused std::string const &a_item)
LUPI_HOST void serialize(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
Ancestry * findInAncestry3(LUPI_maybeUnused std::string const &a_item)
std::string xlinkItemKey() const
std::string const & keyValue() const
Ancestry const * findInAncestry3(LUPI_maybeUnused std::string const &a_item) const
std::string const & keyName() const
Entry(std::string const &a_moniker, std::string const &a_keyName, std::string const &a_keyValue)
T * get(std::size_t a_Index)
Entries::iterator iterator
T const * get(std::string const &a_label) const
std::vector< Entry * > Entries
std::string const & keyName() const
const_iterator begin() const
T const * get(std::size_t a_Index) const
void printEntryLabels(std::string const &a_header) const
void toXMLList(WriteInfo &a_writeInfo, std::string const &a_indent="") const
const_iterator end() const
iterator find(std::string const &a_label)
std::vector< iterator > findAllOfMoniker(std::string const &a_moniker)
bool has(std::string const &a_label) const
Entries::const_iterator const_iterator
void parse(HAPI::Node const &a_node, GUPI_parseSuite a_parseSuite)
Ancestry * findInAncestry3(std::string const &a_item)
std::size_t operator[](std::string const &a_label) const
std::string const & body() const
Ancestry * findInAncestry3(LUPI_maybeUnused std::string const &a_item)
std::string const & label() const
Encoding encoding() const
Text(HAPI::Node const &a_node)
Ancestry const * findInAncestry3(LUPI_maybeUnused std::string const &a_item) const
std::string m_incrementalIndent
void addNodeStarterEnder(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
void push_back(std::string const &a_line)
std::list< std::string > m_lines
void addNodeEnder(std::string const &a_moniker)
std::string incrementalIndent(std::string const &indent)
WriteInfo(std::string const &a_incrementalIndent=" ", int a_valuesPerLine=100, std::string const &a_sep=" ")
void addNodeStarter(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
std::string nodeEnder(std::string const &a_moniker)
std::string nodeStarter(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
std::string addAttribute(std::string const &a_name, std::string const &a_value) const
Entry *(* GUPI_parseSuite)(Suite *a_parent, HAPI::Node const &a_node)