Пример #1
0
void AbstractStringValidator::init(RefArrayVectorOf<XMLCh>*           const enums
                                   ,MemoryManager*                    const manager)
{

    if (enums)
    {
        setEnumeration(enums, false);
        normalizeEnumeration(manager);
    }

    assignFacet(manager);
    inspectFacet(manager);
    inspectFacetBase(manager);
    inheritFacet();

}
Пример #2
0
///////////////////////////////////////////////////////////////////////
// Enumerate all the remaining records.
// Return the id of the last record enumerated.
///////////////////////////////////////////////////////////////////
clist_index_t BufferList::enumerateAll() {

	// sort and enumerate the records
	
	thelist.sort(Cmp());
	if (verbose) {
//		cout << "After sorting: "<<endl;
//		toString();
	}
	
	// Get an iterator for the bufferlist
	typedef list<simpRecord>::iterator lsr;
	lsr recIter = thelist.begin();
	clist_index_t nextLowestSeqNum;

	if (verbose) 
		cerr << "BufferList: lowest index: "<<lowestSeqNum<<endl;


	// Enumerate all is simpler than enumerate, all we do is go through the entire list
	// after sorting and enumerate each one. Then decrement the refCount for each one.	
	while (recIter != thelist.end()) {
		simpRecord temp_rec = (*recIter);
		clist_index_t tempSeq = temp_rec.getSeq();
		if (verbose) 
			cerr << "BufferList: in remove: processing seqnum: "<<tempSeq<<endl;
		
		decRefCount(&(*recIter));

		// Now enumerate the element..
		if (verbose) 
			cerr << "BufferList: setting record "<<tempSeq<<" value to: "<<enumerationIndex<<endl;
		setEnumeration(enumerationIndex,*recIter);
		enumerationIndex+=interval;

		++recIter;
	}
	// Remove the elements.
	thelist.erase(thelist.begin(),thelist.end());	

}
Пример #3
0
    void AbstractParam::readParameters(const YAML::Node &yamlNode)
    {
        for ( YAML::const_iterator it = yamlNode.begin(); it != yamlNode.end(); ++it )
        {
            std::string key = READ_NODE_AS_STRING(it->first);

            if (key == Keys::Description)
                setDescription(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::Default)
                setDefaultValue(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::DisplayName)
                setDisplayName(READ_NODE_AS_STRING(it->second));

            else if (key == Keys::Example)
                setExample(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::Maximum)
                setMaximum(READ_NODE_AS_LONG(it->second));
            else if (key == Keys::Minimum)
                setMinimum(READ_NODE_AS_LONG(it->second));
            else if (key == Keys::MaxLength)
                setMaxLength(READ_NODE_AS_INT(it->second));
            else if (key == Keys::MinLength)
                setMinLength(READ_NODE_AS_INT(it->second));

            else if (key == Keys::Pattern)
                setPattern(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::Repeat)
                setRepeat(READ_NODE_AS_BOOL(it->second));
            else if (key == Keys::Required)
                setRequired(READ_NODE_AS_BOOL(it->second));
            else if (key == Keys::Type)
                setType(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::Enum)
            {
                YAML::Node enumNode = it->second;
                for ( YAML::const_iterator tt = enumNode.begin(); tt != enumNode.end(); ++tt )
                    setEnumeration(READ_NODE_AS_STRING(*tt));
            }
        }
    }
void UnionDatatypeValidator::init(DatatypeValidator*            const baseValidator
                                , RefHashTableOf<KVStringPair>* const facets
                                , RefArrayVectorOf<XMLCh>*      const enums
                                , MemoryManager*                const manager)
{
    if (enums)
        setEnumeration(enums, false);

    // Set Facets if any defined
    if (facets)
    {
        XMLCh* key;
        XMLCh* value;
        RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager);

        while (e.hasMoreElements())
        {
            KVStringPair pair = e.nextElement();
            key = pair.getKey();
            value = pair.getValue();

            if (XMLString::equals(key, SchemaSymbols::fgELT_PATTERN))
            {
                setPattern(value);
                if (getPattern())
                    setFacetsDefined(DatatypeValidator::FACET_PATTERN);
                // do not construct regex until needed
            }
            else
            {
                 ThrowXMLwithMemMgr1(InvalidDatatypeFacetException
                         , XMLExcepts::FACET_Invalid_Tag
                         , key
                         , manager);
            }
        }//while

        /***
           Schema constraint: Part I -- self checking
        ***/
        // Nil

        /***
           Schema constraint: Part II base vs derived checking
        ***/
        // check 4.3.5.c0 must: enumeration values from the value space of base
        if ( ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) != 0) &&
            (getEnumeration() !=0))
        {
            int i = 0;
            int enumLength = getEnumeration()->size();
            try
            {
                for ( ; i < enumLength; i++)
                {
                    // ask parent do a complete check
                    //
                    // enum need NOT be passed this->checkContent()
                    // since there are no other facets for Union, parent
                    // checking is good enough.
                    //
                    baseValidator->validate(getEnumeration()->elementAt(i), (ValidationContext*)0, manager);

                }
            }

            catch ( XMLException& )
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException
                            , XMLExcepts::FACET_enum_base
                            , getEnumeration()->elementAt(i)
                            , manager);
            }
        }

    }// End of Facet setting

    /***
        Inherit facets from base.facets

        The reason of this inheriting (or copying values) is to ease
        schema constraint checking, so that we need NOT trace back to our
        very first base validator in the hierachy. Instead, we are pretty
        sure checking against immediate base validator is enough.
    ***/

    UnionDatatypeValidator *pBaseValidator = (UnionDatatypeValidator*) baseValidator;

    // inherit enumeration
    if (((pBaseValidator->getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) !=0) &&
        ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) == 0))
    {
        setEnumeration(pBaseValidator->getEnumeration(), true);
    }

}
Пример #5
0
///////////////////////////////////////////////////////////////////////
// Return the id of the least record that hasn't been enumerated yet.
// this particular record will be in the next iteration.
///////////////////////////////////////////////////////////////////
clist_index_t BufferList::enumerate() {
	
	// sort and enumerate the records
	
	thelist.sort(Cmp());
	if (verbose) {
//		cerr << "After sorting: "<<endl;
//		toString();
	}
	
	// Get an iterator for the bufferlist
	typedef list<simpRecord>::iterator lsr;
	lsr recIter = thelist.begin();
	clist_index_t nextLowestSeqNum;

	if (lowestSeqNum == std::numeric_limits<uint32_t>::max()) {
		// This means that there weren't any records remaining in the buffer
		// at the end of the last iteration. Now we just set lowestSeqNum to 
		// the value of the first element in the buff list.
		lowestSeqNum = thelist.front().getSeq();
		if (verbose) 
			cerr << "BufferList: lowest index changed to: "<<lowestSeqNum<<endl;
			
	}
	
	if (verbose) 
		cerr << "BufferList: lowest index: "<<lowestSeqNum<<endl;
	// Loop until we have no more records..
	while (recIter != thelist.end()) {
		simpRecord temp_rec = (*recIter);
		clist_index_t tempSeq = temp_rec.getSeq();
		
//		 Now enumerate the element..
		if (verbose) 
			cerr << "BufferList: setting record "<<tempSeq<<" value to: "<<enumerationIndex<<endl;
			
		setEnumeration(enumerationIndex,*recIter);
		enumerationIndex+=interval;



		// If the current record is the one we are searching for..
		if (tempSeq == lowestSeqNum) {
			// .. then we can rejoice! Now we must remove all the records before it, and 
			// find the lowestSeqNum in the remaining records.
			lsr savedRecIter(recIter);
			++recIter;
			// use the maximum value of uint32_t
			nextLowestSeqNum = std::numeric_limits<uint32_t>::max(); //currentIndex;
			// Now loop through the rest of the elements, trying to find the lowest one..
			// We want to keep track of the lowest sequence number in the new buffer..
			while (recIter != thelist.end()) {
				if ((*recIter).getSeq() < nextLowestSeqNum) {
					nextLowestSeqNum = (*recIter).getSeq();
				}
				++recIter;
			}
			
			// Set the sequence number correctly..
			lowestSeqNum = nextLowestSeqNum;
			if (verbose) 
				cerr << "BufferList: in remove: Next lowest sequence number: "<<lowestSeqNum<<endl;
				 
			// Now we will iterate through all the records we have correctly enumerated and
			// decrement the refCount on them and remove them from the list.
			lsr newRecIter = thelist.begin();
			++savedRecIter;
			
			for (;newRecIter != savedRecIter;++newRecIter) {
				decRefCount(&(*newRecIter));
			}
			// Remove the elements.
			thelist.erase(thelist.begin(),savedRecIter);	
			return(lowestSeqNum);		
		}
		++recIter;

	}
	if (verbose) 
		cerr << " BufferList: We shouldn't be getting here!!!"<<endl;
}