Exemple #1
0
 zfbool onVisitXmlProcessingInstruction(ZF_IN const ZFXmlVisitData &data)
 {
     switch(data.xmlVisitType)
     {
         case ZFXmlVisitType::e_Enter:
             if(data.depth > 0 || data.siblingIndex > 0)
             {
                 this->add(flags.xmlToken.xmlNewLineToken);
             }
             this->add(flags.xmlGlobalLineBeginToken);
             this->addIndent(flags.xmlToken.xmlIndentToken, data.depth);
             this->add(flags.xmlToken.xmlPITagLeft);
             this->add(data.xmlItem->xmlName());
             this->add(zfText(" "));
             this->add(data.xmlItem->xmlValue());
             break;
         case ZFXmlVisitType::e_Exit:
             this->add(flags.xmlToken.xmlPITagRight);
             break;
         case ZFXmlVisitType::e_ExitChildren:
         default:
             zfCoreCriticalShouldNotGoHere();
             break;
     }
     return zftrue;
 }
    virtual void mutexImplUnlock(void)
    {
        this->paramLock();
        _ZFP_ZFObjectMutexImpl_default_ThreadIdType curThreadId = this->currentThreadId();
        _ZFP_ZFObjectMutexImpl_default_LockedThreadCountMapType::iterator it = this->lockedThreadCountMap.find(curThreadId);
        if(curThreadId == this->runningThreadId)
        {
            --(it->second);
            if(it->second == 0)
            {
                this->lockedThreadCountMap.erase(it);
                this->runningThreadId = this->INVALID_THREAD_ID;
                this->paramUnlock();
                // all locks locked by current thread are relesed, unlock
                this->doUnlock();
            }
            else
            {
                this->paramUnlock();
                // current thread still hold some locks, just return
            }
        }
        else
        {
            this->paramUnlock();

            // current thread doesn't lock, it's a error state
            zfCoreCriticalShouldNotGoHere();
            return ;
        }
    }
zfbool ZFLeakTestObjectFilter::filterOnCheckActive(ZF_IN ZFObject * const &obj) const
{
    if(!zfsuper::filterOnCheckActive(obj))
    {
        return zffalse;
    }
    zfbool hasIncludeMode = zffalse;
    zfbool included = zffalse;
    for(zfindex i = 0; i < this->_ZFP_ZFLeakTestObjectFilter_nameFilters.count(); ++i)
    {
        const _ZFP_ZFLeakTestObjectFilterData &nameFilter = this->_ZFP_ZFLeakTestObjectFilter_nameFilters.get(i);
        switch(nameFilter.filterType)
        {
            case ZFFilterTypeInclude:
                hasIncludeMode = zftrue;
                if(nameFilter.name.compare(obj->classData()->className()) == 0)
                {
                    included = zftrue;
                }
                break;
            case ZFFilterTypeExclude:
                if(nameFilter.name.compare(obj->classData()->className()) == 0)
                {
                    return zffalse;
                }
                break;
            default:
                zfCoreCriticalShouldNotGoHere();
                return zffalse;
        }
    }
    return (!hasIncludeMode || included);
}
 virtual zfbool fileSeek(ZF_IN ZFFileToken token,
                         ZF_IN zfindex byteSize,
                         ZF_IN_OPT ZFSeekPos position = ZFSeekPosBegin)
 {
     if(token == ZFFileTokenInvalid)
     {
         return zffalse;
     }
     int tmpPos = 0;
     long seekSize = (long)byteSize;
     switch(position)
     {
         case ZFSeekPosBegin:
             tmpPos = SEEK_SET;
             break;
         case ZFSeekPosCur:
             tmpPos = SEEK_CUR;
             break;
         case ZFSeekPosCurReversely:
             tmpPos = SEEK_CUR;
             seekSize = -seekSize;
             break;
         case ZFSeekPosEnd:
             tmpPos = SEEK_END;
             break;
         default:
             zfCoreCriticalShouldNotGoHere();
             break;
     }
     return (::fseek((FILE *)token, seekSize, tmpPos) == 0);
 }
ZFPROPERTY_TYPE_DECLARE_SERIALIZE_TO_DEFINE(ZFCallback, ZFCallback)
{
    if(v.callbackSerializeCustomType() != zfnull)
    {
        if(v.callbackSerializeCustomData() == zfnull)
        {
            ZFSerializableUtil::errorOccurred(outErrorHintToAppend, zfText("missing callback serialize custom data"));
            return zffalse;
        }
        serializableData.itemClassSet(ZFPropertyTypeId_ZFCallback);

        serializableData.attributeSet(ZFSerializableKeyword_ZFCallback_callbackType, v.callbackSerializeCustomType());

        ZFSerializableData customData = v.callbackSerializeCustomData()->copy();
        customData.categorySet(ZFSerializableKeyword_ZFCallback_callbackData);
        serializableData.elementAdd(customData);

        return zftrue;
    }

    switch(v.callbackType())
    {
        case ZFCallbackTypeDummy:
            serializableData.itemClassSet(ZFSerializableKeyword_null);
            break;
        case ZFCallbackTypeMethod:
        {
            serializableData.itemClassSet(ZFPropertyTypeId_ZFCallback);
            ZFSerializableData methodData;
            if(!ZFMethodToSerializableData(methodData, v.callbackMethod(), outErrorHintToAppend))
            {
                return zffalse;
            }
            methodData.categorySet(ZFSerializableKeyword_ZFCallback_method);
            serializableData.elementAdd(methodData);
        }
            break;
        case ZFCallbackTypeMemberMethod:
        {
            ZFSerializableUtil::errorOccurred(outErrorHintToAppend,
                zfText("member method callback is not supported"));
            return zffalse;
        }
            break;
        case ZFCallbackTypeRawFunction:
            serializableData.itemClassSet(ZFPropertyTypeId_ZFCallback);
            ZFSerializableUtil::errorOccurred(outErrorHintToAppend,
                zfText("raw function is not supported"));
            return zffalse;
        default:
            zfCoreCriticalShouldNotGoHere();
            return zffalse;
    }

    return zftrue;
}
ZF_NAMESPACE_GLOBAL_BEGIN

void ZFLevelToString(ZF_IN_OUT zfstring &ret, ZF_IN ZFLevel const &value)
{
    switch(value)
    {
        case ZFLevelZFFrameworkStatic:
            ret += ZFTOKEN_ZFLevelZFFrameworkStatic;
            return ;
        case ZFLevelZFFrameworkEssential:
            ret += ZFTOKEN_ZFLevelZFFrameworkEssential;
            return ;
        case ZFLevelZFFrameworkHigh:
            ret += ZFTOKEN_ZFLevelZFFrameworkHigh;
            return ;
        case ZFLevelZFFrameworkNormal:
            ret += ZFTOKEN_ZFLevelZFFrameworkNormal;
            return ;
        case ZFLevelZFFrameworkLow:
            ret += ZFTOKEN_ZFLevelZFFrameworkLow;
            return ;

        case ZFLevelAppEssential:
            ret += ZFTOKEN_ZFLevelAppEssential;
            return ;
        case ZFLevelAppHigh:
            ret += ZFTOKEN_ZFLevelAppHigh;
            return ;
        case ZFLevelAppNormal:
            ret += ZFTOKEN_ZFLevelAppNormal;
            return ;
        case ZFLevelAppLow:
            ret += ZFTOKEN_ZFLevelAppLow;
            return ;

        case ZFLevelZFFrameworkPostLow:
            ret += ZFTOKEN_ZFLevelZFFrameworkPostLow;
            return ;
        case ZFLevelZFFrameworkPostNormal:
            ret += ZFTOKEN_ZFLevelZFFrameworkPostNormal;
            return ;
        case ZFLevelZFFrameworkPostHigh:
            ret += ZFTOKEN_ZFLevelZFFrameworkPostHigh;
            return ;
        case ZFLevelZFFrameworkPostEssential:
            ret += ZFTOKEN_ZFLevelZFFrameworkPostEssential;
            return ;
        case ZFLevelZFFrameworkPostStatic:
            ret += ZFTOKEN_ZFLevelZFFrameworkPostStatic;
            return ;

        default:
            zfCoreCriticalShouldNotGoHere();
            return ;
    }
}
// ============================================================
// util
ZFUIOrientationEnum _ZFP_ZFUIFlowLayout_layoutOrientationSecondary(ZF_IN ZFUIOrientationEnum layoutOrientationMain,
                                                                   ZF_IN ZFUIOrientationEnum layoutOrientationSecondary)
{
    switch(layoutOrientationMain)
    {
        case ZFUIOrientation::e_Left:
        case ZFUIOrientation::e_Right:
            switch(layoutOrientationSecondary)
            {
                case ZFUIOrientation::e_Left:
                case ZFUIOrientation::e_Right:
                    return ZFUIOrientation::e_Top;
                case ZFUIOrientation::e_Top:
                case ZFUIOrientation::e_Bottom:
                    return layoutOrientationSecondary;
                default:
                    zfCoreCriticalShouldNotGoHere();
                    return ZFUIOrientation::e_Left;
            }
        case ZFUIOrientation::e_Top:
        case ZFUIOrientation::e_Bottom:
            switch(layoutOrientationSecondary)
            {
                case ZFUIOrientation::e_Left:
                case ZFUIOrientation::e_Right:
                    return layoutOrientationSecondary;
                case ZFUIOrientation::e_Top:
                case ZFUIOrientation::e_Bottom:
                    return ZFUIOrientation::e_Left;
                default:
                    zfCoreCriticalShouldNotGoHere();
                    return ZFUIOrientation::e_Left;
            }
        default:
            zfCoreCriticalShouldNotGoHere();
            return ZFUIOrientation::e_Left;
    }
}
ZFCompareResult ZFVersionCompare(ZF_IN const zfchar *version0,
                                 ZF_IN const zfchar *version1,
                                 ZF_IN_OPT ZFComparer<const zfchar *>::Comparer subVersionComparer /* = ZFComparerForVersion */)
{
    ZFCoreArrayPOD<zfindexRange> pos0;
    ZFCoreArrayPOD<zfindexRange> pos1;
    if(zfCoreDataPairSplitString(pos0, zfindexMax, version0, zfindexMax, '\0', '\0', zfText(".")) != zfnull
       || zfCoreDataPairSplitString(pos1, zfindexMax, version1, zfindexMax, '\0', '\0', zfText(".")) != zfnull)
    {
        return ZFCompareUncomparable;
    }

    zfindex count = zfmMin(pos0.count(), pos1.count());
    for(zfindex i = 0; i < count; ++i)
    {
        ZFCompareResult cmp = subVersionComparer(
            zfstring(version0 + pos0[i].start, pos0[i].count).cString()
            ,
            zfstring(version1 + pos1[i].start, pos1[i].count).cString()
            );
        switch(cmp)
        {
            case ZFCompareUncomparable:
            case ZFCompareSmaller:
            case ZFCompareGreater:
                return cmp;
            case ZFCompareTheSame:
                continue;
            default:
                zfCoreCriticalShouldNotGoHere();
                return ZFCompareUncomparable;
        }
    }
    if(pos0.count() > pos1.count())
    {
        return ZFCompareGreater;
    }
    else if(pos0.count() < pos1.count())
    {
        return ZFCompareSmaller;
    }
    else
    {
        return ZFCompareTheSame;
    }
}
Exemple #9
0
// ============================================================
void ZFMethodPrivilegeTypeToString(ZF_IN_OUT zfstring &ret, ZF_IN ZFMethodPrivilegeType const &value)
{
    switch(value)
    {
        case ZFMethodPrivilegeTypePublic:
            ret += ZFTOKEN_ZFMethodPrivilegeTypePublic;
            return ;
        case ZFMethodPrivilegeTypeProtected:
            ret += ZFTOKEN_ZFMethodPrivilegeTypeProtected;
            return ;
        case ZFMethodPrivilegeTypePrivate:
            ret += ZFTOKEN_ZFMethodPrivilegeTypePrivate;
            return ;
        default:
            zfCoreCriticalShouldNotGoHere();
            return ;
    }
}
ZF_NAMESPACE_GLOBAL_BEGIN

// ============================================================
void ZFFilterTypeToString(ZF_IN_OUT zfstring &ret, ZF_IN ZFFilterType const &value)
{
    switch(value)
    {
        case ZFFilterTypeInclude:
            ret += ZFTOKEN_ZFFilterTypeInclude;
            return ;
        case ZFFilterTypeExclude:
            ret += ZFTOKEN_ZFFilterTypeExclude;
            return ;
        default:
            zfCoreCriticalShouldNotGoHere();
            return ;
    }
}
// ============================================================
void ZFFilterCallbackResultToString(ZF_IN_OUT zfstring &ret, ZF_IN ZFFilterCallbackResult const &value)
{
    switch(value)
    {
        case ZFFilterCallbackResultNotSpecified:
            ret += ZFTOKEN_ZFFilterCallbackResultNotSpecified;
            return ;
        case ZFFilterCallbackResultActive:
            ret += ZFTOKEN_ZFFilterCallbackResultActive;
            return ;
        case ZFFilterCallbackResultNotActive:
            ret += ZFTOKEN_ZFFilterCallbackResultNotActive;
            return ;
        default:
            zfCoreCriticalShouldNotGoHere();
            return ;
    }
}
void ZFUILinearLayout::layoutOnMeasure(ZF_OUT ZFUISize &ret,
                                       ZF_IN const ZFUISize &sizeHint,
                                       ZF_IN const ZFUISizeParam &sizeParam)
{
    switch(this->layoutOrientation())
    {
        case ZFUIOrientation::e_Left:
        case ZFUIOrientation::e_Right:
            ret = _ZFP_ZFUILinearLayout_measureHorizontal(this, sizeHint, sizeParam);
            break;
        case ZFUIOrientation::e_Top:
        case ZFUIOrientation::e_Bottom:
            ret = _ZFP_ZFUILinearLayout_measureVertical(this, sizeHint, sizeParam);
            break;
        default:
            zfCoreCriticalShouldNotGoHere();
            return ;
    }
}
Exemple #13
0
 zfbool onVisitXmlAttribute(ZF_IN const ZFXmlVisitData &data)
 {
     switch(data.xmlVisitType)
     {
         case ZFXmlVisitType::e_Enter:
         {
             if(_ZFP_ZFXmlOutputAttributeNeedNewLine(*data.xmlItem, flags, data))
             {
                 this->add(flags.xmlToken.xmlNewLineToken);
                 this->add(flags.xmlGlobalLineBeginToken);
                 this->addIndent(flags.xmlToken.xmlIndentToken, data.depth);
             }
             else if(data.depth > 0 || data.siblingIndex > 0)
             {
                 this->add(zfText(" "));
             }
             this->add(data.xmlItem->xmlName());
             this->add(flags.xmlToken.xmlAttributeEqualTag);
             if(flags.xmlAttributeUseSingleQuote)
             {
                 this->add(flags.xmlToken.xmlAttributeSingleQuoteTagLeft);
                 ZFXmlEscapeCharEncode(this->outputCallback, data.xmlItem->xmlValue());
                 this->add(flags.xmlToken.xmlAttributeSingleQuoteTagRight);
             }
             else
             {
                 this->add(flags.xmlToken.xmlAttributeQuoteTagLeft);
                 ZFXmlEscapeCharEncode(this->outputCallback, data.xmlItem->xmlValue());
                 this->add(flags.xmlToken.xmlAttributeQuoteTagRight);
             }
         }
             break;
         case ZFXmlVisitType::e_Exit:
             break;
         case ZFXmlVisitType::e_ExitChildren:
         default:
             zfCoreCriticalShouldNotGoHere();
             break;
     }
     return zftrue;
 }
Exemple #14
0
static void _ZFP_ZFJsonToOutput_output(ZF_IN_OUT const ZFOutputCallback &output,
                                       ZF_IN const ZFJsonItem &jsonItem,
                                       ZF_IN const ZFJsonOutputFlags &outputFlags,
                                       ZF_IN zfindex indentLevel)
{
    switch(jsonItem.jsonType())
    {
        case ZFJsonType::e_JsonValue:
            _ZFP_ZFJsonToOutput_output_JsonValue(output, jsonItem, outputFlags, indentLevel);
            break;
        case ZFJsonType::e_JsonObject:
            _ZFP_ZFJsonToOutput_output_JsonObject(output, jsonItem, outputFlags, indentLevel);
            break;
        case ZFJsonType::e_JsonArray:
            _ZFP_ZFJsonToOutput_output_JsonArray(output, jsonItem, outputFlags, indentLevel);
            break;
        default:
            zfCoreCriticalShouldNotGoHere();
            break;
    }
}
Exemple #15
0
ZF_NAMESPACE_GLOBAL_BEGIN

// ============================================================
void ZFMethodTypeToString(ZF_IN_OUT zfstring &ret, ZF_IN ZFMethodType const &value)
{
    switch(value)
    {
        case ZFMethodTypeClassStatic:
            ret += ZFTOKEN_ZFMethodTypeClassStatic;
            return ;
        case ZFMethodTypeClassMember:
            ret += ZFTOKEN_ZFMethodTypeClassMember;
            return ;
        case ZFMethodTypeRawFunction:
            ret += ZFTOKEN_ZFMethodTypeRawFunction;
            return ;
        default:
            zfCoreCriticalShouldNotGoHere();
            return ;
    }
}
void ZFUILinearLayout::layoutOnLayout(ZF_IN const ZFUIRect &bounds)
{
    switch(this->layoutOrientation())
    {
        case ZFUIOrientation::e_Left:
            _ZFP_ZFUILinearLayout_layoutHorizontal(this, bounds.size, zftrue);
            break;
        case ZFUIOrientation::e_Right:
            _ZFP_ZFUILinearLayout_layoutHorizontal(this, bounds.size, zffalse);
            break;
        case ZFUIOrientation::e_Top:
            _ZFP_ZFUILinearLayout_layoutVertical(this, bounds.size, zftrue);
            break;
        case ZFUIOrientation::e_Bottom:
            _ZFP_ZFUILinearLayout_layoutVertical(this, bounds.size, zffalse);
            break;
        default:
            zfCoreCriticalShouldNotGoHere();
            return ;
    }
}
Exemple #17
0
 zfbool onVisitXmlText(ZF_IN const ZFXmlVisitData &data)
 {
     switch(data.xmlVisitType)
     {
         case ZFXmlVisitType::e_Enter:
             if(_ZFP_ZFXmlOutputElementChildNeedNewLine(*data.xmlItem, flags, data))
             {
                 this->add(flags.xmlToken.xmlNewLineToken);
                 this->add(flags.xmlGlobalLineBeginToken);
                 this->addIndent(flags.xmlToken.xmlIndentToken, data.depth);
             }
             if(data.xmlItem->xmlTextCDATA())
             {
                 this->add(flags.xmlToken.xmlTextCDATATagLeft);
             }
             this->addEncoded(data.xmlItem->xmlValue());
             break;
         case ZFXmlVisitType::e_Exit:
             if(data.xmlItem->xmlTextCDATA())
             {
                 this->add(flags.xmlToken.xmlTextCDATATagRight);
             }
             if(_ZFP_ZFXmlOutputElementChildNeedNewLine(*data.xmlItem, flags, data))
             {
                 this->add(flags.xmlToken.xmlNewLineToken);
                 this->add(flags.xmlGlobalLineBeginToken);
                 this->addIndent(flags.xmlToken.xmlIndentToken, data.depth - 1);
             }
             break;
         case ZFXmlVisitType::e_ExitChildren:
         default:
             zfCoreCriticalShouldNotGoHere();
             break;
     }
     return zftrue;
 }
    virtual ZFFileToken fileOpen(ZF_IN const zfchar *filePath,
                                 ZF_IN_OPT ZFFileOpenOptionFlags flag = ZFFileOpenOption::e_Read)
    {
        const zfcharA *sFlag = zfnull;
        if(ZFBitTest(flag, ZFFileOpenOption::e_Append))
        {
            if(ZFBitTest(flag, ZFFileOpenOption::e_Read))
            {
                sFlag = zfTextA("a+b");
            }
            else
            {
                sFlag = zfTextA("ab");
            }
        }
        else if(ZFBitTest(flag, ZFFileOpenOption::e_Create))
        {
            if(ZFBitTest(flag, ZFFileOpenOption::e_Read))
            {
                sFlag = zfText("w+b");
            }
            else
            {
                sFlag = zfText("wb");
            }
        }
        else if(ZFBitTest(flag, ZFFileOpenOption::e_Write))
        {
            if(ZFBitTest(flag, ZFFileOpenOption::e_Read))
            {
                sFlag = zfTextA("r+b");
            }
            else
            {
                sFlag = zfTextA("wb");
            }
        }
        else if(ZFBitTest(flag, ZFFileOpenOption::e_Read))
        {
            sFlag = zfTextA("rb");
        }
        else
        {
            zfCoreCriticalShouldNotGoHere();
            return ZFFileTokenInvalid;
        }

        #if ZF_ENV_sys_Windows
            zfstringW _filePathSaved = ZFStringZ2W(filePath);
            DWORD _fileAttrSaved = ::GetFileAttributesW(_filePathSaved.cString());
            ::SetFileAttributesW(_filePathSaved.cString(), FILE_ATTRIBUTE_NORMAL);
        #endif

        ZFFileToken ret = (ZFFileToken)(::fopen(ZFStringZ2A(filePath), sFlag));

        #if ZF_ENV_sys_Windows
            ::SetFileAttributesW(_filePathSaved.cString(), _fileAttrSaved);
        #endif

        return ret;
    }
zfbool ZFClassFilter::filterCheckActive(ZF_IN const ZFClass * const &e) const
{
    if(e == zfnull)
    {
        return zffalse;
    }

    for(zfindex i = 0, count = this->_ZFP_ZFClassFilter_customFilterCallbacks.count(); i < count; ++i)
    {
        switch(this->_ZFP_ZFClassFilter_customFilterCallbacks.get(i)(e))
        {
            case ZFFilterCallbackResultNotSpecified:
                break;
            case ZFFilterCallbackResultActive:
                return zftrue;
            case ZFFilterCallbackResultNotActive:
                return zffalse;
            default:
                zfCoreCriticalShouldNotGoHere();
                break;
        }
    }

    zfbool hasIncludeMode = zffalse;
    zfbool included = zffalse;
    for(zfindex i = 0, count = this->_ZFP_ZFClassFilter_filters.count(); i < count; ++i)
    {
        const _ZFP_ZFClassFilterData &filter = this->_ZFP_ZFClassFilter_filters.get(i);
        switch(filter.filterType)
        {
            case ZFClassFilterTypeInclude:
                hasIncludeMode = zftrue;
                if(filter.filterClass == e)
                {
                    included = zftrue;
                }
                break;
            case ZFClassFilterTypeExclude:
                if(filter.filterClass == e)
                {
                    return zffalse;
                }
                break;
            case ZFClassFilterTypeIncludeChildOf:
                if(!e->classIsSubclassOf(filter.filterClass))
                {
                    return zffalse;
                }
                break;
            case ZFClassFilterTypeIncludeChildTypeOf:
                if(!e->classIsTypeOf(filter.filterClass))
                {
                    return zffalse;
                }
                break;
            case ZFClassFilterTypeIncludeParentOf:
                if(!filter.filterClass->classIsSubclassOf(e))
                {
                    return zffalse;
                }
                break;
            case ZFClassFilterTypeIncludeParentTypeOf:
                if(!filter.filterClass->classIsTypeOf(e))
                {
                    return zffalse;
                }
                break;
            case ZFClassFilterTypeExcludeChildOf:
                if(e->classIsSubclassOf(filter.filterClass))
                {
                    return zffalse;
                }
                break;
            case ZFClassFilterTypeExcludeChildTypeOf:
                if(e->classIsTypeOf(filter.filterClass))
                {
                    return zffalse;
                }
                break;
            case ZFClassFilterTypeExcludeParentOf:
                if(filter.filterClass->classIsSubclassOf(e))
                {
                    return zffalse;
                }
                break;
            case ZFClassFilterTypeExcludeParentTypeOf:
                if(filter.filterClass->classIsTypeOf(e))
                {
                    return zffalse;
                }
                break;
            default:
                zfCoreCriticalShouldNotGoHere();
                return zffalse;
        }
    }
    return (!hasIncludeMode || included);
}
Exemple #20
0
 zfbool onVisitXmlElement(ZF_IN const ZFXmlVisitData &data)
 {
     switch(data.xmlVisitType)
     {
         case ZFXmlVisitType::e_Enter:
             if(data.depth > 0 || data.siblingIndex > 0)
             {
                 this->add(flags.xmlToken.xmlNewLineToken);
             }
             this->add(flags.xmlGlobalLineBeginToken);
             if((data.depth > 0 && data.siblingIndex > 0) && flags.xmlElementAddNewLineAtHeadIfNotSingleLine
                 && (_ZFP_ZFXmlOutputElementAttributeNeedNewLine(*data.xmlItem, flags, data)
                     || _ZFP_ZFXmlOutputElementChildNeedNewLine(data.xmlItem->xmlChildFirst(), flags, data)))
             {
                 this->add(flags.xmlToken.xmlNewLineToken);
                 this->add(flags.xmlGlobalLineBeginToken);
             }
             this->addIndent(flags.xmlToken.xmlIndentToken, data.depth);
             if(_ZFP_ZFXmlOutputElementUseSingleTag(*data.xmlItem, flags, data))
             {
                 this->add(flags.xmlToken.xmlElementSingleTagLeft);
             }
             else
             {
                 this->add(flags.xmlToken.xmlElementBeginTagLeft);
             }
             this->add(data.xmlItem->xmlName());
             break;
         case ZFXmlVisitType::e_Exit:
             if(!data.xmlItem->xmlAttributeFirst().xmlIsNull())
             {
                 this->add(zfText(" "));
             }
             if(_ZFP_ZFXmlOutputElementUseSingleTag(*data.xmlItem, flags, data))
             {
                 this->add(flags.xmlToken.xmlElementSingleTagRight);
             }
             else
             {
                 this->add(flags.xmlToken.xmlElementBeginTagRight);
             }
             break;
         case ZFXmlVisitType::e_ExitChildren:
             if(!_ZFP_ZFXmlOutputElementUseSingleTag(*data.xmlItem, flags, data))
             {
                 if(_ZFP_ZFXmlOutputElementChildNeedNewLine(data.xmlItem->xmlChildFirst(), flags, data)
                     || _ZFP_ZFXmlOutputElementAttributeNeedNewLine(*data.xmlItem, flags, data))
                 {
                     this->add(flags.xmlToken.xmlNewLineToken);
                     this->add(flags.xmlGlobalLineBeginToken);
                     this->addIndent(flags.xmlToken.xmlIndentToken, data.depth);
                 }
                 this->add(flags.xmlToken.xmlElementEndTagLeft);
                 this->add(data.xmlItem->xmlName());
                 this->add(flags.xmlToken.xmlElementEndTagRight);
             }
             break;
         default:
             zfCoreCriticalShouldNotGoHere();
             break;
     }
     return zftrue;
 }
static void _ZFP_ZFUILinearLayout_layoutVertical(ZF_IN ZFUILinearLayout *parent,
                                                 ZF_IN const ZFUISize &size,
                                                 ZF_IN zfbool positiveDirection)
{
    zfint requiredSize = 0;
    zfint totalWeight = 0;
    zfbool hasLayoutedChild = zffalse;
    zfint parentMarginX = ZFUIMarginGetX(parent->layoutChildMargin());
    zfint parentMarginY = ZFUIMarginGetY(parent->layoutChildMargin());
    for(zfindex i = 0; i < parent->childCount(); ++i)
    {
        ZFUIView *child = parent->childAtIndex(i);
        ZFUILinearLayoutParam *layoutParam = child->layoutParamT();
        if(!child->viewVisible() && !layoutParam->layoutReserveSpaceWhenNotVisible())
        {
            continue ;
        }
        zfint prevSpace = (hasLayoutedChild ? parent->layoutChildSpace() : 0);
        hasLayoutedChild = zftrue;

        zfint marginX = parentMarginX + ZFUIMarginGetX(layoutParam->layoutMargin());
        zfint marginY = parentMarginY + ZFUIMarginGetY(layoutParam->layoutMargin());
        if(layoutParam->layoutWeight() > 0)
        {
            totalWeight += layoutParam->layoutWeight();
        }
        else
        {
            switch(layoutParam->sizeParam().height)
            {
                case ZFUISizeType::e_Wrap:
                {
                    child->layoutMeasure(
                        ZFUISizeMake(
                            ZFUIViewLayoutParam::sizeHintMerge(
                                layoutParam->sizeHint().width,
                                ZFUIViewLayoutParam::sizeHintOffset(size.width, -marginX)),
                            layoutParam->sizeHint().height),
                        layoutParam->sizeParam());
                    requiredSize += child->layoutMeasuredSize().height;
                }
                    break;
                case ZFUISizeType::e_Fill:
                    requiredSize = size.height;
                    break;
                default:
                    zfCoreCriticalShouldNotGoHere();
                    return ;
            }
        }

        requiredSize += prevSpace + marginY;
    }
    hasLayoutedChild = zffalse;
    zfint flexibleSize = zfmMax(0, size.height - requiredSize);
    zfint offset = (positiveDirection ? 0 : size.height);
    for(zfindex i = 0; i < parent->childCount(); ++i)
    {
        ZFUIView *child = parent->childAtIndex(i);
        ZFUILinearLayoutParam *layoutParam = child->layoutParamT();
        if(!child->viewVisible() && !layoutParam->layoutReserveSpaceWhenNotVisible())
        {
            continue ;
        }
        zfint prevSpace = (hasLayoutedChild ? parent->layoutChildSpace() : 0);
        hasLayoutedChild = zftrue;

        zfint marginX = parentMarginX + ZFUIMarginGetX(layoutParam->layoutMargin());
        zfint marginY = parentMarginY + ZFUIMarginGetY(layoutParam->layoutMargin());
        zfint totalUsedSpace = prevSpace + marginY;
        if(layoutParam->layoutWeight() > 0)
        {
            child->layoutMeasure(
                ZFUISizeMake(
                    ZFUIViewLayoutParam::sizeHintMerge(
                        layoutParam->sizeHint().width,
                        ZFUIViewLayoutParam::sizeHintOffset(size.width, -marginX)),
                    ZFUIViewLayoutParam::sizeHintMerge(flexibleSize * layoutParam->layoutWeight() / totalWeight, layoutParam->sizeHint().height)
                ),
                ZFUISizeParamMake(
                    layoutParam->sizeParam().width,
                    ZFUISizeType::e_Fill
                ));
            flexibleSize -= child->layoutMeasuredSize().height;
            totalWeight -= layoutParam->layoutWeight();
        }
        else
        {
            if(layoutParam->sizeParam().height == ZFUISizeType::e_Fill)
            {
                child->layoutMeasure(
                    ZFUISizeMake(
                        ZFUIViewLayoutParam::sizeHintMerge(
                            layoutParam->sizeHint().width,
                            ZFUIViewLayoutParam::sizeHintOffset(size.width, -marginX)),
                        ZFUIViewLayoutParam::sizeHintMerge(
                            layoutParam->sizeHint().height,
                            positiveDirection ? zfmMax(size.height - offset - totalUsedSpace, 0) : zfmMax(offset - totalUsedSpace, 0))
                    ),
                    layoutParam->sizeParam());
            }
        }
        if(positiveDirection)
        {
            child->layout(ZFUIAlignApply(
                layoutParam->layoutAlign(),
                ZFUIRectMake(0, offset + prevSpace, size.width, child->layoutMeasuredSize().height + marginY),
                child->layoutMeasuredSize(),
                layoutParam->layoutMargin() + parent->layoutChildMargin()));
            offset += prevSpace + child->layoutMeasuredSize().height + marginY;
        }
        else
        {
            offset -= child->layoutMeasuredSize().height + marginY + prevSpace;
            child->layout(ZFUIAlignApply(
                layoutParam->layoutAlign(),
                ZFUIRectMake(0, offset, size.width, child->layoutMeasuredSize().height + marginY),
                child->layoutMeasuredSize(),
                layoutParam->layoutMargin() + parent->layoutChildMargin()));
        }
    }
}
static void _ZFP_ZFUIFlowLayout_layoutVertical(ZF_IN ZFUIFlowLayout *parent,
                                               ZF_IN const ZFUISize &size,
                                               ZF_IN zfbool positiveDirection)
{
    zfindex wrapIndex = 0;
    zfint lineSizeUsed = 0;
    while(wrapIndex < parent->childCount()) // for each line
    {
        zfint requiredSize = 0;
        zfint totalWeight = 0;
        zfbool hasLayoutedChild = zffalse;
        zfint parentMarginX = ZFUIMarginGetX(parent->layoutChildMargin());
        zfint parentMarginY = ZFUIMarginGetY(parent->layoutChildMargin());
        zfindex wrapIndexTmp = parent->childCount();
        zfint lineSize = 0;
        zfint prevLineSpace = (wrapIndex > 0 ? parent->layoutChildSpaceX() : 0);
        zfint flexableWrapSize = 0;
        for(zfindex i = wrapIndex; i < parent->childCount(); ++i)
        {
            ZFUIView *child = parent->childAtIndex(i);
            ZFUIFlowLayoutParam *layoutParam = child->layoutParamT();
            if(!child->viewVisible() && !layoutParam->layoutReserveSpaceWhenNotVisible())
            {
                continue ;
            }
            zfint prevSpace = (hasLayoutedChild ? parent->layoutChildSpaceY() : 0);
            hasLayoutedChild = zftrue;

            zfint marginX = parentMarginX + ZFUIMarginGetX(layoutParam->layoutMargin());
            zfint marginY = parentMarginY + ZFUIMarginGetY(layoutParam->layoutMargin());
            zfint childRequiredSize = 0;
            if(layoutParam->layoutWeight() > 0)
            {
                child->layoutMeasure(
                    ZFUISizeMake(
                        ZFUIViewLayoutParam::sizeHintMerge(
                            layoutParam->sizeHint().width,
                            ZFUIViewLayoutParam::sizeHintOffset(size.width, 0 - lineSizeUsed - marginX - prevLineSpace)),
                        layoutParam->sizeHint().height),
                    layoutParam->sizeParam());
                childRequiredSize += child->layoutMeasuredSize().height;
            }
            else
            {
                switch(layoutParam->sizeParam().height)
                {
                    case ZFUISizeType::e_Wrap:
                        child->layoutMeasure(
                            ZFUISizeMake(
                                ZFUIViewLayoutParam::sizeHintMerge(
                                    layoutParam->sizeHint().width,
                                    ZFUIViewLayoutParam::sizeHintOffset(size.width, 0 - lineSizeUsed - marginX - prevLineSpace)),
                                layoutParam->sizeHint().height),
                            layoutParam->sizeParam());
                        childRequiredSize += child->layoutMeasuredSize().height;
                        break;
                    case ZFUISizeType::e_Fill:
                        child->layoutMeasure(
                            ZFUISizeMake(
                                ZFUIViewLayoutParam::sizeHintMerge(
                                    layoutParam->sizeHint().width,
                                    ZFUIViewLayoutParam::sizeHintOffset(size.width, 0 - lineSizeUsed - marginX - prevLineSpace)),
                                layoutParam->sizeHint().height),
                            layoutParam->sizeParam());
                        childRequiredSize = zfmMax(
                            child->layoutMeasuredSize().height,
                            size.height - requiredSize - prevSpace - marginY);
                        break;
                    default:
                        zfCoreCriticalShouldNotGoHere();
                        return ;
                }
            }
            childRequiredSize += prevSpace + marginY;
            if(i > wrapIndex && requiredSize + childRequiredSize > size.height)
            {
                wrapIndexTmp = i;
                break;
            }

            if(layoutParam->layoutWeight() > 0)
            {
                flexableWrapSize += childRequiredSize;
            }
            requiredSize += childRequiredSize;
            lineSize = zfmMax(lineSize, child->layoutMeasuredSize().width + marginX);
            if(layoutParam->layoutWeight() > 0)
            {
                totalWeight += layoutParam->layoutWeight();
            }
            if(requiredSize >= size.height)
            {
                wrapIndexTmp = i + 1;
                break;
            }
        }
        hasLayoutedChild = zffalse;
        zfint flexibleSize = zfmMax(0, size.height - requiredSize + flexableWrapSize);
        zfint offset = (positiveDirection ? 0 : size.height);
        zfint lineX = ((_ZFP_ZFUIFlowLayout_layoutOrientationSecondary(
                parent->layoutOrientationMain(), parent->layoutOrientationSecondary()) == ZFUIOrientation::e_Left)
            ? lineSizeUsed + prevLineSpace
            : size.width - lineSizeUsed - lineSize - prevLineSpace);
        for(zfindex i = wrapIndex; i < wrapIndexTmp; ++i)
        {
            ZFUIView *child = parent->childAtIndex(i);
            ZFUIFlowLayoutParam *layoutParam = child->layoutParamT();
            if(!child->viewVisible() && !layoutParam->layoutReserveSpaceWhenNotVisible())
            {
                continue ;
            }
            zfint prevSpace = (hasLayoutedChild ? parent->layoutChildSpaceY() : 0);
            hasLayoutedChild = zftrue;

            zfint marginX = parentMarginX + ZFUIMarginGetX(layoutParam->layoutMargin());
            zfint marginY = parentMarginY + ZFUIMarginGetY(layoutParam->layoutMargin());
            zfint totalUsedSpace = prevSpace + marginY;
            if(layoutParam->layoutWeight() > 0)
            {
                child->layoutMeasure(
                    ZFUISizeMake(
                        ZFUIViewLayoutParam::sizeHintMerge(
                            layoutParam->sizeHint().width,
                            ZFUIViewLayoutParam::sizeHintOffset(size.width, 0 - lineSizeUsed - marginX - prevLineSpace)),
                        ZFUIViewLayoutParam::sizeHintMerge(flexibleSize * layoutParam->layoutWeight() / totalWeight, layoutParam->sizeHint().height)
                        ),
                    ZFUISizeParamMake(
                        layoutParam->sizeParam().width,
                        ZFUISizeType::e_Fill
                        ));
                flexibleSize -= child->layoutMeasuredSize().height;
                totalWeight -= layoutParam->layoutWeight();
            }
            else
            {
                if(layoutParam->sizeParam().height == ZFUISizeType::e_Fill)
                {
                    child->layoutMeasure(
                        ZFUISizeMake(
                            ZFUIViewLayoutParam::sizeHintMerge(
                                layoutParam->sizeHint().width,
                                ZFUIViewLayoutParam::sizeHintOffset(size.width, 0 - lineSizeUsed - marginX - prevLineSpace)),
                            ZFUIViewLayoutParam::sizeHintMerge(
                                layoutParam->sizeHint().height,
                                positiveDirection ? zfmMax(size.height - offset - totalUsedSpace, 0) : zfmMax(offset - totalUsedSpace, 0))
                            ),
                        layoutParam->sizeParam());
                }
            }
            if(positiveDirection)
            {
                child->layout(ZFUIAlignApply(
                    layoutParam->layoutAlign(),
                    ZFUIRectMake(lineX, offset + prevSpace, lineSize, child->layoutMeasuredSize().height + marginY),
                    child->layoutMeasuredSize(),
                    layoutParam->layoutMargin() + parent->layoutChildMargin()));
                offset += prevSpace + child->layoutMeasuredSize().height + marginY;
            }
            else
            {
                offset -= child->layoutMeasuredSize().height + marginY + prevSpace;
                child->layout(ZFUIAlignApply(
                    layoutParam->layoutAlign(),
                    ZFUIRectMake(lineX, offset, lineSize, child->layoutMeasuredSize().height + marginY),
                    child->layoutMeasuredSize(),
                    layoutParam->layoutMargin() + parent->layoutChildMargin()));
            }
        } // for(zfindex i = wrapIndex; i < wrapIndexTmp; ++i)
        wrapIndex = wrapIndexTmp;
        lineSizeUsed += lineSize + prevLineSpace;
    } // for each line
}