Exemple #1
0
static bool AddField_Helper( const CString& dictName, const CString& type, const CString& field )
{
    ArxDictTool* pDictTool = ArxDictTool::GetDictTool( dictName );
    int index = pDictTool->addEntry( type, field );
    delete pDictTool;
    return ( index != INVALID_ENTRY );
}
bool DataObjectListHelper::AddObject( const CString& name, const CString& value )
{
    if( name.GetLength() == 0 || value.GetLength() == 0 ) return false;

    ArxDictTool* pDictTool = ArxDictTool::GetDictTool( OBJECT_LIST_DICT );
    bool ret = ( INVALID_ENTRY != pDictTool->addEntry( name, value ) );
    if( ret )
    {
        ArxDictTool2* pDictTool2 = ArxDictTool2::GetDictTool( OBJECT_LIST_DATA_DICT );
        CString key;
        key.Format( _T( "%s_%s" ), name, value );

        DataObject* pDO = new DataObject();
        pDO->setType( name );
        pDO->initData();  // 初始化数据
        ret = pDictTool2->addEntry( key, pDO );
        if( !ret ) // 添加Object失败
        {
            delete pDO;
            pDictTool->removeEntry( name, value );
        }
        delete pDictTool2;
    }
    delete pDictTool;

    return ret;
}
Exemple #3
0
bool ArxDictHelper::AddEntry( const CString& dictName, const CString& key, const CString& entry )
{
    ArxDictTool* pDictTool = ArxDictTool::GetDictTool( dictName );
    bool ret = ( INVALID_ENTRY != pDictTool->addEntry( key, entry ) );
    delete pDictTool;
    return ret;
}
bool IntStrListHelper::AddIntStrList( const CString& name, const AcDbIntArray& intList, const AcStringArray& strList )
{
    if( ( name.GetLength() == 0 ) || strList.isEmpty() || intList.isEmpty() ) return false;
    if( intList.length() != strList.length() ) return false;

    ArxDictTool* pDictTool = ArxDictTool::GetDictTool( INT_LIST_DICT );
    bool ret = pDictTool->findKey( name );
    if( !ret )
    {
        int len = intList.length();
        for( int i = 0; i < len; i++ )
        {
            CString intValue;
            intValue.Format( _T( "%d" ), intList[i] );
            pDictTool->addEntry( name, intValue );             // 偶数位置的元素为整数
            pDictTool->addEntry( name, strList[i].kACharPtr() ); // 奇数位置的元素为字符串
        }
    }
    delete pDictTool;
    return !ret;
}
bool StringListHelper::AddStringList( const CString& name, const AcStringArray& strList )
{
    if( ( name.GetLength() == 0 ) || strList.isEmpty() ) return false;

    ArxDictTool* pDictTool = ArxDictTool::GetDictTool( STRING_LIST_DICT );
    bool ret = pDictTool->findKey( name );
    if( !ret ) // 如果变量name已存在,则不进行修改
    {
        int len = strList.length();
        for( int i = 0; i < len; i++ )
        {
            pDictTool->addEntry( name, strList[i].kACharPtr() );
        }
    }
    delete pDictTool;
    return !ret;
}