Ice Sheet System Model  4.18
Code documentation
KML_Icon.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_Icon.h"
14 #include "./KMLFileReadUtils.h"
15 #include "../shared/shared.h"
16 /*}}}*/
17 
18 /*Constructors/destructor/copy*/
20 
21  strcpy(href ,"");
22  strcpy(refmode ,"onChange");
23  refint = 4.;
24  strcpy(vrefmode ,"never");
25  vreftime = 4.;
26  vboundsc = 1.;
27  strcpy(vformat ,"");
28  strcpy(hquery ,"");
29 
30 }
31 /*}}}*/
33 
34  ;
35 
36 }
37 /*}}}*/
38 
39 /*Other*/
40 void KML_Icon::Echo(){/*{{{*/
41 
42  bool flag=true;
43 
44  if(flag) _printf0_("KML_Icon:\n");
46 
47  if(flag) _printf0_(" href: \"" << href << "\"\n");
48  if(flag) _printf0_(" refmode: \"" << refmode << "\"\n");
49  if(flag) _printf0_(" refint: " << refint << "\n");
50  if(flag) _printf0_(" vrefmode: \"" << vrefmode << "\"\n");
51  if(flag) _printf0_(" vreftime: " << vreftime << "\n");
52  if(flag) _printf0_(" vboundsc: " << vboundsc << "\n");
53  if(flag) _printf0_(" vformat: \"" << vformat << "\"\n");
54  if(flag) _printf0_(" hquery: \"" << hquery << "\"\n");
55 
56  return;
57 }
58 /*}}}*/
59 void KML_Icon::DeepEcho(){/*{{{*/
60 
61  char indent[81]="";
62 
63  KML_Icon::DeepEcho(indent);
64 
65  return;
66 }
67 /*}}}*/
68 void KML_Icon::DeepEcho(const char* indent){/*{{{*/
69 
70  bool flag=true;
71 
72  if(flag) _printf0_(indent << "KML_Icon:\n");
73  KML_Object::DeepEcho(indent);
74 
75  if(flag) _printf0_(indent << " href: \"" << href << "\"\n");
76  if(flag) _printf0_(indent << " refmode: \"" << refmode << "\"\n");
77  if(flag) _printf0_(indent << " refint: " << refint << "\n");
78  if(flag) _printf0_(indent << " vrefmode: \"" << vrefmode << "\"\n");
79  if(flag) _printf0_(indent << " vreftime: " << vreftime << "\n");
80  if(flag) _printf0_(indent << " vboundsc: " << vboundsc << "\n");
81  if(flag) _printf0_(indent << " vformat: \"" << vformat << "\"\n");
82  if(flag) _printf0_(indent << " hquery: \"" << hquery << "\"\n");
83 
84  return;
85 }
86 /*}}}*/
87 void KML_Icon::Write(FILE* filout,const char* indent){/*{{{*/
88 
89  fprintf(filout,"%s<Icon",indent);
90  WriteAttrib(filout," ");
91  fprintf(filout,">\n");
92  WriteCommnt(filout,indent);
93 
94  KML_Object::Write(filout,indent);
95 
96  if (href && strlen(href))
97  fprintf(filout,"%s <href>%s</href>\n",indent,href);
98  if (refmode && strlen(refmode))
99  fprintf(filout,"%s <refreshMode>%s</refreshMode>\n",indent,refmode);
100  fprintf(filout,"%s <refreshInterval>%g</refreshInterval>\n",indent,refint);
101  if (vrefmode && strlen(vrefmode))
102  fprintf(filout,"%s <viewRefreshMode>%s</viewRefreshMode>\n",indent,vrefmode);
103  fprintf(filout,"%s <viewRefreshTime>%g</viewRefreshTime>\n",indent,vreftime);
104  fprintf(filout,"%s <viewBoundScale>%g</viewBoundScale>\n",indent,vboundsc);
105  if (vformat && strlen(vformat))
106  fprintf(filout,"%s <viewFormat>%s</viewFormat>\n",indent,vformat);
107  if (hquery && strlen(hquery))
108  fprintf(filout,"%s <httpQuery>%s</httpQuery>\n",indent,hquery);
109 
110  fprintf(filout,"%s</Icon>\n",indent);
111 
112  return;
113 }
114 /*}}}*/
115 void KML_Icon::Read(FILE* fid,char* kstr){/*{{{*/
116 
117  char* kstri;
118  int ncom=0;
119  char** pcom=NULL;
120 
121 /* get object attributes and check for solo tag */
122 
123  if (KMLFileTagAttrib(this,
124  kstr))
125  return;
126 
127 /* loop over and process fields within opening and closing tags */
128 
129  while((kstri=KMLFileToken(fid, &ncom,&pcom))){
130  if (!strncmp(kstri,"</Icon", 6)) {
131  xDelete<char>(kstri);
132  break;
133  }
134  else if (!strncmp(kstri,"</",2))
135  {_error_("KML_Icon::Read -- Unexpected closing tag " << kstri << ".\n");}
136  else if (strncmp(kstri,"<",1))
137  {_error_("KML_Icon::Read -- Unexpected field \"" << kstri << "\".\n");}
138 
139  else if (!strcmp(kstri,"<href>"))
140  KMLFileTokenParse( href ,NULL,KML_ICON_HREF_LENGTH, kstri, fid);
141  else if (!strcmp(kstri,"<refreshMode>"))
143  else if (!strcmp(kstri,"<refreshInterval>"))
144  KMLFileTokenParse(&refint , kstri, fid);
145  else if (!strcmp(kstri,"<viewRefreshMode>"))
147  else if (!strcmp(kstri,"<viewRefreshTime>"))
148  KMLFileTokenParse(&vreftime , kstri, fid);
149  else if (!strcmp(kstri,"<viewBoundScale>"))
150  KMLFileTokenParse(&vboundsc , kstri, fid);
151  else if (!strcmp(kstri,"<viewFormat>"))
153  else if (!strcmp(kstri,"<httpQuery>"))
154  KMLFileTokenParse( hquery ,NULL,KML_ICON_HQUERY_LENGTH, kstri, fid);
155 
156  else if (!strncmp(kstri,"<",1))
157  KML_Object::Read(fid,kstri);
158 
159  xDelete<char>(kstri);
160  }
161 
162  this->AddCommnt(ncom,pcom);
163 
164  for(ncom=ncom; ncom>0; ncom--)
165  xDelete<char>(pcom[ncom-1]);
166  xDelete<char*>(pcom);
167 
168  return;
169 }
170 /*}}}*/
KML_ICON_REFMODE_LENGTH
#define KML_ICON_REFMODE_LENGTH
Definition: KML_Icon.h:9
_printf0_
#define _printf0_(StreamArgs)
Definition: Print.h:29
KML_Object::WriteAttrib
virtual void WriteAttrib(FILE *fid, const char *indent)
Definition: KML_Object.cpp:288
KML_ICON_VFORMAT_LENGTH
#define KML_ICON_VFORMAT_LENGTH
Definition: KML_Icon.h:11
KMLFileReadUtils.h
: header file for kml file reading utilities.
KMLFileTagAttrib
int KMLFileTagAttrib(KML_Object *kobj, char *ktag)
Definition: KMLFileReadUtils.cpp:287
KML_Icon::hquery
char hquery[KML_ICON_HQUERY_LENGTH+1]
Definition: KML_Icon.h:31
KML_Icon::vrefmode
char vrefmode[KML_ICON_VREFMODE_LENGTH+1]
Definition: KML_Icon.h:27
KML_ICON_HREF_LENGTH
#define KML_ICON_HREF_LENGTH
Definition: KML_Icon.h:8
KML_Icon.h
: header file for kml_icon object
KML_Object::Read
virtual void Read(FILE *fid, char *kstr)=0
Definition: KML_Object.cpp:143
KML_Icon::vboundsc
float vboundsc
Definition: KML_Icon.h:29
KMLFileToken
char * KMLFileToken(FILE *fid, int *pncom=NULL, char ***ppcom=NULL)
Definition: KMLFileReadUtils.cpp:18
KML_Icon::vreftime
float vreftime
Definition: KML_Icon.h:28
KML_Object::Write
virtual void Write(FILE *fid, const char *indent)=0
Definition: KML_Object.cpp:122
KML_Icon::Read
void Read(FILE *fid, char *kstr)
Definition: KML_Icon.cpp:115
KML_Object::DeepEcho
virtual void DeepEcho()
Definition: KML_Object.cpp:72
KML_ICON_HQUERY_LENGTH
#define KML_ICON_HQUERY_LENGTH
Definition: KML_Icon.h:12
KMLFileTokenParse
int KMLFileTokenParse(int *pival, char *ktag, FILE *fid)
Definition: KMLFileReadUtils.cpp:335
KML_ICON_VREFMODE_LENGTH
#define KML_ICON_VREFMODE_LENGTH
Definition: KML_Icon.h:10
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
KML_Icon::refmode
char refmode[KML_ICON_REFMODE_LENGTH+1]
Definition: KML_Icon.h:25
KML_Object::Echo
virtual void Echo()
Definition: KML_Object.cpp:61
KML_Icon::KML_Icon
KML_Icon()
Definition: KML_Icon.cpp:19
KML_Icon::href
char href[KML_ICON_HREF_LENGTH+1]
Definition: KML_Icon.h:24
KML_Icon::Write
void Write(FILE *fid, const char *indent)
Definition: KML_Icon.cpp:87
KML_Icon::~KML_Icon
~KML_Icon()
Definition: KML_Icon.cpp:32
KML_Icon::Echo
void Echo()
Definition: KML_Icon.cpp:40
KML_Icon::DeepEcho
void DeepEcho()
Definition: KML_Icon.cpp:59
KML_Icon::refint
float refint
Definition: KML_Icon.h:26
KML_Object::AddCommnt
virtual void AddCommnt(int ncom, char **pcom)
Definition: KML_Object.cpp:301
KML_Object::WriteCommnt
virtual void WriteCommnt(FILE *fid, const char *indent)
Definition: KML_Object.cpp:326
KML_Icon::vformat
char vformat[KML_ICON_VFORMAT_LENGTH+1]
Definition: KML_Icon.h:30