27 m_moniker( a_moniker ),
28 m_ancestor( nullptr ),
29 m_attribute( a_attribute ) {
49 if(
this != &a_ancestry ) {
50 m_moniker = a_ancestry.
moniker( );
68 while( _root->m_ancestor !=
nullptr ) _root = _root->m_ancestor;
82 while( _root->m_ancestor !=
nullptr ) _root = _root->m_ancestor;
97 return( findInAncestry2( 0, segments ) );
111 return( findInAncestry2( 0, segments ) );
123Ancestry *Ancestry::findInAncestry2( std::size_t a_index, std::vector<std::string>
const &a_segments ) {
127 if( a_index == a_segments.size( ) )
return( item );
129 std::string segment( a_segments[a_index] );
131 if( segment ==
"" ) {
132 item = this->
root( );
134 if( a_segments[a_index] != item->
moniker( ) )
return(
nullptr ); }
135 else if( segment ==
"." ) {
137 else if( segment ==
".." ) {
143 if( item ==
nullptr )
return( item );
146 return( item->findInAncestry2( a_index, a_segments ) );
158Ancestry const *Ancestry::findInAncestry2( std::size_t a_index, std::vector<std::string>
const &a_segments )
const {
162 if( a_index == a_segments.size( ) )
return( item );
164 std::string segment( a_segments[a_index] );
166 if( segment ==
"" ) {
167 item = this->
root( );
169 if( a_segments[a_index] != item->moniker( ) )
return(
nullptr ); }
170 else if( segment ==
"." ) {
172 else if( segment ==
".." ) {
178 if( item ==
nullptr )
return( item );
181 return( item->findInAncestry2( a_index, a_segments ) );
209 if(
isRoot( ) )
return( xlink );
210 return( m_ancestor->toXLink( ) + xlink );
222 std::cout <<
"Node '" <<
moniker( ) <<
"' needs toXMLList methods." << std::endl;
235 std::ofstream fileio;
236 fileio.open(
"test.xml" );
237 for( std::list<std::string>::iterator iter = writeInfo.
m_lines.begin( ); iter != writeInfo.
m_lines.end( ); ++iter ) {
238 fileio << *iter << std::endl;
262 for(
auto line =
m_lines.begin( ); line !=
m_lines.end( ); ++line ) std::cout << *line << std::endl;
#define DATA_MEMBER_STD_STRING(member, buf, mode)
virtual Ancestry * findInAncestry3(std::string const &a_item)=0
Ancestry * findInAncestry(std::string const &a_href)
Ancestry & operator=(Ancestry const &a_ancestry)
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
virtual void toXMLList(WriteInfo &a_writeInfo, std::string const &a_indent="") const
std::string attribute() const
virtual std::string xlinkItemKey() const
std::string m_incrementalIndent
std::list< std::string > m_lines
WriteInfo(std::string const &a_incrementalIndent=" ", int a_valuesPerLine=100, std::string const &a_sep=" ")
std::vector< std::string > splitXLinkString(std::string const &a_string)