InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UnspecifiableOf.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Michael Burbidge
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __UnspecifiableOf_h__
25 #define __UnspecifiableOf_h__
26 
27 //========================================================================================
28 // TEMPLATE UnspecifiableOf
29 //========================================================================================
30 
31 struct Unspecified { };
32 
39 template <class ValueType>
41 {
42 public:
47  UnspecifiableOf(const Unspecified& /*unspecified*/) : fSpecified(false) { }
48 
53  UnspecifiableOf(const ValueType& value) : fSpecified(true), fValue(value) { }
54 
59  UnspecifiableOf(const UnspecifiableOf& other) : fSpecified(other.fSpecified), fValue(other.fValue) { }
60 
66  {
67  if (this != &other)
68  {
69  fSpecified = other.fSpecified;
70  fValue = other.fValue;
71  }
72 
73  return *this;
74  }
75 
80  bool IsSpecified() const { return fSpecified; }
81 
86  ValueType GetValue() const { ASSERT(IsSpecified()); return fValue; }
87 
88 private:
89  bool fSpecified;
90  ValueType fValue;
91 };
92 
93 // was: extern const Unspecified kUnspecified;
94 
95 #ifdef WINDOWS
96 // pjm - figure out what is going on here
97 const Unspecified kUnspecified;
98 #else
99 const Unspecified kUnspecified = {};
100 #endif
101 
102 #endif // __UnspecifiableOf_h__