Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Parsing XML in C++ using the YARD Parser

, 21 Dec 2004
Provides a set of tools for building XML parsers in C++ using the YARD recursive descent parser.
// released into the public domain 
// by Christopher Diggins 2004 


#include <assert.h>

namespace yard 

  template<typename Elem_T, typename Iter_T = Elem_T const*>
  struct ParserInputStream 
    typedef Elem_T element_type;
    typedef Iter_T iter_type;
    ParserInputStream(Iter_T begin, Iter_T end) : mCurPos(begin), mEndPos(end)
    { }             
    Elem_T GetElem() { 
      return *mCurPos;
    void GotoNext() { 
    Iter_T GetPos() {
      return mCurPos;
    void SetPos(Iter_T pos) {
      mCurPos = pos; 
    bool AdvancePast(Elem_T elem) { 
      if (AtEnd()) { 
        return false; 
      if (GetElem() == elem) { 
        return true; 
      return false; 
    bool AtEnd() { 
      return mCurPos == mEndPos;
    Iter_T mCurPos;  
    Iter_T mEndPos;


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.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Christopher Diggins
Software Developer Autodesk
Canada Canada
This article was written by Christopher Diggins, a computer science nerd who currently works at Autodesk as an SDK specialist.
Follow on   Twitter   Google+   LinkedIn

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150302.1 | Last Updated 21 Dec 2004
Article Copyright 2004 by Christopher Diggins
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid