-
Notifications
You must be signed in to change notification settings - Fork 0
/
Options.cpp
81 lines (59 loc) · 1.97 KB
/
Options.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// =============================================================================
// Options.cpp
// implementation of the COptions class.
// =============================================================================
// Copyright (c) WildPackets, Inc. 2004. All rights reserved.
#include "StdAfx.h"
#include "Options.h"
#include "ByteStream.h"
#include "DeltaTimeFilter.h"
#include "CatchHR.h"
extern CDeltaTimeFilterApp theApp;
CStringA g_strTrue( "True" );
CStringA g_strFalse( "False" );
// -----------------------------------------------------------------------------
// ReadXML
// -----------------------------------------------------------------------------
void
CFilter::ReadXML( XXMLElement* pElement )
{
HRESULT hr = 0;
try
{
XString theValue;
CString csValue;
BOOL bResult = pElement->GetNamedAttributeValue( kPref_Name, theValue );
csValue = theValue;
if (bResult) SetName( csValue );
bResult = pElement->GetNamedAttributeValue( kPref_Filter, theValue );
csValue = theValue;
if (bResult) SetFilter( csValue );
bResult = pElement->GetNamedAttributeValue( kPref_Comment, theValue );
csValue = theValue;
if (bResult) SetComment( csValue );
}
CATCH_HR(hr)
}
// -----------------------------------------------------------------------------
// WriteXML
// -----------------------------------------------------------------------------
XXMLElement*
CFilter::WriteXML()
{
HRESULT hr = 0;
XXMLElement* pElement = NULL;
try
{
pElement = new XXMLElement( kPref_Options );
ASSERT(pElement);
if (pElement == NULL) AtlThrow(-1);
BOOL bResult = pElement->AddAttribute( kPref_Name, GetName() );
if (bResult == FALSE) AtlThrow(-1);
bResult = pElement->AddAttribute( kPref_Filter, GetFilter() );
if (bResult == FALSE) AtlThrow(-1);
bResult = pElement->AddAttribute( kPref_Comment, GetComment() );
if (bResult == FALSE) AtlThrow(-1);
}
CATCH_HR(hr)
return pElement;
}