InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TemplateData.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: rich gartland
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 // Class to implement template field data for Knowledge
24 // base Interface.
25 //
26 //========================================================================================
27 
28 #ifndef __TEMPLATEDATA
29 #define __TEMPLATEDATA
30 
31 
32 #include "PMTypes.h"
33 #include "PMString.h"
34 #include "K2Vector.h"
35 #include "K2Vector.h"
36 
37 #ifdef PUBLIC_BUILD
38 #endif
39 
40 typedef enum { fldInt, fldDouble, fldString } fldType;
41 
46 class FieldData {
47  public:
48  FieldData();
49  FieldData(int32 intvalue);
50  FieldData(double doublevalue);
51  FieldData(const PMString& stringvalue);
52  ~FieldData();
53  void SetName(ConstCString fname);
54  std::string fieldName;
55  fldType fieldType;
56  int32 anInt;
57  double aDouble;
58  PMString *aString;
59 };
60 
65 class TemplateData {
66  public:
67  TemplateData();
68  ~TemplateData();
69  TemplateData(ConstCString tname);
70 
71  void SetName(ConstCString tname);
72  const char* GetName() { return fTemplateName.c_str(); };
73 
74  int32 GetNumFields() { return static_cast<int32>(fFieldList.size()); };
75  void SetIDIndex(int16 idindex) { fIDIndex = idindex; };
76  int16 GetIDIndex() { return fIDIndex; };
77  FieldData* MakeField(int16 index);
78 
79  void SetField(int16 index, ConstCString fname, int32 value, bool16 isID = kFalse);
80  void SetField(int16 index, ConstCString fname, double value, bool16 isID = kFalse);
81  void SetField(int16 index, ConstCString fname, PMString& value, bool16 isID = kFalse);
82 
83  void GetField(int16 index, int32 *value) { *value = fFieldList[index]->anInt; };
84  void GetField(int16 index, double *value) { *value = fFieldList[index]->aDouble; };
85  void GetField(int16 index, PMString& value) { value = *(fFieldList[index]->aString); };
86  fldType GetFieldType(int16 index) { return fFieldList[index]->fieldType; };
87  const std::string GetFieldName(int16 index) { return fFieldList[index]->fieldName; };
88 
89  private:
90  std::string fTemplateName;
91  int16 fIDIndex;
92  K2Vector<FieldData*> fFieldList;
93 };
94 
95 
96 
97 #endif // __TEMPLATEDATA