1 // Copyright 2008, Google Inc. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are met: 5 // 6 // 1. Redistributions of source code must retain the above copyright notice, 7 // this list of conditions and the following disclaimer. 8 // 2. Redistributions in binary form must reproduce the above copyright notice, 9 // this list of conditions and the following disclaimer in the documentation 10 // and/or other materials provided with the distribution. 11 // 3. Neither the name of Google Inc. nor the names of its contributors may be 12 // used to endorse or promote products derived from this software without 13 // specific prior written permission. 14 // 15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26 // This file contains the declaration of the <xal:AddressDetails> elements. 27 // Note, only a subset of XAL using these elements is implemented here. 28 // However, note that the normal unknown/misplaced element handling of libkml 29 // is employed thus all of XAL is preserved on parse and emitted on 30 // serialization. The portion implemented here pertains to programmatic 31 // dom access. 32 // 33 // xAL complex elements: 34 // <xal:AddressDetails> 35 // <xal:AdministrativeArea> 36 // <xal:Country> 37 // <xal:Locality> 38 // <xal:PostalCode> 39 // <xal:SubAdministrativeArea> 40 // <xal:Thoroughfare> 41 // 42 // xAL simple elements: 43 // <xal:AdministrativeAreaName> 44 // <xal:CountryNameCode> 45 // <xal:LocalityName> 46 // <xal:PostalCodeNumber> 47 // <xal:SubAdministrativeAreaName> 48 // <xal:ThoroughfareName> 49 // <xal:ThoroughfareNumber> 50 51 #ifndef KML_DOM_XAL_H__ 52 #define KML_DOM_XAL_H__ 53 54 #include "kml/dom/element.h" 55 #include "kml/base/attributes.h" 56 57 namespace kmldom { 58 59 // <xal:AddressDetails> 60 class XalAddressDetails : public BasicElement<Type_XalAddressDetails> { 61 public: ~XalAddressDetails()62 virtual ~XalAddressDetails() {} 63 64 // <xal:Country> get_country()65 const XalCountryPtr& get_country() const { return country_; } has_country()66 bool has_country() const { return country_ != NULL; } set_country(const XalCountryPtr & country)67 void set_country(const XalCountryPtr& country) { 68 SetComplexChild(country, &country_); 69 } clear_country()70 void clear_country() { set_country(NULL); } 71 72 private: 73 XalAddressDetails(); 74 XalCountryPtr country_; 75 friend class KmlFactory; 76 friend class KmlHandler; 77 virtual void AddElement(const ElementPtr& element); 78 friend class Serializer; 79 virtual void Serialize(Serializer& serializer) const; 80 }; 81 82 // <xal:AdministrativeArea> 83 class XalAdministrativeArea : public BasicElement<Type_XalAdministrativeArea> { 84 public: ~XalAdministrativeArea()85 virtual ~XalAdministrativeArea() {} 86 87 // <xal:AdministrativeAreaName> get_administrativeareaname()88 const string& get_administrativeareaname() const { 89 return administrativeareaname_; 90 } has_administrativeareaname()91 bool has_administrativeareaname() const { 92 return has_administrativeareaname_; 93 } set_administrativeareaname(const string & value)94 void set_administrativeareaname(const string& value) { 95 administrativeareaname_ = value; 96 has_administrativeareaname_ = true; 97 } clear_administrativeareaname()98 void clear_administrativeareaname() { 99 administrativeareaname_.clear(); 100 has_administrativeareaname_ = false; 101 } 102 103 // <xal:Locality> get_locality()104 const XalLocalityPtr& get_locality() const { return locality_; } has_locality()105 bool has_locality() const { return locality_ != NULL; } set_locality(const XalLocalityPtr & locality)106 void set_locality(const XalLocalityPtr& locality) { 107 SetComplexChild(locality, &locality_); 108 } 109 clear_locality()110 void clear_locality() { set_locality(NULL); } 111 // <xal:SubAdministrativeArea> get_subadministrativearea()112 const XalSubAdministrativeAreaPtr& get_subadministrativearea() const { 113 return subadministrativearea_; 114 } has_subadministrativearea()115 bool has_subadministrativearea() const { 116 return subadministrativearea_ != NULL; 117 } set_subadministrativearea(const XalSubAdministrativeAreaPtr & subadministrativearea)118 void set_subadministrativearea( 119 const XalSubAdministrativeAreaPtr& subadministrativearea) { 120 SetComplexChild(subadministrativearea, &subadministrativearea_); 121 } clear_subadministrativearea()122 void clear_subadministrativearea() { set_subadministrativearea(NULL); } 123 124 private: 125 XalAdministrativeArea(); 126 bool has_administrativeareaname_; 127 string administrativeareaname_; 128 XalLocalityPtr locality_; 129 XalSubAdministrativeAreaPtr subadministrativearea_; 130 friend class KmlFactory; 131 friend class KmlHandler; 132 virtual void AddElement(const ElementPtr& element); 133 friend class Serializer; 134 virtual void Serialize(Serializer& serializer) const; 135 }; 136 137 // <xal:Country> 138 class XalCountry : public BasicElement<Type_XalCountry> { 139 public: ~XalCountry()140 virtual ~XalCountry() {} 141 142 // <xal:CountryNameCode>, ISO 3166-1 get_countrynamecode()143 const string& get_countrynamecode() const { return countrynamecode_; } has_countrynamecode()144 bool has_countrynamecode() const { return has_countrynamecode_; } set_countrynamecode(const string & value)145 void set_countrynamecode(const string& value) { 146 countrynamecode_ = value; 147 has_countrynamecode_ = true; 148 } clear_countrynamecode()149 void clear_countrynamecode() { 150 countrynamecode_.clear(); 151 has_countrynamecode_ = false; 152 } 153 154 // <xal:AdministrativeArea> get_administrativearea()155 const XalAdministrativeAreaPtr& get_administrativearea() const { 156 return administrativearea_; 157 } has_administrativearea()158 bool has_administrativearea() const { return administrativearea_ != NULL; } set_administrativearea(const XalAdministrativeAreaPtr & administrativearea)159 void set_administrativearea( 160 const XalAdministrativeAreaPtr& administrativearea) { 161 SetComplexChild(administrativearea, &administrativearea_); 162 } clear_administrativearea()163 void clear_administrativearea() { set_administrativearea(NULL); } 164 165 private: 166 XalCountry(); 167 bool has_countrynamecode_; 168 string countrynamecode_; 169 XalAdministrativeAreaPtr administrativearea_; 170 friend class KmlFactory; 171 friend class KmlHandler; 172 virtual void AddElement(const ElementPtr& element); 173 friend class Serializer; 174 virtual void Serialize(Serializer& serializer) const; 175 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(XalCountry); 176 }; 177 178 // <xal:Locality> 179 class XalLocality : public BasicElement<Type_XalLocality> { 180 public: ~XalLocality()181 virtual ~XalLocality() {} 182 183 // <xal:LocalityName> get_localityname()184 const string& get_localityname() const { 185 return localityname_; 186 } has_localityname()187 bool has_localityname() const { 188 return has_localityname_; 189 } set_localityname(const string & value)190 void set_localityname(const string& value) { 191 localityname_ = value; 192 has_localityname_ = true; 193 } clear_localityname()194 void clear_localityname() { 195 localityname_.clear(); 196 has_localityname_ = false; 197 } 198 199 // <xal:Thoroughfare> get_thoroughfare()200 const XalThoroughfarePtr& get_thoroughfare() const { return thoroughfare_; } has_thoroughfare()201 bool has_thoroughfare() const { return thoroughfare_ != NULL; } set_thoroughfare(const XalThoroughfarePtr & thoroughfare)202 void set_thoroughfare(const XalThoroughfarePtr& thoroughfare) { 203 SetComplexChild(thoroughfare, &thoroughfare_); 204 } clear_thoroughfare()205 void clear_thoroughfare() { set_thoroughfare(NULL); } 206 207 // <xal:PostalCode> get_postalcode()208 const XalPostalCodePtr& get_postalcode() const { return postalcode_; } has_postalcode()209 bool has_postalcode() const { return postalcode_ != NULL; } set_postalcode(const XalPostalCodePtr & postalcode)210 void set_postalcode(const XalPostalCodePtr& postalcode) { 211 SetComplexChild(postalcode, &postalcode_); 212 } clear_postalcode()213 void clear_postalcode() { set_postalcode(NULL); } 214 215 private: 216 XalLocality(); 217 bool has_localityname_; 218 string localityname_; 219 XalThoroughfarePtr thoroughfare_; 220 XalPostalCodePtr postalcode_; 221 friend class KmlFactory; 222 friend class KmlHandler; 223 virtual void AddElement(const ElementPtr& element); 224 friend class Serializer; 225 virtual void Serialize(Serializer& serializer) const; 226 }; 227 228 // <xal:PostalCode> 229 class XalPostalCode : public BasicElement<Type_XalPostalCode> { 230 public: ~XalPostalCode()231 virtual ~XalPostalCode() {} 232 233 // <xal:PostalCodeNumber> get_postalcodenumber()234 const string& get_postalcodenumber() const { 235 return postalcodenumber_; 236 } has_postalcodenumber()237 bool has_postalcodenumber() const { 238 return has_postalcodenumber_; 239 } set_postalcodenumber(const string & value)240 void set_postalcodenumber(const string& value) { 241 postalcodenumber_ = value; 242 has_postalcodenumber_ = true; 243 } clear_postalcodenumber()244 void clear_postalcodenumber() { 245 postalcodenumber_.clear(); 246 has_postalcodenumber_ = false; 247 } 248 249 private: 250 XalPostalCode(); 251 bool has_postalcodenumber_; 252 string postalcodenumber_; 253 friend class KmlFactory; 254 friend class KmlHandler; 255 virtual void AddElement(const ElementPtr& element); 256 friend class Serializer; 257 virtual void Serialize(Serializer& serializer) const; 258 }; 259 260 // <xal:SubAdministrativeArea> 261 class XalSubAdministrativeArea : 262 public BasicElement<Type_XalSubAdministrativeArea> { 263 public: ~XalSubAdministrativeArea()264 virtual ~XalSubAdministrativeArea() {} 265 266 // <xal:SubAdministrativeAreaName> get_subadministrativeareaname()267 const string& get_subadministrativeareaname() const { 268 return subadministrativeareaname_; 269 } has_subadministrativeareaname()270 bool has_subadministrativeareaname() const { 271 return has_subadministrativeareaname_; 272 } set_subadministrativeareaname(const string & value)273 void set_subadministrativeareaname(const string& value) { 274 subadministrativeareaname_ = value; 275 has_subadministrativeareaname_ = true; 276 } clear_subadministrativeareaname()277 void clear_subadministrativeareaname() { 278 subadministrativeareaname_.clear(); 279 has_subadministrativeareaname_ = false; 280 } 281 282 // <xal:Locality> get_locality()283 const XalLocalityPtr& get_locality() const { return locality_; } has_locality()284 bool has_locality() const { return locality_ != NULL; } set_locality(const XalLocalityPtr & locality)285 void set_locality(const XalLocalityPtr& locality) { 286 SetComplexChild(locality, &locality_); 287 } clear_locality()288 void clear_locality() { set_locality(NULL); } 289 290 private: 291 XalSubAdministrativeArea(); 292 bool has_subadministrativeareaname_; 293 string subadministrativeareaname_; 294 XalLocalityPtr locality_; 295 friend class KmlFactory; 296 friend class KmlHandler; 297 virtual void AddElement(const ElementPtr& element); 298 friend class Serializer; 299 virtual void Serialize(Serializer& serializer) const; 300 }; 301 302 // <xal:Thoroughfare> 303 class XalThoroughfare : public BasicElement<Type_XalThoroughfare> { 304 public: ~XalThoroughfare()305 virtual ~XalThoroughfare() {} 306 307 // <xal:ThoroughfareName> get_thoroughfarename()308 const string& get_thoroughfarename() const { 309 return thoroughfarename_; 310 } has_thoroughfarename()311 bool has_thoroughfarename() const { 312 return has_thoroughfarename_; 313 } set_thoroughfarename(const string & value)314 void set_thoroughfarename(const string& value) { 315 thoroughfarename_ = value; 316 has_thoroughfarename_ = true; 317 } clear_thoroughfarename()318 void clear_thoroughfarename() { 319 thoroughfarename_.clear(); 320 has_thoroughfarename_ = false; 321 } 322 323 // <xal:ThoroughfareNumber> get_thoroughfarenumber()324 const string& get_thoroughfarenumber() const { 325 return thoroughfarenumber_; 326 } has_thoroughfarenumber()327 bool has_thoroughfarenumber() const { 328 return has_thoroughfarenumber_; 329 } set_thoroughfarenumber(const string & value)330 void set_thoroughfarenumber(const string& value) { 331 thoroughfarenumber_ = value; 332 has_thoroughfarenumber_ = true; 333 } clear_thoroughfarenumber()334 void clear_thoroughfarenumber() { 335 thoroughfarenumber_.clear(); 336 has_thoroughfarenumber_ = false; 337 } 338 339 private: 340 XalThoroughfare(); 341 bool has_thoroughfarename_; 342 string thoroughfarename_; 343 bool has_thoroughfarenumber_; 344 string thoroughfarenumber_; 345 friend class KmlFactory; 346 friend class KmlHandler; 347 virtual void AddElement(const ElementPtr& element); 348 friend class Serializer; 349 virtual void Serialize(Serializer& serializer) const; 350 }; 351 352 } // end namespace kmldom 353 354 #endif // KML_DOM_XAL_H__ 355