예제 #1
0
int ListDatatypeValidator::compare(const XMLCh*     const lValue
                                 , const XMLCh*     const rValue
                                 , MemoryManager*   const manager)
{
    DatatypeValidator* theItemTypeDTV = getItemTypeDTV();
    BaseRefVectorOf<XMLCh>* lVector = XMLString::tokenizeString(lValue, manager);
    Janitor<BaseRefVectorOf<XMLCh> > janl(lVector);
    BaseRefVectorOf<XMLCh>* rVector = XMLString::tokenizeString(rValue, manager);
    Janitor<BaseRefVectorOf<XMLCh> > janr(rVector);

    int lNumberOfTokens = lVector->size();
    int rNumberOfTokens = rVector->size();

    if (lNumberOfTokens < rNumberOfTokens)
        return -1;
    else if (lNumberOfTokens > rNumberOfTokens)
        return 1;
    else
    { //compare each token
        for ( int i = 0; i < lNumberOfTokens; i++)
        {
            int returnValue = theItemTypeDTV->compare(lVector->elementAt(i), rVector->elementAt(i), manager);
            if (returnValue != 0)
                return returnValue; //REVISIT: does it make sense to return -1 or +1..?
        }
        return 0;
    }

}
예제 #2
0
std::vector<XMLCh*> XMLStringUtil::Tokenise(const XMLCh* const str)
{
	BaseRefVectorOf<XMLCh>* parts = XMLString::tokenizeString(str);
	std::vector<XMLCh*> partsVec(parts->size());
	for(size_t i=0,is=parts->size();i<is;++i) {
		partsVec[i] = parts->elementAt(i);
	}
	return partsVec;
}
예제 #3
0
void XMLStringUtil::Space2Hex(XMLCh* const str)
{
	XMLCh hexVal[4] = {chPercent,chDigit_2,chDigit_0,chNull};
	XMLCh tempBuf[512];
	XMLString::copyString(tempBuf,str);
	BaseRefVectorOf<XMLCh>*  parts = XMLString::tokenizeString(tempBuf);
	Janitor<BaseRefVectorOf<XMLCh> > jan(parts);
	if (parts->size()) {
		XMLString::copyString(str,parts->elementAt(0));
		for(size_t i=1,is=parts->size();i<is;++i) {
			XMLString::catString(str,hexVal);
			XMLString::catString(str,parts->elementAt(i));
		}
	}
}
예제 #4
0
void ListDatatypeValidator::inspectFacetBase(MemoryManager* const manager)
{

    //
    // we are pretty sure baseValidator is not null
    //

    if (getBaseValidator()->getType() == DatatypeValidator::List)
    {
        AbstractStringValidator::inspectFacetBase(manager);
    }
    else
    {
        // the first level ListDTV
        // check 4.3.5.c0 must: enumeration values from the value space of base
        if ( ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) != 0) &&
             (getEnumeration() !=0)                                              )
        {
            int i;
            int enumLength = getEnumeration()->size();
            try
            {
                for ( i = 0; i < enumLength; i++)
                {
                    // ask the itemType for a complete check
                    BaseRefVectorOf<XMLCh>* tempList = XMLString::tokenizeString(getEnumeration()->elementAt(i), manager);
                    Janitor<BaseRefVectorOf<XMLCh> >    jan(tempList);
                    int tokenNumber = tempList->size();

                    try
                    {
                        for ( int j = 0; j < tokenNumber; j++)
                            getBaseValidator()->validate(tempList->elementAt(j), (ValidationContext*)0, manager);
                    }
                    catch(const OutOfMemoryException&)
                    {
                        jan.release();

                        throw;
                    }

                    // enum shall pass this->checkContent() as well.
                    checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false, manager);
                }
            }

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

        }

    }

}// End of inspectFacetBase()
예제 #5
0
int ListDatatypeValidator::getLength(const XMLCh* const content
                                     , MemoryManager* const manager) const
{
    BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content, manager);
    Janitor<BaseRefVectorOf<XMLCh> > janName(tokenVector);

    return tokenVector->size();
}
예제 #6
0
static BaseRefVectorOf<XMLCh> *
decomposeAttributeName(const gss_buffer_t attr)
{
    BaseRefVectorOf<XMLCh> *components;
    string str((const char *)attr->value, attr->length);
    auto_ptr_XMLCh qualifiedAttr(str.c_str());

    components = XMLString::tokenizeString(qualifiedAttr.get());

    if (components->size() != 2) {
        delete components;
        components = NULL;
    }

    return components;
}
예제 #7
0
bool ListDatatypeValidator::valueSpaceCheck(BaseRefVectorOf<XMLCh>* tokenVector
                                          , const XMLCh*    const  enumStr
                                          , MemoryManager*  const  manager) const
{
    DatatypeValidator* theItemTypeDTV = getItemTypeDTV();
    BaseRefVectorOf<XMLCh>* enumVector = XMLString::tokenizeString(enumStr, manager);
    Janitor<BaseRefVectorOf<XMLCh> > janName(enumVector);

    if (tokenVector->size() != enumVector->size())
        return false;

    for ( unsigned int j = 0; j < tokenVector->size(); j++ )
    {
        if (theItemTypeDTV->compare(tokenVector->elementAt(j), enumVector->elementAt(j), manager) != 0)
            return false;
    }

    return true;
}
예제 #8
0
void BaseValue::ReadValue(const DOMNode* node)
{
	_ASSERTE(node != NULL);

	DOMNode* value = node->getFirstChild();
	if( value == NULL ) { return; }

	BaseRefVectorOf<XMLCh>* vecValue = XMLString::tokenizeString( value->getNodeValue() );

	unsigned int sizeValue = vecValue->size();
	if( sizeValue == 0 ) { return; }

	valParam.reserve( sizeValue );
	for( unsigned int i = 0; i < sizeValue; i++ )
	{
		valParam.push_back( XMLChToFloat( vecValue->elementAt( i ) ) );
	}

	SAFE_DELETE(vecValue);
}
예제 #9
0
void ParamElement::ReadValue(const DOMNode* node)
{
	_ASSERTE(node != NULL);

	DOMNode* value = node->getFirstChild();
	if( value == NULL ) { return; }

	BaseRefVectorOf<XMLCh>* vecValue = XMLString::tokenizeString( value->getNodeValue() );

	unsigned int sizeValue = vecValue->size();
	if( sizeValue == 0 ) { return; }

	if( IsFloatType() )
	{
		valFloat.reserve( sizeValue );
		for( unsigned int i = 0; i < sizeValue; i++ )
		{
			valFloat.push_back( XMLChToFloat( vecValue->elementAt( i ) ) );
		}
	}
	else if( IsBoolType() )
	{
		valBool.reserve( sizeValue );
		for( unsigned int i = 0; i < sizeValue; i++ )
		{
			valBool.push_back( XMLChToBool( vecValue->elementAt( i ) ) );
		}
	}
	else if( IsBlendType() )
	{
		// 未実装
	}
	else if( IsFunctionType() )
	{
		// 未実装
	}
	else { _ASSERTE(!"UnknownType"); }

	SAFE_DELETE(vecValue);
}
예제 #10
0
/***
 * 2.5.1.2 List datatypes   
 *   
 * The canonical-lexical-representation for the ·list· datatype is defined as 
 * the lexical form in which each item in the ·list· has the canonical 
 * lexical representation of its ·itemType·.
 ***/
const XMLCh* ListDatatypeValidator::getCanonicalRepresentation(const XMLCh*         const rawData
                                                             ,       MemoryManager* const memMgr
                                                             ,       bool                 toValidate) const
{
    MemoryManager* toUse = memMgr? memMgr : getMemoryManager();
    ListDatatypeValidator* temp = (ListDatatypeValidator*) this;
    temp->setContent(rawData);
    BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(rawData, toUse);
    Janitor<BaseRefVectorOf<XMLCh> > janName(tokenVector);    

    if (toValidate)
    {
        try
        {
            temp->checkContent(tokenVector, rawData, 0, false, toUse);
        }
        catch (...)
        {
            return 0;
        }
    }
   
    unsigned int  retBufSize = 2 * XMLString::stringLen(rawData);
    XMLCh* retBuf = (XMLCh*) toUse->allocate(retBufSize * sizeof(XMLCh));
    retBuf[0] = 0;
    XMLCh* retBufPtr = retBuf;
    DatatypeValidator* itemDv = this->getItemTypeDTV();

    try 
    {
        for (unsigned int i = 0; i < tokenVector->size(); i++)
        {
            XMLCh* itemCanRep = (XMLCh*) itemDv->getCanonicalRepresentation(tokenVector->elementAt(i), toUse, false);
            unsigned int itemLen = XMLString::stringLen(itemCanRep); 

            if(retBufPtr+itemLen+2 >= retBuf+retBufSize)
            {
                // need to resize
                XMLCh * oldBuf = retBuf;
                retBuf = (XMLCh*) toUse->allocate(retBufSize * sizeof(XMLCh) * 4);
                memcpy(retBuf, oldBuf, retBufSize * sizeof(XMLCh ));
                retBufPtr = (retBufPtr - oldBuf) + retBuf;
                toUse->deallocate(oldBuf);
                retBufSize <<= 2;
            }

            XMLString::catString(retBufPtr, itemCanRep);
            retBufPtr = retBufPtr + itemLen + 1;
            *(retBufPtr++) = chSpace;
            *(retBufPtr) = chNull;
            toUse->deallocate(itemCanRep);
        }

        return retBuf;

    }
    catch (...)
    {
        return 0;
    }
}