/*
This template tries to show, that almost anything is possible with bib2x-templates.
The outcome of this template is C++ Code, which you can compile.
It does not do much but fill objects with the bibliographic entries and print them afterwards.


*/



#include <iostream>
#include <string>
#include <map>

typedef std::map<std::string, std::string> CName2Str;

class CEntry
{
private:
    std::string m_sName;
    std::string m_sType;
    CName2Str m_oAttrib;
    CEntry* m_poNext;


    void Print ( )
        {
        CName2Str::iterator mIt = m_oAttrib.begin();
        CName2Str::iterator mItEnd = m_oAttrib.end();
    
        std::cout << m_sName << "(" << m_sType << "):" << std::endl;

        for ( ; mIt != mItEnd; ++mIt )
            {
            std::cout << "\t" << mIt->first << "\t:" << mIt->second << std::endl;
            }
        std::cout << std::endl;
        }

public:

    CEntry ( std::string sName, std::string sType )
        : m_sName ( sName ),
          m_sType ( sType )
        {
        m_poNext = 0;
        }
    
    void FollowedBy ( CEntry* poNext )
        {
        m_poNext = poNext;
        }

    void AddAttrib ( std::string sName, std::string sContent )
        {
        m_oAttrib[sName] = sContent;
        }

    void PrintRecursively ()
        {
        Print();
        if ( m_poNext )
            m_poNext->PrintRecursively ();
        }

};



int main ( void )
    {
    CEntry* poEntry = 0;
    CEntry* poPrev = 0;
    CEntry* poFirst = 0;


    poPrev = poEntry;
    poEntry = new CEntry ( "CSS21:2005", "@misc" );
    if ( poPrev )
        poPrev->FollowedBy(poEntry);
    if ( !poFirst )
        poFirst = poEntry;

    poEntry->AddAttrib("author", "Bert Bos and Tantek &#x43;&#x0327;elik and Ian Hickson and H&#x0061;&#x030A;kon Wium Lie");
    poEntry->AddAttrib("title", "Cascading Style Sheets, CSS 2.1 Specification");
    poEntry->AddAttrib("year", "2005");
    poEntry->AddAttrib("howpublished", "W3C Recommendation, http://www.w3.org/TR/2005/WD-CSS21-20050613/http://www.w3.org/TR/2005/WD-CSS21-20050613/");
    poEntry->AddAttrib("url", "http://www.w3.org/TR/2005/WD-CSS21-20050613/");




    poPrev = poEntry;
    poEntry = new CEntry ( "XML11:2004", "@misc" );
    if ( poPrev )
        poPrev->FollowedBy(poEntry);
    if ( !poFirst )
        poFirst = poEntry;

    poEntry->AddAttrib("author", "Bray Tim and Jean Paoli and C. M. Sperberg-McQueen and Eve Maler and Fran&#x63;&#x0327;ois Yergeau and John Cowan");
    poEntry->AddAttrib("title", "Extensible Markup Language (XML) 1.1 Specification");
    poEntry->AddAttrib("year", "2004");
    poEntry->AddAttrib("howpublished", "W3C Recommendation, http://www.w3.org/TR/xml11/http://www.w3.org/TR/xml11/");
    poEntry->AddAttrib("url", "http://www.w3.org/TR/xml11/");




    poPrev = poEntry;
    poEntry = new CEntry ( "HTML4:1999", "@misc" );
    if ( poPrev )
        poPrev->FollowedBy(poEntry);
    if ( !poFirst )
        poFirst = poEntry;

    poEntry->AddAttrib("author", "Dave Raggett and Arnaud Le Hors and Ian Jacobs");
    poEntry->AddAttrib("title", "HTML 4.01 Specification");
    poEntry->AddAttrib("year", "1999");
    poEntry->AddAttrib("howpublished", "W3C Recommendation, http://www.w3.org/TR/html4/http://www.w3.org/TR/html4/");
    poEntry->AddAttrib("url", "http://www.w3.org/TR/html4/");




    poPrev = poEntry;
    poEntry = new CEntry ( "seligman01impact", "@article" );
    if ( poPrev )
        poPrev->FollowedBy(poEntry);
    if ( !poFirst )
        poFirst = poEntry;

    poEntry->AddAttrib("author", "Len Seligman and Arnon Rosenthal");
    poEntry->AddAttrib("title", "XML's Impact on Databases and Data Sharing");
    poEntry->AddAttrib("year", "2001");
    poEntry->AddAttrib("address", "Los Alamitos, CA, USA");
    poEntry->AddAttrib("doi", "http://dx.doi.org/10.1109/2.928623");
    poEntry->AddAttrib("issn", "0018-9162");
    poEntry->AddAttrib("journal", "Computer");
    poEntry->AddAttrib("number", "6");
    poEntry->AddAttrib("pages", "59--67");
    poEntry->AddAttrib("publisher", "IEEE Computer Society Press");
    poEntry->AddAttrib("volume", "34");




    poPrev = poEntry;
    poEntry = new CEntry ( "lamport94", "@book" );
    if ( poPrev )
        poPrev->FollowedBy(poEntry);
    if ( !poFirst )
        poFirst = poEntry;

    poEntry->AddAttrib("author", "Leslie Lamport");
    poEntry->AddAttrib("title", "LaTeX: This entry is an intended dupe!");
    poEntry->AddAttrib("year", "1995");
    poEntry->AddAttrib("pages", "156-163");
    poEntry->AddAttrib("publisher", "Addison-Wesley");



    poPrev = poEntry;
    poEntry = new CEntry ( "lamport94", "@book" );
    if ( poPrev )
        poPrev->FollowedBy(poEntry);
    if ( !poFirst )
        poFirst = poEntry;

    poEntry->AddAttrib("author", "Leslie Lamport");
    poEntry->AddAttrib("title", "LaTeX: A Document Preparation System");
    poEntry->AddAttrib("year", "1994");
    poEntry->AddAttrib("pages", "156-163");
    poEntry->AddAttrib("publisher", "Addison-Wesley");




    poPrev = poEntry;
    poEntry = new CEntry ( "patashnik-bibtexing", "@misc" );
    if ( poPrev )
        poPrev->FollowedBy(poEntry);
    if ( !poFirst )
        poFirst = poEntry;

    poEntry->AddAttrib("author", "Oren Patashnik");
    poEntry->AddAttrib("title", "BIBTEXing");
    poEntry->AddAttrib("year", "1988");
    poEntry->AddAttrib("url", "citeseer.ist.psu.edu/article/patashnik88bibtexing.html");




    poPrev = poEntry;
    poEntry = new CEntry ( "Unicode:2003:USV", "@book" );
    if ( poPrev )
        poPrev->FollowedBy(poEntry);
    if ( !poFirst )
        poFirst = poEntry;

    poEntry->AddAttrib("author", "The Unicode Consortium");
    poEntry->AddAttrib("title", "The Unicode Standard, Version 4.0");
    poEntry->AddAttrib("year", "2003");
    poEntry->AddAttrib("acknowledgement", "--EMPTY--");
    poEntry->AddAttrib("address", "Reading, MA, USA");
    poEntry->AddAttrib("bibdate", "Tue Oct 21 17:47:30 2003");
    poEntry->AddAttrib("isbn", "0-321-18578-1");
    poEntry->AddAttrib("isbn-13", "978-0-321-18578-5");
    poEntry->AddAttrib("lccn", "QA268 .U545 2004");
    poEntry->AddAttrib("note", "Includes CD-ROM.");
    poEntry->AddAttrib("pages", "xxxviii + 1462");
    poEntry->AddAttrib("publisher", "Addison-Wesley");
    poEntry->AddAttrib("url", "http://www.unicode.org/versions/Unicode4.0.0/");




    poFirst->PrintRecursively();
    }