1 // Options.h: interface for the COptions class.
3 //////////////////////////////////////////////////////////////////////
5 #if !defined(AFX_OPTIONS_H__8B59AD68_C12F_44E7_9236_3C800593E961__INCLUDED_)
6 #define AFX_OPTIONS_H__8B59AD68_C12F_44E7_9236_3C800593E961__INCLUDED_
10 #endif // _MSC_VER > 1000
15 //---------------------------------------------------------------------------
16 enum tristate
{ cleared
, undefined
, set
};
18 inline void operator &= (bool& _bool
, tristate _tristate
)
20 _bool
= _tristate
== undefined
? _bool
: _tristate
== cleared
? false : true;
24 //---------------------------------------------------------------------------
28 : m_Type (typeUndefined
)
31 : m_Type (typeTristate
), pTristateValue (val
)
33 CValue (const char* pVal
)
34 : m_Type (typeString
), m_pStringValue (pVal
)
36 CValue (const bool val
)
37 : m_Type (typeBool
), pBoolValue(val
)
40 enum { typeUndefined
, typeTristate
, typeBool
, typeString
} m_Type
;
42 tristate pTristateValue
;
44 const char* m_pStringValue
;
47 operator const char* () const
49 assert (m_Type
== typeString
);
50 return m_pStringValue
;
53 operator tristate () const
55 assert (m_Type
== typeTristate
);
56 return pTristateValue
;
67 typedef std::list
<COption
> COptionsList
;
72 enum eArgType
{ noArgument
, requiredArgument
, optionalArgument
, tristateArgument
};
74 COptionInfo (int id
, char shortOption
, std::string longOption
, std::string descr
, eArgType needArg
);
78 std::string m_longOption
;
79 std::string m_Description
;
83 std::ostream
& operator<<(std::ostream
& os
, const COptionInfo
& info
);
85 typedef std::list
<COptionInfo
> COptionInfoList
;
91 virtual ~COptions () {};
93 virtual COptionInfoList
GetOptionsInfo () const
95 return COptionInfoList ();
97 void SetOptions (const COptionsList
& options
)
99 COptionsList::const_iterator itor
= options
.begin ();
100 while (itor
!= options
.end())
102 // if (!SetOption (*itor))
103 // throw SSException ("unknown option");
108 virtual bool SetOption (const COption
& option
) = 0;
110 virtual void PrintUsage () const;
114 #endif // !defined(AFX_OPTIONS_H__8B59AD68_C12F_44E7_9236_3C800593E961__INCLUDED_)