Click here to Skip to main content
15,886,019 members
Articles / High Performance Computing

HPC Template Library, A Supplement to the STL

Rate me:
Please Sign up or sign in to vote.
4.88/5 (11 votes)
15 Dec 2017MIT3 min read 38.1K   1.3K   39  
The HPC Template Library is a supplement to the Standard Template Library providing threadsafe containers.
/*
**	This file is part of the XMLStar.
**	This software was developed by:
**	
**  Anthony Daniels, Mi Yan
**	The University of Michigan
**	Department of Naval Architecture & Marine Engineering
**	Department of Computer Science
**
**  XMLStar is free software: you can redistribute it and/or modify
**  it under the terms of the GNU Lesser General Public License as published by
**  the Free Software Foundation, either version 3 of the License, or
**  (at your option) any later version.
**
**  The United States of America Department of Defense has unlimited 
**	usage, redistribution, and modification rights to XMLStar.
**
**  XMLStar is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**  GNU Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public License
**  along with XMLStar.  If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once
#ifndef HTL_XMLREADER_H
#define HTL_XMLREADER_H

#include "..\..\modHtlGlobal.h"

using namespace std;
namespace HTL{

	typedef std::pair<std::string,std::string> XMLNameValuePair;


	class HtlElement;
	class HtlAttribute;
	class HtlComment;
	class HtlProcess;

	class HTL_DLLAPI HtlXMLReader
	{
	public:

		//!PUBLIC CONSTRUCTORS & DESTRUCTOR/////////////////////////////
		HtlXMLReader(void);
		virtual ~HtlXMLReader(void);
		//!PUBLIC OPERATOR OVERLOADS

		//XML SERIALIZATION AND DE-SERIALIZATION METHODS///////////
		//!Expand the XML string value of the element
		virtual int LoadXMLTree(HtlElement * ptrCurrTop, const std::string & strInput, HtlElementIndex & objCurrElementIndex);
		virtual int LoadXMLTree(HtlElement * ptrCurrTop, std::istream & strStreamInput);
		virtual int LoadXMLTree(HtlElement * ptrCurrTop, std::ifstream & strStreamInput);

		//!Load the XML Element based on the current starting location of the index
		int LoadXMLElement(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);

	protected:
		//!Load the Tag to the Element Name
		int LoadOpenTag(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex, bool & blnNullElementReturn);
		//!Load the Tag to the Element Name
		int LoadCloseTag(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);
		//!Load the Attributes into the Element
		int	LoadAttributes(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);
		//!Load the Value into the Element
		int	LoadValue(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);

		//!Load the Comments, Processes, and Sub Elements
		int	LoadSubNodes(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);
		//!Load a Sub Element
		int	LoadSubElement(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);

		//!Load the Comments into the Element
		int	LoadComment(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);

		//!Load the Comments into the Element
		int	LoadProcess(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);
		//!Load the Tag to the Element Name
		int LoadProcessOpenTag(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);
		//!Load the Attributes into the Element
		int	LoadProcessAttributes(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);
		//!Load the Value into the Element
		int	LoadProcessValue(HtlElement * ptrElement, const std::string & strInput, HtlElementIndex & objCurrElementIndex);
		
		//!Find Next < character indicating a start tag
		long FindNextTagStart(const std::string & strInput,size_t intStartPos, bool & blnCloseTag);
		//!Find Next Non-White Space Legal Character
		long FindNextNWSLChar(const std::string & strInput,size_t intStartPos); 
		//!Find Next Non-White Space Character
		long FindNextNWSChar(const std::string & strInput,size_t intStartPos);
		//!Find Next White Space Character
		long FindNextWSChar(const std::string & strInput,size_t intStartPos);
		//!Find Next Quotation " or '
		long FindNextQuote(const std::string & strInput,size_t intStartPos);
		//!Find Next Character
		long FindNextChar(const std::string & strInput,size_t intStartPos, char chrFind);

		bool IsNodeComment(const std::string & strInput,size_t intStartPos);
		bool IsNodeProcess(const std::string & strInput,size_t intStartPos);
		bool IsNodeElement(const std::string & strInput,size_t intStartPos);
		//!This Node removes the trailing whitespace and a rogue equal sign incase of error
		void CleanNameString(std::string & strName);
	private:

	HtlComment * m_ptrCurrComment;
	HtlProcess * m_ptrCurrProcess;
	//the string that everything is stored in
	std::string m_str;
	//the string size
	size_t m_intStringSize;
	};//end XMLWriter class definition

};//end namespace XMLStar
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions