1 /* Cfour (C++ Common Console Classes)
2  * Copyright (C) 2001 Jeffrey Bakker
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  *
18  *
19  *  Author:              Jeffrey Bakker
20  *  Filename:            cfdatapair.h
21  *  File version:        1.1
22  *
23  *  ===========================================================================
24  *
25  *  Created on: Sept 2nd, 2001
26  *
27  *  Modified on: April 1st, 2002
28  *
29  *             - Added translateML() which takes data markup format,
30  *               and modifies name and value.
31  *             - Added info_ml(), changed info() to info_nv().
32  *             - Added a constructor which takes a string in markup format.
33  *             - Overloaded insertion and extraction operators to convert
34  *               data between pairs and maarkup like a stream call.
35  *             - Made getName() and getValue() as const methods.
36  *
37  *  ===========================================================================
38  *
39  *  Remark:
40  *
41  *  This is the class defintion for CFdataPair, a class which provides methods
42  *  and data members for storing pairs of data.
43  *
44  *  ===========================================================================
45  * _______. ..
46  */
47 
48 
49 #ifndef _C4_DATA_PAIR
50 #define _C4_DATA_PAIR
51 
52 #include <string>
53 using namespace std;
54 
55 class CFdatapair {
56 
57  public:
58 
59   void operator<<(string  mldata);//{translateML(mldata);}
60   void operator>>(string& mldata);//{mldata = info_ml();}
61   //---------------------------------------------------------------------------
62   CFdatapair();                   // default constructor
63   CFdatapair(string mldata);      // create datapair with markup data
64   CFdatapair(string n, string v); // create datapair with name and value
65   //---------------------------------------------------------------------------
66   string getname()  const;        // return the name
67   string getvalue() const;        // return the value
68   void setname (string n);        // change the name
69   void setvalue(string v);        // change the value
70   //---------------------------------------------------------------------------
71   string info_nv()  const;        // return the name/value in printable format
72   string info_ml()  const;        // return the name/value in markup format
73   //---------------------------------------------------------------------------
74   void translateML(string mldata);// change the name/value using markup data
75   void swap();                    // swap the name and value
76   //---------------------------------------------------------------------------
77  protected:
78 
79   string name;
80   string value;
81   //---------------------------------------------------------------------------
82 };
83 
84 #endif  // _C4_DATA_PAIR
85 
86