class  CBrokField : public CObject
{
protected:
int m_ID;
CString m_name; //字段名
CString m_title; //字段标题
CString m_type; //字段数据类型
int m_iType;
int m_length; //字段长度
int m_choice; //选择链接
CString m_describe; //字段描述 CDWordArray m_choiceID; //选择对象ID
CStringArray m_choices; //选择链接public:
CBrokField(int ID, CString name, CString title, CString type, int length, int choice, CString decribe) 
{
m_ID = ID;
m_name = name; //字段名
m_name.TrimLeft();
m_name.TrimRight();
m_title = title; //字段标题
m_type = type; //字段数据类型
m_length = length; //字段长度
m_choice = choice; //选择链接
m_describe = decribe; //字段描述 if (m_type=="整数")
m_iType = 1;
else if (m_type=="浮点数")
m_iType = 2;
else if (m_type=="字符串")
m_iType = 0;
else m_iType = 0;
} ~CBrokField() 
{
m_choiceID.RemoveAll();
m_choices.RemoveAll();
} int GetID(){return m_ID;}
CString GetName(){return m_name;}
CString GetTitle(){return m_title;}
CString GetType(){return m_type;}
int GetLength(){return m_length;}
int GetChoice(){return m_choice;}
CString GetDescribe(){return m_describe;} int GetChoices(){return m_choiceID.GetSize();}
int GetChoiceID(int nIndex )
{
if (nIndex<m_choiceID.GetSize())
return m_choiceID.GetAt(nIndex);
return 0;
}
void AddChoiceID(int ID){m_choiceID.Add(ID);}
CString GetChoice(int nIndex )
{
if (nIndex<m_choices.GetSize())
return m_choices.GetAt(nIndex);
return "";
}
void AddChoice(CString choice){m_choices.Add(choice);}
};

解决方案 »

  1.   

    CString,CDWordArray,CStringArray 几个类也要转换才行type
    TString=class(TObject)
    private
      FText:string;
    public
      procedure TrimLeft;
      procedure TrimRight;
      property Text:string read FText write FText;
    end;
    procedure TString.TrimLeft;
    begin
    end;
    procedure TString.TrimRight;
    begin
    end;type
    TDWordArray=class(TObject)
    public
      procedure RemoveAll();
      function GetSize():Integer;
      function GetAt(nIndex:Integer):DWORD;
      procedure Add(AValue:DWORD);
    end;
    procedure TDWordArray.RemoveAll();
    begin
    end;
    function TDWordArray.GetSize():Integer;
    begin
      Result:=0;/////
    end;
    function TDWordArray.GetAt(nIndex:Integer):DWORD;
    begin
      Result:=0;/////
    end;
    procedure TDWordArray.Add(AValue:DWORD);
    begin
    end;type
    TStringArray=class(TObject)
    public
      procedure RemoveAll();
      function GetSize():Integer;
      function GetAt(nIndex:Integer):TString;
      procedure Add(AString:TString);
    end;
    procedure TStringArray.RemoveAll();
    begin
    end;
    function TStringArray.GetSize():Integer;
    begin
      Result:=0;/////
    end;
    function TStringArray.GetAt(nIndex:Integer):TString;
    begin
      Result:=nil;/////
    end;
    procedure TStringArray.Add(AString:TString);
    begin
    end;type
    TBrokField=class(TObject)
      protected
    m_ID:Integer;
    m_name:TString; //字段名
    m_title:TString; //字段标题
    m_type:TString; //字段数据类型
    m_iType:Integer;
    m_length:Integer; //字段长度
    m_choice:Integer; //选择链接
    m_describe:TString; //字段描述 m_choiceID:TDWordArray; //选择对象ID
    m_choices:TStringArray; //选择链接public
    constructor Create(ID:Integer;name:TString;title:TString;atype:TString;
        length:Integer;choice:Integer;decribe:TString);reintroduce;
      destructor Destroy;override; function GetID():Integer;
    function GetName():TString;
    function GetTitle():TString;
    function GetType():TString;
    function GetLength():Integer;
    function GetChoice():Integer;overload;
    function GetDescribe():TString; function GetChoices():Integer;
    function GetChoiceID(nIndex:Integer):Integer;
    procedure AddChoiceID(ID:Integer);
    function GetChoice(nIndex:Integer):TString;overload;
    procedure AddChoice(choice:TString);
    end;constructor TBrokField.Create(ID:Integer;name:TString;title:TString;
      atype:TString;length:Integer;choice:Integer;decribe:TString);
    begin
      inherited Create;
      m_ID := ID;
      m_name := name; //字段名
      m_name.TrimLeft();
      m_name.TrimRight();
      m_title := title; //字段标题
      m_type := atype; //字段数据类型
      m_length := length; //字段长度
      m_choice := choice; //选择链接
      m_describe := decribe; //字段描述  if (m_type.Text='整数') then
    m_iType := 1
    else if (m_type.Text='浮点数') then
    m_iType := 2
    else if (m_type.Text='字符串') then
    m_iType := 0
    else m_iType := 0;
    end;destructor TBrokField.Destroy;
    begin
    m_choiceID.RemoveAll();
    m_choices.RemoveAll();
    end;
    function TBrokField.GetID():Integer;
    begin
      Result:= m_ID;
    end;
    function TBrokField.GetName():TString;
    begin
      Result:=m_name;
    end;
    function TBrokField.GetTitle():TString;
    begin
      Result:=m_title;
    end;
    function TBrokField.GetType():TString;
    begin
      Result:=m_type;
    end;
    function TBrokField.GetLength():Integer;
    begin
      Result:=m_length;
    end;
    function TBrokField.GetChoice():Integer;
    begin
      Result:=m_choice;
    end;
    function TBrokField.GetDescribe():TString;
    begin
      Result:= m_describe;
    end;
    function TBrokField.GetChoices():Integer;
    begin
      Result:=m_choiceID.GetSize();
    end;
    function TBrokField.GetChoiceID(nIndex:Integer):Integer;
    begin
      Result:=0;
    if (nIndex<m_choiceID.GetSize()) then
    Result:=m_choiceID.GetAt(nIndex);
    end;
    procedure TBrokField.AddChoiceID(ID:Integer);
    begin
      m_choiceID.Add(ID);
    end;
    function TBrokField.GetChoice(nIndex:Integer):TString;
    begin
      Result:=nil;
    if (nIndex<m_choices.GetSize()) then
    Result:=m_choices.GetAt(nIndex);
    end;
    procedure TBrokField.AddChoice(choice:TString);
    begin
      m_choices.Add(choice);
    end;