使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 4905e2e7537d507f218e8e9595485e09d9f3a2b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include "StdAfx.h"
#include "MBGridStyleAttrMgr2.h"
 
#include "json.h"
 
IMPLEMENT_DYNAMIC(CMBGridStyleAttrMgr2, CMBAbstBaseObj)
 
CMBGridStyleAttrMgr2::CMBGridStyleAttrMgr2(void)
{
    RemoveAllAttr();
}
 
 
CMBGridStyleAttrMgr2::~CMBGridStyleAttrMgr2(void)
{
    RemoveAllAttr();
}
 
 
void        CMBGridStyleAttrMgr2::GetAttrMap( CMBGridStyleAttrMap &mapAttr)
{
    mapAttr.clear();
    mapAttr = m_mapAttr;
}
 
void    CMBGridStyleAttrMgr2::GetAttrVector( CMBGridStyleAttrVector &vectorAttr)
{
    vectorAttr.clear();
    vectorAttr = m_vectorAttr;
}
 
CMBGridStyleAttr *CMBGridStyleAttrMgr2::GetAttr( CString strAttr ) 
{
    if( strAttr.IsEmpty() )
        return NULL;
 
    CMBGridStyleAttrMap::iterator    it; 
    CMBGridStyleAttr *pAttr  = NULL;
 
    it = m_mapAttr.find(strAttr);
 
    if( it!= m_mapAttr.end() )
        pAttr = it->second;
 
    return pAttr;  
}
 
bool    CMBGridStyleAttrMgr2::AddAttr( CMBGridStyleAttr *pAttr )
{
    if( NULL ==  pAttr || pAttr->m_strAttr.IsEmpty() )
        return false;
 
    CMBGridStyleAttrMap::iterator    it;  
    CString strName;
 
    strName = pAttr->m_strAttr;
    it = m_mapAttr.find(strName);
 
    // Èç¹ûÕҵõ½ ·µ»Ø
    if( it != m_mapAttr.end() )
        return false;
 
    m_mapAttr[strName] = pAttr; 
 
    m_vectorAttr.push_back(pAttr);
 
    return true;
}
 
bool    CMBGridStyleAttrMgr2::RemoveAllAttr()
{
    CMBGridStyleAttrMap::iterator    it; 
    CMBGridStyleAttr *pAttr  = NULL;
 
    for( it = m_mapAttr.begin();it != m_mapAttr.end();it++ )
    {
        pAttr = it->second;
        delete pAttr;
        pAttr = NULL;        
    }
 
    m_mapAttr.clear();
    m_vectorAttr.clear();
     
    return true;    
}
 
 
int  CMBGridStyleAttrMgr2::GetIndex( CString strAttr )
{
    int nSize = m_vectorAttr.size();
    for( int i= 0;i < nSize;i++ )
    {
        CMBGridStyleAttr *pAttr =    m_vectorAttr[i];
        if( pAttr->m_strAttr == strAttr )
            return i;
    }
    return -1;
}
 
bool CMBGridStyleAttrMgr2::ParseJson( CString strCfgPath,CString &strErrInfo )
{
    CString strGridStyle,strJsonContent,strWidth;
    Json::Reader reader;
    Json::Value json_object;
    Json::Value json_cell;
    Json::Value json_attr;
    string json,attr,showName,width;    
 
    strGridStyle.Format(_T("%s\\GridStyle.json"),strCfgPath);
    // ¶ÁÎļþÄÚÈÝ
    if(! CStrFileUtils::GetStrFromFile(strGridStyle,strJsonContent))
    {
        strErrInfo = _T("¶ÁÎļþ ") + strGridStyle + _T(" Ê§°Ü£¡");
        return false;
    }
     
    json = CT2A(strJsonContent);
  
    if (!reader.parse(json, json_object)){
         strErrInfo = strGridStyle+ _T(" ·Çjson¸ñʽ£¡");
         return false;
    }
 
    json_cell     = json_object["Cell"] ;
    if( json_cell.isArray() )
    {
         
        int nSize = json_cell.size();
        for( int i =0;i<nSize;i++ )
        {
             json_attr = json_cell[i];
              
             CMBGridStyleAttr *pAttr = new CMBGridStyleAttr();
             attr       = json_attr["Attr"].asString();    
             showName   = json_attr["ShowName"].asString();  
             width        = json_attr["Width"].asString();
 
             pAttr->m_strAttr     = CA2T(attr.c_str());
             pAttr->m_strShowName = CA2T(showName.c_str());    
             strWidth              = CA2T(width.c_str());      
             pAttr->m_nWidth       = _ttoi(strWidth);
                
             if( !AddAttr(pAttr) )
             {
                delete pAttr;
                pAttr = NULL;
             }
        }// end for 
    } 
    return true;
}