📄 customer.h
字号:
// 通过这个类可以操纵数据库(也就是customer.xml),每创建一个对象,它就可以
// 把数据库中的内容读入内存中。当对象被删除时,它可以自动地将内存中的数据重新
// 写入数据库中,从而更新数据库。具体的操作接口可以看函数的说明
#pragma once
// #ifndef _CUSTOMER_
// #define _CUSTOMER_
#include <string>
#include <strstream>
#include <fstream>
#include <map>
#include <list>
#include "ToolFun.h"
#include <iostream>
#include <iomanip>
using namespace std;
#define defaultWeight 3
struct stuMan{
stuMan():weight(0), id(0) { };
map< string, string > msgMap;
int weight;
int id;
};
class Customer
{
public:
typedef list< stuMan >::iterator Iterator;
public:
Customer(void);
virtual ~Customer(void);
Iterator find( int id ); // check the customer exist in database.
Iterator begin(); // return begin iterator of customers
Iterator end(); // return end iterator of customes
bool save(); // storage database file and format define file back to disk
bool add(); // add a customer to database
bool add( const map<string,string>& attr_Map ); // add a customer to database;
bool add( const struct stuMan& man ); // add a customer to database.
bool chg( int id ); // change a customer's message.
bool del( int id ); // delete a customer from database.
bool display( int id ); // dispaly the usr with this ID's message
bool display( const map<string,string>& cnd_Map ); // display the meesage of users who fix the condition
bool display( const string& name ); // display this usr's message.
bool displayf( const string& name );// display the message of usrs whose name look like as the name.
private:
bool init(); // Initialize Customers' message;
bool initFormat(); // Initialize the Customer's format map
private:
list< stuMan > CMan;
map<string,string> formatMap;
int maxID;
bool ready;
};
ifstream& operator >> ( ifstream& is, Customer& c );
ostream& operator << ( ostream& os, const Customer& c );
// #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -