SOL9 2.0 Class: SchemaItemCollection

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * SchemaItemCollection.h 
 * Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2011/02/06
#pragma once

#include <sol/xml/XMLObject.h>
#include <sol/xml/SchemaItem.h>

namespace SOL {

class SchemaItemCollection : public XMLObject {
private:
    MSXML2::ISchemaItemCollectionPtr pCollection;

public:
    SchemaItemCollection(MSXML2::ISchemaItemCollectionPtr collection)
    :pCollection(collection)
    {
    }

public:
    MSXML2::ISchemaItemCollectionPtr getCollectionPtr()
    {
        if (pCollection==NULL) {
            throw Exception("Error: SchemaItemCollection is NULL");
        }
        return pCollection;
    }


public:
    MSXML2::ISchemaItemPtr getItem(long index)
    {
        return getCollectionPtr()->Getitem(index);
    }

    MSXML2::ISchemaItemPtr itemByName(_bstr_t name)
    {
        return getCollectionPtr()->itemByName(name);
    }
    
    MSXML2::ISchemaItemPtr itemByQName(_bstr_t name,_bstr_t namespaceURI)
    {
        return getCollectionPtr()->itemByQName(name, namespaceURI);
    }
    
    long getLength()
    {
        return getCollectionPtr()->Getlength();
    }
    
    IUnknownPtr getNewEnum()
    {
        return getCollectionPtr()->Get_newEnum();
    }

public:
    void display(const TCHAR* name=NULL)
    {
        try {
            long len = getLength();
            if (len>0) {
                if (name == NULL) {
                    name = _T("SchemaItemCollection");
                }

                _tprintf(_T("<%s length=\"%d\">\n"), name, len);
                for (long i = 0; i<len; i++) {
                    try {
                        SchemaItem item = getItem(i);
                        item.display();
                    } catch (...) {
                    }
                }
                _tprintf(_T("</%s>\n"), name);
            }

        } catch (...) {
        }
    }

};


}

Last modified: 1 Feb 2012

Copyright (c) 2009-2012 Antillia.com ALL RIGHTS RESERVED.