调查统计员(源码5)

// ****************************************************************************
//  Investigator_Base.h   version:  1.0     date: 12/09/2005
//  ---------------------------------------------------------------------------
//  Summary:
//  ---------------------------------------------------------------------------
//  Copyright (C) LYH_Studio @ 2005 - All Rights Reserved
// ****************************************************************************
//
// ****************************************************************************


#ifndef _LYH_STUDIO_INVESTIGATOR_BASE
#define _LYH_STUDIO_INVESTIGATOR_BASE

//include file
#include <string>
using namespace std;
#include "InvtString.h"

namespace Investigator
{
 
#define ASSERT(a)     a == true
 //#define WINDOWWIDTH        80
 
 //class define
 /*this class is the base class of generation of Investigator
 *you can find some useful functions in it.Including InvtChar(char),InvtString(string)
 *thE deriver of this class shoud contain functions like DrawAmountPic() and so on.
 */
 class Investigator_Base
 {
 public :
  Investigator_Base();
  Investigator_Base(const string &strData, const string &strCI);
  virtual ~Investigator_Base();
  
  /*------------------>Function @ SetData @ discription <-----------------------*
  *@name: inline int SetData(const string &strData) throw(char*);               *
  *@parameter: const string &strData                                            *
  *@purpose: set choises to member value m_strData                              *
  *@return value:int                                                            *
  *-----------------------------------------------------------------------------*/
  inline int SetData(const string &strData) throw(char*);
  
  /*--------------->Function @ SetCharInvt @ discription <----------------------*
  *@name:inline int SetCharInvt(const string &strCI) throw(char*);              *
  *@parameter: const string &strCI                                              *
  *@purpose: set choises elements to member value m_strCI                       *
  *@return value: int                                                           *
  *-----------------------------------------------------------------------------*/
  inline int SetCharInvt(const string &strCI) throw(char*);
  
  
  /*----------------->Function @ InvtChar @ discription <-----------------------*
  *@name:int InvtChar(char cChr)  const throw() ;                               *
  *@parameter: char cChr                                                        *
  *@purpose: investigate the amount of choice cChr                              *
  *@return value: int                                                           *
  *-----------------------------------------------------------------------------*/
  int InvtChar(char cChr)  const throw() ;
  
  /*------------------>Function @ InvtStr @ discription <-----------------------*
  *@name:int stringEx(const string &strData) const throw() ;                    *
  *@parameter: const string &strData                                            *
  *@purpose: investigate the amount of choice strData                           *
  *@return value: int                                                           *
  *-----------------------------------------------------------------------------*/
  int InvtStr(const string &strData) const throw() ;
  
  
  //------------------------->   virtual functions  <---------------------------//
  
  /*--------------->Function @ InvtAndNotice @ discription <--------------------*
  *@name:virtual bool                                                           *
  InvtAndNotice(const stringEx &strItemShow) throw(char*) = 0;                  *
  *@parameter: const stringEx &strItemShow                                      *
  *@purpose: show statistic result in characters                                *
  *@return value: bool                                                          *
  *-----------------------------------------------------------------------------*/
  virtual bool InvtAndNotice(const stringEx &strItemShow) throw(char*) = 0;
  
  /*--------------->Function @ InvtAndDrawMast @ discription <------------------*
  *@name:virtual bool                                                           *
  InvtAndDrawMast(const stringEx &strItemShow) throw(char*) = 0;*
  *@parameter:const stringEx &strItemShow                               *
  *@purpose: show statistic result in Mast                                      *
  *@return value:bool                                                           *
  *-----------------------------------------------------------------------------*/
  virtual bool InvtAndDrawMast(const stringEx &strItemShow) throw(char*) = 0;
  
  /*--------------->Function @ InvtAnd_N_DM @ discription <---------------------*
  *@name: virtual bool                                                          *
  InvtAnd_N_DM(const stringEx &strItemShow) throw(char*) = 0;*
  *@parameter: const stringEx &strItemShow                              *
  *@purpose: show statistic result in Mast and characters                       *
  *@return value: bool                                                          *
  *-----------------------------------------------------------------------------*/
  virtual bool InvtAnd_N_DM(const stringEx &strItemShow) throw(char*) = 0;
  
  
  /*--------------->Function @ InvtAndNoticeAll @ discription <-----------------*
  *@name: virtual bool InvtAndNoticeAll() = 0;                                  *
  *@parameter: void                                                             *
  *@purpose: show all the statistic result in characters                        *
  *@return value: bool                                                          *
  *-----------------------------------------------------------------------------*/
  virtual bool InvtAndNoticeAll() = 0;
  
  /*-------------->Function @ InvtAndDrawMastAll @ discription <----------------*
  *@name: virtual bool InvtAndDrawMastAll()  = 0;                               *
  *@parameter: void                                                             *
  *@purpose: show statistic result in Mast                                      *
  *@return value: bool                                                          *
  *-----------------------------------------------------------------------------*/
  virtual bool InvtAndDrawMastAll()  = 0;
  
  /*--------------->Function @ InvtAnd_N_DMAll @ discription <------------------*
  *@name: virtual bool InvtAnd_N_DMAll()  = 0;                                  *
  *@parameter: void                                                             *
  *@purpose: show all the statistic result in Mast and characters               *
  *@return value: bool                                                          *
  *-----------------------------------------------------------------------------*/
  virtual bool InvtAnd_N_DMAll()  = 0;
  
  //public Data for window's width
 public:
  static const int WINDOWWIDTH;
  
 protected:
  stringEx m_strData;
  stringEx m_strCI;
 };
 
 
 
 inline int Investigator_Base::SetData(const string &strData) throw(char*)
 {
  if (strData.length() <= 0)
   throw "缺少统计数据!";
  
  m_strData = strData;
  
  return m_strData.length ();
 }
 
 inline int Investigator_Base::SetCharInvt(const string &strCI) throw(char*)
 {
  if (strCI.length() <= 0)
   throw "缺少统计选项!";
  
  m_strCI = strCI;
  
  return m_strCI.length ();
 }
}

#endif

//

// ****************************************************************************
//  Investigator_Base.cpp   version:  1.0     date: 12/09/2005
//  ---------------------------------------------------------------------------
//  Summary:
//  ---------------------------------------------------------------------------
//  Copyright (C) LYH_Studio @ 2005 - All Rights Reserved
// ****************************************************************************
//
// ****************************************************************************

//include file
#include "Investigator_Base.h"
using namespace Investigator;

const int Investigator_Base::WINDOWWIDTH = 80;


//class functions define

Investigator_Base::Investigator_Base()
{
};

Investigator_Base::Investigator_Base(const string &strData, const string &strCI)
{
 SetData(strData);
 SetCharInvt(strCI);
};

Investigator_Base::~Investigator_Base()
{
};

int Investigator_Base::InvtChar(char cChr) const throw() 
{
 
 int iNum = 0,iPos = -1;
 
 while ((iPos = m_strData.find(cChr,iPos+1)) != string::npos)
  iNum ++;
 
 return iNum;
}

int Investigator_Base::InvtStr(const string &strData) const throw() 
{
 if (ASSERT(m_strData.length() == 0))
  throw string("缺少统计数据!");
 
 int iNum = 0,iPos = 0;
 
 while ((iPos = m_strData.find(strData,iPos)) != string::npos)
  iNum ++;
 
 return iNum;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值