Ice Sheet System Model  4.18
Code documentation
KML_Attribute.cpp
Go to the documentation of this file.
1 
5 /*Headers:*/
6 /*{{{*/
7 #ifdef HAVE_CONFIG_H
8  #include <config.h>
9 #else
10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
11 #endif
12 
13 #include "./KML_Attribute.h"
14 #include "../shared/shared.h"
15 /*}}}*/
16 
17 /*Constructors/destructor/copy*/
19 
20  name =NULL;
21  value =NULL;
22 
23 }
24 /*}}}*/
26 
27  if (name ) xDelete<char>(name);
28  if (value ) xDelete<char>(value);
29 
30 }
31 /*}}}*/
32 
33 /*Other*/
34 void KML_Attribute::Echo(){/*{{{*/
35 
36  int i;
37  bool flag=true;
38 
39  if(flag) _printf0_(" ");
40  for (i=0;i<10-strlen(name);i++)
41  if(flag) _printf0_(" ");
42  if(flag) _printf0_(name << ": \"" << value << "\"\n");
43 
44  return;
45 }
46 /*}}}*/
48 
49  char indent[81]="";
50 
52 
53  return;
54 }
55 /*}}}*/
56 void KML_Attribute::DeepEcho(const char* indent){/*{{{*/
57 
58  int i;
59  bool flag=true;
60 
61  if(flag) _printf0_(indent << " ");
62  for (i=0;i<10-strlen(name);i++)
63  if(flag) _printf0_(" ");
64  if(flag) _printf0_(name << ": \"" << value << "\"\n");
65 
66  return;
67 }
68 /*}}}*/
69 void KML_Attribute::Write(FILE* filout,const char* indent){/*{{{*/
70 
71 // attributes always written in keyword line of kml_object
72 
73  fprintf(filout,"%s%s=\"%s\"",indent,name,value);
74 
75  return;
76 }
77 /*}}}*/
78 void KML_Attribute::Read(FILE* fid,char* kstr){/*{{{*/
79 
80 // attributes always read in keyword line of kml_object
81 
82  ;
83 
84  return;
85 }
86 /*}}}*/
87 void KML_Attribute::Alloc(const char* namei,const char* valuei){/*{{{*/
88 
89  name =xNew<char>(strlen(namei )+1);
90  memcpy(name,namei,(strlen(namei)+1)*sizeof(char));
91 
92  value=xNew<char>(strlen(valuei)+1);
93  memcpy(value,valuei,(strlen(valuei)+1)*sizeof(char));
94 
95  return;
96 }
97 /*}}}*/
98 void KML_Attribute::Add(DataSet* attrib){/*{{{*/
99 
100  attrib->AddObject((Object*)this);
101 
102  return;
103 }
104 /*}}}*/
105 void KML_Attribute::Get(char** pvalueo,char* deflt){/*{{{*/
106 
107  if (!value || !strlen(value)) {
108  *pvalueo=xNew<char>(strlen(deflt)+1);
109  memcpy(*pvalueo,deflt,(strlen(deflt)+1)*sizeof(char));
110  }
111  else {
112  *pvalueo=xNew<char>(strlen(value)+1);
113  memcpy(*pvalueo,value,(strlen(value)+1)*sizeof(char));
114  }
115 
116  return;
117 }
118 /*}}}*/
KML_Attribute::value
char * value
Definition: KML_Attribute.h:18
_printf0_
#define _printf0_(StreamArgs)
Definition: Print.h:29
DataSet::AddObject
int AddObject(Object *object)
Definition: DataSet.cpp:252
KML_Attribute::DeepEcho
virtual void DeepEcho()
Definition: KML_Attribute.cpp:47
KML_Attribute::Get
void Get(char **pvalueo, char *deflt)
Definition: KML_Attribute.cpp:105
KML_Attribute::~KML_Attribute
~KML_Attribute()
Definition: KML_Attribute.cpp:25
Object
Definition: Object.h:13
KML_Attribute::Read
void Read(FILE *fid, char *kstr)
Definition: KML_Attribute.cpp:78
KML_Attribute::name
char * name
Definition: KML_Attribute.h:17
KML_Attribute::KML_Attribute
KML_Attribute()
Definition: KML_Attribute.cpp:18
KML_Attribute::Alloc
void Alloc(const char *namei, const char *valuei)
Definition: KML_Attribute.cpp:87
KML_Attribute.h
: header file for kml_attribute object
DataSet
Declaration of DataSet class.
Definition: DataSet.h:14
KML_Attribute::Add
void Add(DataSet *attrib)
Definition: KML_Attribute.cpp:98
KML_Attribute::Echo
virtual void Echo()
Definition: KML_Attribute.cpp:34
KML_Attribute::Write
void Write(FILE *fid, const char *indent)
Definition: KML_Attribute.cpp:69