SAGA API  v9.2
metadata.cpp
Go to the documentation of this file.
1 
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Application Programming Interface //
9 // //
10 // Library: SAGA_API //
11 // //
12 //-------------------------------------------------------//
13 // //
14 // metadata.cpp //
15 // //
16 // Copyright (C) 2009 by Olaf Conrad //
17 // //
18 //-------------------------------------------------------//
19 // //
20 // This file is part of 'SAGA - System for Automated //
21 // Geoscientific Analyses'. //
22 // //
23 // This library is free software; you can redistribute //
24 // it and/or modify it under the terms of the GNU Lesser //
25 // General Public License as published by the Free //
26 // Software Foundation, either version 2.1 of the //
27 // License, or (at your option) any later version. //
28 // //
29 // This library is distributed in the hope that it will //
30 // be useful, but WITHOUT ANY WARRANTY; without even the //
31 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
32 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
33 // License for more details. //
34 // //
35 // You should have received a copy of the GNU Lesser //
36 // General Public License along with this program; if //
37 // not, see <http://www.gnu.org/licenses/>. //
38 // //
39 //-------------------------------------------------------//
40 // //
41 // contact: Olaf Conrad //
42 // Institute of Geography //
43 // University of Hamburg //
44 // Germany //
45 // //
46 // e-mail: oconrad@saga-gis.org //
47 // //
49 
50 //---------------------------------------------------------
51 
53 // //
54 // //
55 // //
57 
58 //---------------------------------------------------------
59 #include <wx/xml/xml.h>
60 #include <wx/wfstream.h>
61 #include <wx/sstream.h>
62 #include <wx/mstream.h>
63 #include <wx/protocol/http.h>
64 
65 #include "metadata.h"
66 #include "table.h"
67 
68 
70 // //
71 // //
72 // //
74 
75 //---------------------------------------------------------
77 {
78  _On_Construction();
79 }
80 
82 {
83  return( true );
84 }
85 
86 //---------------------------------------------------------
88 {
89  _On_Construction();
90 
91  Create(MetaData);
92 }
93 
94 bool CSG_MetaData::Create(const CSG_MetaData &MetaData)
95 {
96  return( Assign(MetaData) );
97 }
98 
99 //---------------------------------------------------------
100 CSG_MetaData::CSG_MetaData(const CSG_String &File, const SG_Char *Extension)
101 {
102  _On_Construction();
103 
104  Create(File, Extension);
105 }
106 
107 bool CSG_MetaData::Create(const CSG_String &File, const SG_Char *Extension)
108 {
109  return( Load(File, Extension) );
110 }
111 
112 //---------------------------------------------------------
114 {
115  _On_Construction();
116 
117  Create(Stream);
118 }
119 
121 {
122  return( Load(Stream) );
123 }
124 
125 //---------------------------------------------------------
127 {
128  _On_Construction();
129 
130  m_pParent = pParent;
131 }
132 
133 //---------------------------------------------------------
134 void CSG_MetaData::_On_Construction(void)
135 {
136  m_pParent = NULL;
137 
138  m_Children.Create(sizeof(CSG_MetaData **), 0, TSG_Array_Growth::SG_ARRAY_GROWTH_1);
139 }
140 
141 //---------------------------------------------------------
143 {
144  Destroy();
145 }
146 
147 //---------------------------------------------------------
149 {
150  CSG_MetaData **m_pChildren = (CSG_MetaData **)m_Children.Get_Array();
151 
152  for(int i=0; i<Get_Children_Count(); i++)
153  {
154  delete(m_pChildren[i]);
155  }
156 
157  m_Children.Destroy();
158 
159 // m_pParent = NULL;
160 
161 // m_Name .Clear();
162 // m_Content .Clear();
163 
164  m_Prop_Names .Clear();
165  m_Prop_Values .Clear();
166 }
167 
168 
170 // //
172 
173 //---------------------------------------------------------
175 {
176  return( Ins_Child(-1) );
177 }
178 
180 {
181  return( Ins_Child(Name, -1) );
182 }
183 
185 {
186  return( Ins_Child(Name, Content, -1) );
187 }
188 
189 CSG_MetaData * CSG_MetaData::Add_Child(const CSG_String &Name, double Content)
190 {
191  return( Ins_Child(Name, SG_Get_String(Content, -16), -1) );
192 }
193 
195 {
196  return( Ins_Child(Name, CSG_String::Format(SG_T("%d"), Content), -1) );
197 }
198 
200 {
201  return( Ins_Child(Name, CSG_String::Format(SG_T("%lld"), Content), -1) );
202 }
203 
204 CSG_MetaData * CSG_MetaData::Add_Child(const CSG_MetaData &MetaData, bool bAddChildren)
205 {
206  return( Ins_Child(MetaData, -1, bAddChildren) );
207 }
208 
209 
211 // //
213 
214 //---------------------------------------------------------
216 {
217  if( !m_Children.Inc_Array() )
218  {
219  return( NULL );
220  }
221 
222  CSG_MetaData **pChildren = (CSG_MetaData **)m_Children.Get_Array();
223 
224  if( Position < 0 || Position >= Get_Children_Count() )
225  {
226  Position = Get_Children_Count() - 1;
227  }
228 
229  for(int i=Get_Children_Count()-1; i>Position; i--)
230  {
231  pChildren[i] = pChildren[i - 1];
232  }
233 
234  return( pChildren[Position] = new CSG_MetaData(this) );
235 }
236 
237 //---------------------------------------------------------
238 CSG_MetaData * CSG_MetaData::Ins_Child(const CSG_String &Name, const CSG_String &Content, int Position)
239 {
240  CSG_MetaData *pChild = Ins_Child(Position);
241 
242  if( pChild )
243  {
244  pChild->m_Name = Name;
245  pChild->m_Content = Content;
246  }
247 
248  return( pChild );
249 }
250 
251 CSG_MetaData * CSG_MetaData::Ins_Child(const CSG_String &Name, int Position)
252 {
253  return( Ins_Child(Name, CSG_String(""), Position) );
254 }
255 
256 CSG_MetaData * CSG_MetaData::Ins_Child(const CSG_String &Name, double Content, int Position)
257 {
258  return( Ins_Child(Name, SG_Get_String(Content, -16), Position) );
259 }
260 
261 CSG_MetaData * CSG_MetaData::Ins_Child(const CSG_String &Name, int Content, int Position)
262 {
263  return( Ins_Child(Name, CSG_String::Format(SG_T("%d"), Content), Position) );
264 }
265 
266 CSG_MetaData * CSG_MetaData::Ins_Child(const CSG_String &Name, sLong Content, int Position)
267 {
268  return( Ins_Child(Name, CSG_String::Format(SG_T("%lld"), Content), Position) );
269 }
270 
271 CSG_MetaData * CSG_MetaData::Ins_Child(const CSG_MetaData &MetaData, int Position, bool bAddChildren)
272 {
273  CSG_MetaData *pChild = Ins_Child(Position);
274 
275  if( pChild )
276  {
277  pChild->Assign(MetaData, bAddChildren);
278  }
279 
280  return( pChild );
281 }
282 
283 
285 // //
287 
288 //---------------------------------------------------------
289 bool CSG_MetaData::Mov_Child(int from_Index, int to_Index)
290 {
291  if( from_Index < 0 || from_Index >= Get_Children_Count()
292  || to_Index < 0 || to_Index >= Get_Children_Count() )
293  {
294  return( false );
295  }
296 
297  if( from_Index != to_Index )
298  {
299  CSG_MetaData **pChildren = (CSG_MetaData **)m_Children.Get_Array();
300  CSG_MetaData *pChild = pChildren[from_Index];
301 
302  if( from_Index < to_Index )
303  {
304  for(int i=from_Index; i<to_Index; i++)
305  {
306  pChildren[i] = pChildren[i + 1];
307  }
308  }
309  else // if( from_Index > to_Index )
310  {
311  for(int i=from_Index; i>to_Index; i--)
312  {
313  pChildren[i] = pChildren[i - 1];
314  }
315  }
316 
317  pChildren[to_Index] = pChild;
318  }
319 
320  return( true );
321 }
322 
323 
325 // //
327 
328 //---------------------------------------------------------
329 bool CSG_MetaData::Del_Child(int Index)
330 {
331  if( Index >= 0 && Index < Get_Children_Count() )
332  {
333  CSG_MetaData **pChildren = (CSG_MetaData **)m_Children.Get_Array();
334 
335  delete(pChildren[Index]);
336 
337  for(int i=Index, j=Index+1; j<Get_Children_Count(); i++, j++)
338  {
339  pChildren[i] = pChildren[j];
340  }
341 
342  m_Children.Dec_Array();
343 
344  return( true );
345  }
346 
347  return( false );
348 }
349 
350 //---------------------------------------------------------
352 {
353  if( &MetaData != this )
354  {
355  for(int i=0; i<MetaData.Get_Children_Count(); i++)
356  {
357  Add_Child(MetaData[i], true);
358  }
359  }
360 
361  return( true );
362 }
363 
364 //---------------------------------------------------------
372 //---------------------------------------------------------
373 bool CSG_MetaData::Del_Children(int Depth, const SG_Char *Name)
374 {
375  if( Depth < 0 )
376  {
377  // nop
378  }
379  else if( Name && *Name )
380  {
381  for(int i=Get_Children_Count()-1; i>=0; i--)
382  {
383  if( Get_Child(i)->Get_Name().CmpNoCase(Name) )
384  {
385  Get_Child(i)->Del_Children(Depth, Name);
386  }
387  else if( Depth > 0 )
388  {
389  Get_Child(i)->Del_Children(Depth - 1, Name);
390  }
391  else
392  {
393  Del_Child(i);
394  }
395  }
396  }
397  else if( Depth > 0 )
398  {
399  for(int i=0; i<Get_Children_Count(); i++)
400  {
401  Get_Child(i)->Del_Children(Depth - 1, Name);
402  }
403  }
404  else
405  {
406  for(int i=0; i<Get_Children_Count(); i++)
407  {
408  delete(Get_Child(i));
409  }
410 
411  m_Children.Destroy();
412  }
413 
414  return( true );
415 }
416 
417 //---------------------------------------------------------
418 int CSG_MetaData::_Get_Child(const CSG_String &Name) const
419 {
420  for(int i=0; i<Get_Children_Count(); i++)
421  {
422  if( Name.CmpNoCase(Get_Child(i)->Get_Name()) == 0 )
423  {
424  return( i );
425  }
426  }
427 
428  return( -1 );
429 }
430 
431 
433 // //
435 
436 //---------------------------------------------------------
437 bool CSG_MetaData::Cmp_Name(const CSG_String &String, bool bNoCase) const
438 {
439  return( bNoCase ? !m_Name.CmpNoCase(String) : !m_Name.Cmp(String) );
440 }
441 
442 
444 // //
446 
447 //---------------------------------------------------------
448 bool CSG_MetaData::Get_Content(const CSG_String &Name, CSG_String &Value) const
449 {
450  const SG_Char *cString = Name.is_Empty() ? Get_Content().c_str() : Get_Content(Name);
451 
452  if( cString )
453  {
454  Value = cString;
455 
456  return( true );
457  }
458 
459  return( false );
460 }
461 
462 //---------------------------------------------------------
463 bool CSG_MetaData::Get_Content(const CSG_String &Name, double &Value) const
464 {
465  CSG_String s;
466 
467  return( Get_Content(Name, s) && s.asDouble(Value) );
468 }
469 
470 //---------------------------------------------------------
471 bool CSG_MetaData::Get_Content(const CSG_String &Name, int &Value) const
472 {
473  CSG_String s;
474 
475  return( Get_Content(Name, s) && s.asInt(Value) );
476 }
477 
478 //---------------------------------------------------------
479 bool CSG_MetaData::Get_Content(const CSG_String &Name, sLong &Value) const
480 {
481  CSG_String s;
482 
483  return( Get_Content(Name, s) && s.asLongLong(Value) );
484 }
485 
487 // //
489 
490 //---------------------------------------------------------
491 void CSG_MetaData::Fmt_Content(const char *Format, ...)
492 {
493  wxString s;
494 
495  va_list argptr;
496 
497 #ifdef _SAGA_LINUX
498  wxString _Format(Format); _Format.Replace("%s", "%ls"); // workaround as we only use wide characters since wx 2.9.4 so interpret strings as multibyte
499  va_start(argptr, _Format);
500  s.PrintfV(_Format, argptr);
501 #else
502  va_start(argptr, Format);
503  s.PrintfV(Format, argptr);
504 #endif
505 
506  m_Content = CSG_String(&s);
507 
508  va_end(argptr);
509 }
510 
511 //---------------------------------------------------------
512 void CSG_MetaData::Fmt_Content(const wchar_t *Format, ...)
513 {
514  wxString s;
515 
516  va_list argptr;
517 
518 #ifdef _SAGA_LINUX
519  wxString _Format(Format); _Format.Replace("%s", "%ls"); // workaround as we only use wide characters since wx 2.9.4 so interpret strings as multibyte
520  va_start(argptr, _Format);
521  s.PrintfV(_Format, argptr);
522 #else
523  va_start(argptr, Format);
524  s.PrintfV(Format, argptr);
525 #endif
526 
527  m_Content = CSG_String(&s);
528 
529  va_end(argptr);
530 }
531 
532 //---------------------------------------------------------
533 bool CSG_MetaData::Cmp_Content(const CSG_String &String, bool bNoCase) const
534 {
535  return( bNoCase ? !m_Content.CmpNoCase(String) : !m_Content.Cmp(String) );
536 }
537 
538 
540 // //
542 
543 //---------------------------------------------------------
544 bool CSG_MetaData::Add_Property(const CSG_String &Name, const CSG_String &Value)
545 {
546  if( !Value.is_Empty() &&_Get_Property(Name) < 0 )
547  {
548  m_Prop_Names .Add(Name );
549  m_Prop_Values.Add(Value);
550 
551  return( true );
552  }
553 
554  return( false );
555 }
556 
557 bool CSG_MetaData::Add_Property(const CSG_String &Name, double Value)
558 {
559  return( Add_Property(Name, CSG_String::Format(SG_T("%f"), Value)) );
560 }
561 
562 bool CSG_MetaData::Add_Property(const CSG_String &Name, int Value)
563 {
564  return( Add_Property(Name, CSG_String::Format(SG_T("%d"), Value)) );
565 }
566 
568 {
569  return( Add_Property(Name, CSG_String::Format(SG_T("%lld"), Value)) );
570 }
571 
572 //---------------------------------------------------------
574 {
575  for(int i=0; i<Get_Property_Count(); i++)
576  {
577  if( !Get_Property_Name(i).CmpNoCase(Name) )
578  {
579  return( Del_Property(i) );
580  }
581  }
582 
583  return( false );
584 }
585 
587 {
588  if( i >= 0 && i < Get_Property_Count() )
589  {
590  m_Prop_Names .Del(i);
591  m_Prop_Values.Del(i);
592 
593  return( true );
594  }
595 
596  return( false );
597 }
598 
599 //---------------------------------------------------------
600 bool CSG_MetaData::Set_Property(const CSG_String &Name, const CSG_String &Value, bool bAddIfNotExists)
601 {
602  int Index;
603 
604  if( (Index = _Get_Property(Name)) >= 0 )
605  {
606  m_Prop_Values[Index] = Value;
607 
608  return( true );
609  }
610  else if( bAddIfNotExists )
611  {
612  m_Prop_Names .Add(Name);
613  m_Prop_Values .Add(Value);
614 
615  return( true );
616  }
617 
618  return( false );
619 }
620 
621 bool CSG_MetaData::Set_Property(const CSG_String &Name, double Value, bool bAddIfNotExists)
622 {
623  return( Set_Property(Name, CSG_String::Format(SG_T("%f"), Value, bAddIfNotExists)) );
624 }
625 
626 bool CSG_MetaData::Set_Property(const CSG_String &Name, int Value, bool bAddIfNotExists)
627 {
628  return( Set_Property(Name, CSG_String::Format(SG_T("%d"), Value, bAddIfNotExists)) );
629 }
630 
631 bool CSG_MetaData::Set_Property(const CSG_String &Name, sLong Value, bool bAddIfNotExists)
632 {
633  return( Set_Property(Name, CSG_String::Format(SG_T("%lld"), Value, bAddIfNotExists)) );
634 }
635 
636 //---------------------------------------------------------
637 bool CSG_MetaData::Get_Property(const CSG_String &Name, CSG_String &Value) const
638 {
639  const SG_Char *cString = Get_Property(Name);
640 
641  if( cString )
642  {
643  Value = cString;
644 
645  return( true );
646  }
647 
648  return( false );
649 }
650 
651 bool CSG_MetaData::Get_Property(const CSG_String &Name, double &Value) const
652 {
653  CSG_String s;
654 
655  return( Get_Property(Name, s) && s.asDouble(Value) );
656 }
657 
658 bool CSG_MetaData::Get_Property(const CSG_String &Name, int &Value) const
659 {
660  CSG_String s;
661 
662  return( Get_Property(Name, s) && s.asInt(Value) );
663 }
664 
665 bool CSG_MetaData::Get_Property(const CSG_String &Name, sLong &Value) const
666 {
667  CSG_String s;
668 
669  return( Get_Property(Name, s) && s.asLongLong(Value) );
670 }
671 
672 //---------------------------------------------------------
673 bool CSG_MetaData::Cmp_Property(const CSG_String &Name, const CSG_String &String, bool bNoCase) const
674 {
675  CSG_String s;
676 
677  return( Get_Property(Name, s) && (bNoCase ? !s.CmpNoCase(String) : !s.Cmp(String)) );
678 }
679 
680 //---------------------------------------------------------
681 int CSG_MetaData::_Get_Property(const CSG_String &Name) const
682 {
683  for(int i=0; i<m_Prop_Names.Get_Count(); i++)
684  {
685  if( Name.CmpNoCase(m_Prop_Names[i]) == 0 )
686  {
687  return( i );
688  }
689  }
690 
691  return( -1 );
692 }
693 
694 
696 // //
698 
699 //---------------------------------------------------------
701 {
702  CSG_String s;
703 
704  if( Flags == 0 )
705  {
706  for(int i=0; i<Get_Children_Count(); i++)
707  {
708  s += Get_Child(i)->Get_Name() + ":\t" + Get_Child(i)->Get_Content() + "\n";
709  }
710  }
711  else
712  {
713  wxXmlDocument XML;
714 
715  wxXmlNode *pRoot = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Get_Name().c_str());
716 
717  XML.SetRoot(pRoot);
718 
719  _Save(pRoot);
720 
721  wxStringOutputStream Stream;
722 
723  XML.Save(Stream);
724 
725  s = &Stream.GetString();
726 
727  if( Flags == 2 ) // remove <xml>
728  {
729  s = s.AfterFirst('\n');
730  }
731  }
732 
733  return( s );
734 }
735 
736 //---------------------------------------------------------
738 {
739  CSG_Table t;
740 
741  t.Add_Field("NAME" , SG_DATATYPE_String);
742  t.Add_Field("VALUE", SG_DATATYPE_String);
743 
744  for(int i=0; i<Get_Children_Count(); i++)
745  {
746  CSG_Table_Record *r = t.Add_Record();
747 
748  r->Set_Value(0, Get_Child(i)->Get_Name());
749  r->Set_Value(1, Get_Child(i)->Get_Content());
750  }
751 
752  return( t );
753 }
754 
755 
757 // //
759 
760 //---------------------------------------------------------
761 bool CSG_MetaData::Assign(const CSG_MetaData &MetaData, bool bAddChildren)
762 {
763  if( &MetaData != this )
764  {
765  Destroy();
766 
767  Set_Name (MetaData.Get_Name ());
768  Set_Content (MetaData.Get_Content());
769 
770  for(int i=0; i<MetaData.Get_Property_Count(); i++)
771  {
772  Add_Property(MetaData.Get_Property_Name(i), MetaData.Get_Property(i));
773  }
774 
775  if( bAddChildren )
776  {
777  Add_Children(MetaData);
778  }
779  }
780 
781  return( true );
782 }
783 
784 
786 // //
788 
789 //---------------------------------------------------------
790 bool CSG_MetaData::Load(const CSG_String &File, const SG_Char *Extension)
791 {
792  Destroy();
793 
794  //-----------------------------------------------------
795  if( File.Find("http://") == 0 )
796  {
797  CSG_String s(File.Right(File.Length() - CSG_String("http://").Length()));
798 
799  return( Load_HTTP(s.BeforeFirst('/'), s.AfterFirst('/')) );
800  }
801 
802  //-----------------------------------------------------
803  CSG_String _File(SG_File_Make_Path("", File, Extension));
804 
805  if( !SG_File_Exists(_File) )
806  {
807  return( false );
808  }
809 
810  //-----------------------------------------------------
811  if( SG_File_Cmp_Extension(_File, "json") )
812  {
813  return( Load_JSON(_File) );
814  }
815 
816  //-----------------------------------------------------
817  wxXmlDocument XML;
818 
819  if( XML.Load(_File.c_str()) )
820  {
821  _Load(XML.GetRoot());
822 
823  return( true );
824  }
825 
826  //-----------------------------------------------------
827  return( false );
828 }
829 
830 //---------------------------------------------------------
832 {
833  Destroy();
834 
835  wxXmlDocument XML;
836 
837  if( File.is_Reading() && XML.Load(*((wxInputStream *)File.Get_Stream())) )
838  {
839  _Load(XML.GetRoot());
840 
841  return( true );
842  }
843 
844  return( false );
845 }
846 
847 //---------------------------------------------------------
848 void CSG_MetaData::_Load(wxXmlNode *pNode)
849 {
850  m_Name = pNode->GetName ().wc_str();
851  m_Content = pNode->GetNodeContent().wc_str();
852 
853  //-----------------------------------------------------
854  wxXmlAttribute *pProperty = pNode->GetAttributes();
855 
856  while( pProperty )
857  {
858  Add_Property(&pProperty->GetName(), &pProperty->GetValue());
859 
860  pProperty = pProperty->GetNext();
861  }
862 
863  //-----------------------------------------------------
864  wxXmlNode *pChild = pNode->GetChildren();
865 
866  while( pChild )
867  {
868  if( pChild->GetType() != wxXML_TEXT_NODE )
869  {
870  Add_Child()->_Load(pChild);
871  }
872 
873  pChild = pChild->GetNext();
874  }
875 }
876 
877 
879 // //
881 
882 //---------------------------------------------------------
883 bool CSG_MetaData::Save(const CSG_String &File, const SG_Char *Extension) const
884 {
885  wxXmlDocument XML;
886 
887  wxXmlNode *pRoot = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Get_Name().c_str());
888 
889  XML.SetRoot(pRoot);
890 
891  _Save(pRoot);
892 
893  if( XML.Save(SG_File_Make_Path("", File, Extension).c_str()) )
894  {
895  return( true );
896  }
897 
898  return( false );
899 }
900 
901 //---------------------------------------------------------
902 bool CSG_MetaData::Save(CSG_File &File) const
903 {
904  wxXmlDocument XML;
905 
906  wxXmlNode *pRoot = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Get_Name().c_str());
907 
908  XML.SetRoot(pRoot);
909 
910  _Save(pRoot);
911 
912  if( File.is_Writing() && XML.Save(*((wxOutputStream *)File.Get_Stream())) )
913  {
914  return( true );
915  }
916 
917  return( false );
918 }
919 
920 //---------------------------------------------------------
921 void CSG_MetaData::_Save(wxXmlNode *pNode) const
922 {
923  int i;
924 
925  //-----------------------------------------------------
926  pNode->SetName (CSG_String(Get_Name().Length() ? Get_Name() : CSG_String("NODE")).c_str());
927  pNode->SetContent(Get_Content().c_str());
928 
929  if( Get_Content().Length() > 0 || (Get_Property_Count() == 0 && Get_Children_Count() == 0) )
930  {
931  wxXmlNode *pChild = new wxXmlNode(pNode, wxXML_TEXT_NODE, SG_T("TEXT"));
932 
933  pChild->SetContent(Get_Content().c_str());
934  }
935 
936  //-----------------------------------------------------
937  for(i=0; i<Get_Property_Count(); i++)
938  {
939  pNode->AddAttribute(Get_Property_Name(i).c_str(), Get_Property(i));
940  }
941 
942  //-----------------------------------------------------
943  for(i=Get_Children_Count()-1; i>=0; i--)
944  {
945  Get_Child(i)->_Save(new wxXmlNode(pNode, wxXML_ELEMENT_NODE, Get_Child(i)->Get_Name().c_str()));
946  }
947 }
948 
949 
951 // //
953 
954 //---------------------------------------------------------
956 {
957  Destroy();
958 
959  wxXmlDocument XML;
960 
961  wxMemoryInputStream Stream((const void *)_XML.b_str(), (size_t)_XML.Length());
962 
963  if( XML.Load(Stream) )
964  {
965  _Load(XML.GetRoot());
966 
967  return( true );
968  }
969 
970  return( false );
971 }
972 
973 //---------------------------------------------------------
975 {
976  wxXmlDocument XML;
977 
978  wxXmlNode *pRoot = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, Get_Name().c_str());
979 
980  XML.SetRoot(pRoot);
981 
982  _Save(pRoot);
983 
984  wxMemoryOutputStream Stream;
985 
986  if( XML.Save(Stream) )
987  {
988  CSG_Array s(sizeof(char), Stream.GetSize());
989 
990  Stream.CopyTo(s.Get_Array(), s.Get_Size());
991 
992  _XML = (const char *)s.Get_Array();
993 
994  return( true );
995  }
996 
997  return( false );
998 }
999 
1000 
1002 // //
1004 
1005 //---------------------------------------------------------
1006 bool CSG_MetaData::Load_HTTP(const CSG_String &Server, const CSG_String &Path, const SG_Char *Username, const SG_Char *Password)
1007 {
1008  Destroy();
1009 
1010  //-----------------------------------------------------
1011  wxHTTP HTTP;
1012 
1013  if( Username && *Username ) { HTTP.SetUser (Username); }
1014  if( Password && *Password ) { HTTP.SetPassword(Password); }
1015 
1016  wxString s = Server.c_str();
1017 
1018  if( s.Find("http://") == 0 )
1019  {
1020  s = s.Right(s.Length() - wxString("http://").Length());
1021  }
1022 
1023  if( !HTTP.Connect(s) )
1024  {
1025  return( false );
1026  }
1027 
1028  //-----------------------------------------------------
1029  s = Path.c_str();
1030 
1031  if( s[0] != '/' )
1032  {
1033  s.Prepend("/");
1034  }
1035 
1036  wxInputStream *pStream = HTTP.GetInputStream(s);
1037 
1038  if( !pStream )
1039  {
1040  return( false );
1041  }
1042 
1043  wxXmlDocument XML;
1044 
1045  if( XML.Load(*pStream) )
1046  {
1047  _Load(XML.GetRoot());
1048 
1049  delete(pStream);
1050 
1051  return( true );
1052  }
1053 
1054  delete(pStream);
1055 
1056  return( false );
1057 }
1058 
1059 
1061 // //
1063 
1064 //---------------------------------------------------------
1066 {
1067  return( false );
1068 }
1069 
1070 //---------------------------------------------------------
1072 {
1073  return( false );
1074 }
1075 
1076 
1078 // //
1080 
1081 //---------------------------------------------------------
1083 {
1084  CSG_File Stream; CSG_String JSON;
1085 
1086  if( Stream.Open(File, SG_FILE_R, false) && Stream.Read(JSON, (size_t)Stream.Length()) > 0 )
1087  {
1088  return( from_JSON(JSON) );
1089  }
1090 
1091  return( false );
1092 }
1093 
1094 //---------------------------------------------------------
1095 bool CSG_MetaData::Save_JSON(const CSG_String &File) const
1096 {
1097  return( false );
1098 }
1099 
1100 //---------------------------------------------------------
1102 {
1103  Destroy();
1104 
1105  Set_Name("root");
1106 
1107  CSG_MetaData *pNode = this;
1108 
1109  const SG_Char *pc = JSON.c_str();
1110 
1111  while( *pc )
1112  {
1113  CSG_String Element;
1114 
1115  for(bool bQuota=false;;)
1116  {
1117  SG_Char c = *pc++;
1118 
1119  if( !c || c == '\n' ) { break; } else
1120  {
1121  if( c == '\"' )
1122  {
1123  Element += c; bQuota = !bQuota;
1124  }
1125  else if( bQuota || (c != ' ' && c != '\t' && c != ',') )
1126  {
1127  Element += c;
1128  }
1129  }
1130  }
1131 
1132  //-------------------------------------------------
1133  if( Element.is_Empty() )
1134  {
1135  // nop
1136  }
1137  else if( Element.Find('[') >= 0 ) // array begins
1138  {
1139  pNode = pNode->Add_Child(Element.AfterFirst('\"').BeforeFirst('\"'));
1140 
1141  pNode->Add_Property("array", 1);
1142  }
1143  else if( Element.Find(']') >= 0 ) // array ends
1144  {
1145  if( pNode != this )
1146  {
1147  pNode = pNode->Get_Parent();
1148  }
1149  }
1150  else if( Element.Find('{') >= 0 ) // object begins
1151  {
1152  Element = Element.AfterFirst('\"').BeforeFirst('\"');
1153 
1154  if( !Element.is_Empty() )
1155  {
1156  pNode = pNode->Add_Child(Element);
1157  }
1158  else if( pNode->Get_Property("array") )
1159  {
1160  pNode = pNode->Add_Child(CSG_String::Format("%d", pNode->Get_Children_Count()));
1161  }
1162  }
1163  else if( Element.Find('}') >= 0 ) // object ends
1164  {
1165  if( pNode != this )
1166  {
1167  pNode = pNode->Get_Parent();
1168  }
1169  }
1170  else
1171  {
1172  CSG_String Key (Element.AfterFirst('\"').BeforeFirst('\"'));
1173  CSG_String Value(Element.AfterFirst(':'));
1174 
1175  if( Value.Find('\"') > -1 )
1176  {
1177  Value = Value.AfterFirst('\"').BeforeFirst('\"');
1178  }
1179 
1180  pNode->Add_Child(Key, Value);
1181  }
1182  }
1183 
1184  return( true );
1185 }
1186 
1187 //---------------------------------------------------------
1189 {
1190  return( false );
1191 }
1192 
1193 
1195 // //
1196 // //
1197 // //
1199 
1200 //---------------------------------------------------------
1202 {
1203  m_pHTTP = NULL;
1204 }
1205 
1206 //---------------------------------------------------------
1208 {
1209  return( Destroy() );
1210 }
1211 
1212 //---------------------------------------------------------
1213 CSG_HTTP::CSG_HTTP(const CSG_String &Server, const SG_Char *Username, const SG_Char *Password)
1214 {
1215  m_pHTTP = NULL;
1216 
1217  Create(Server, Username, Password);
1218 }
1219 
1220 //---------------------------------------------------------
1221 bool CSG_HTTP::Create(const CSG_String &Server, const SG_Char *Username, const SG_Char *Password)
1222 {
1223  Destroy();
1224 
1225  m_pHTTP = new wxHTTP;
1226 
1227  if( Username && *Username ) { m_pHTTP->SetUser (Username); }
1228  if( Password && *Password ) { m_pHTTP->SetPassword(Password); }
1229 
1230  wxString Host = Server.c_str();
1231 
1232  unsigned short Port = 80;
1233 
1234  #define SERVER_TRIM(s, p) { wxString sp(p); sp += "://"; if( s.Find(p) == 0 ) { s = s.Right(s.Length() - sp.Length()); } }
1235 
1236  SERVER_TRIM(Host, "https");
1237  SERVER_TRIM(Host, "http");
1238 
1239  if( Host.Find(":") >= 0 )
1240  {
1241  long _Port;
1242 
1243  if( Host.AfterLast(':').ToLong(&_Port) )
1244  {
1245  Port = (unsigned short)_Port;
1246  }
1247 
1248  Host = Host.BeforeLast(':');
1249  }
1250 
1251  if( !m_pHTTP->Connect(Host, Port) )
1252  {
1253  Destroy();
1254 
1255  return( false );
1256  }
1257 
1258  return( true );
1259 }
1260 
1261 //---------------------------------------------------------
1263 {
1264  Destroy();
1265 }
1266 
1267 //---------------------------------------------------------
1269 {
1270  if( m_pHTTP )
1271  {
1272  delete(m_pHTTP);
1273 
1274  m_pHTTP = NULL;
1275  }
1276 
1277  return( true );
1278 }
1279 
1280 //---------------------------------------------------------
1281 bool CSG_HTTP::is_Connected(void) const
1282 {
1283  return( m_pHTTP != NULL );
1284 }
1285 
1286 //---------------------------------------------------------
1287 wxInputStream * CSG_HTTP::_Request(const CSG_String &Request)
1288 {
1289  if( !is_Connected() )
1290  {
1291  return( NULL );
1292  }
1293 
1294  wxString s(Request.c_str());
1295 
1296  if( s[0] != '/' )
1297  {
1298  s.Prepend("/");
1299  }
1300 
1301  wxInputStream *pStream = m_pHTTP->GetInputStream(s);
1302 
1303  if( pStream && !pStream->CanRead() )
1304  {
1305  delete(pStream);
1306 
1307  return( NULL );
1308  }
1309 
1310  return( pStream );
1311 }
1312 
1313 //---------------------------------------------------------
1314 bool CSG_HTTP::Request(const CSG_String &Request, CSG_MetaData &Answer)
1315 {
1316  wxInputStream *pStream = _Request(Request); if( !pStream ) { return( false ); }
1317 
1318  wxXmlDocument XML;
1319 
1320  if( !XML.Load(*pStream) )
1321  {
1322  delete(pStream);
1323 
1324  return( false );
1325  }
1326 
1327  Answer.Destroy(); Answer._Load(XML.GetRoot());
1328 
1329  delete(pStream);
1330 
1331  return( true );
1332 }
1333 
1334 //---------------------------------------------------------
1335 bool CSG_HTTP::Request(const CSG_String &Request, CSG_Bytes &Answer)
1336 {
1337  wxInputStream *pStream = _Request(Request); if( !pStream ) { return( false ); }
1338 
1339 // if( pStream->GetSize() == ((size_t)-1) )
1340 // {
1341 // delete(pStream);
1342 //
1343 // return( false );
1344 // }
1345 
1346  Answer.Clear();
1347 
1348  while( pStream->CanRead() )
1349  {
1350  char Byte;
1351 
1352  pStream->Read(&Byte, sizeof(Byte));
1353 
1354  Answer += Byte;
1355  }
1356 
1357  delete(pStream);
1358 
1359  return( true );
1360 }
1361 
1362 //---------------------------------------------------------
1363 bool CSG_HTTP::Request(const CSG_String &Request, CSG_String &Answer)
1364 {
1365  wxInputStream *pStream = _Request(Request); if( !pStream ) { return( false ); }
1366 
1367  //if( pStream->GetSize() == ((size_t)-1) )
1368  //{
1369  // delete(pStream);
1370 
1371  // return( false );
1372  //}
1373 
1374  Answer.Clear();
1375 
1376  while( pStream->CanRead() )
1377  {
1378  char Byte;
1379 
1380  pStream->Read(&Byte, sizeof(Byte));
1381 
1382  Answer += Byte;
1383  }
1384 
1385  delete(pStream);
1386 
1387  return( true );
1388 }
1389 
1390 //---------------------------------------------------------
1391 bool CSG_HTTP::Request(const CSG_String &Request, const SG_Char *File)
1392 {
1393  wxInputStream *pStream = _Request(Request); if( !pStream ) { return( false ); }
1394 
1395  wxFileOutputStream *pFile = new wxFileOutputStream(File);
1396 
1397  if( !pFile )
1398  {
1399  delete(pStream);
1400 
1401  return( false );
1402  }
1403 
1404  pFile->Write(*pStream);
1405 
1406  delete(pFile);
1407 
1408  delete(pStream);
1409 
1410  return( true );
1411 }
1412 
1413 
1415 // //
1416 // //
1417 // //
1419 
1420 //---------------------------------------------------------
1421 #include <wx/protocol/ftp.h>
1422 
1423 //---------------------------------------------------------
1424 bool SG_FTP_Download(const CSG_String &Target_Directory, const CSG_String &Source, const SG_Char *Username, const SG_Char *Password, unsigned short Port, bool bBinary, bool bVerbose)
1425 {
1426  CSG_String _Source(Source); _Source.Trim();
1427 
1428  if( _Source.Find("ftp://") == 0 )
1429  {
1430  _Source = _Source.Right(_Source.Length() - CSG_String("ftp://").Length());
1431  }
1432 
1433  CSG_String ftpHost = _Source.BeforeFirst('/');
1434  CSG_String ftpDir = _Source.AfterFirst ('/').BeforeLast('/'); // ftpDir.Prepend("/");
1435  CSG_String ftpFile = _Source.AfterLast ('/');
1436 
1437  //-----------------------------------------------------
1438  wxFTP ftp;
1439 
1440  if( Username && *Username ) { ftp.SetUser (Username); }
1441  if( Password && *Password ) { ftp.SetPassword(Password); }
1442 
1443  if( !ftp.Connect(ftpHost.c_str(), Port) )
1444  {
1445  if( bVerbose )
1446  {
1447  SG_UI_Msg_Add_Error(_TL("Couldn't connect"));
1448  }
1449 
1450  return( false );
1451  }
1452 
1453  //-----------------------------------------------------
1454  if( !ftpDir.is_Empty() && !ftp.ChDir(ftpDir.c_str()) )
1455  {
1456  if( bVerbose )
1457  {
1458  SG_UI_Msg_Add_Error(CSG_String::Format("%s [%s]", _TL("Couldn't change to directory"), ftpDir.c_str()));
1459  }
1460 
1461  return( false );
1462  }
1463 
1464  if( ftp.GetFileSize(ftpFile.c_str()) == -1 )
1465  {
1466  if( bVerbose )
1467  {
1468  SG_UI_Msg_Add_Error(CSG_String::Format("%s [%s]", _TL("Couldn't get the file size"), ftpFile.c_str()));
1469  }
1470  }
1471 
1472  //-----------------------------------------------------
1473  wxInputStream *pStream = ftp.GetInputStream(ftpFile.c_str());
1474 
1475  if( !pStream )
1476  {
1477  if( bVerbose )
1478  {
1479  SG_UI_Msg_Add_Error(CSG_String::Format("%s [%s]", _TL("Couldn't get the file"), ftpFile.c_str()));
1480  }
1481 
1482  return( false );
1483  }
1484 
1485  //-----------------------------------------------------
1486  wxFileOutputStream *pFile = new wxFileOutputStream(SG_File_Make_Path(Target_Directory, ftpFile).c_str());
1487 
1488  if( !pFile )
1489  {
1490  if( bVerbose )
1491  {
1492  SG_UI_Msg_Add_Error(CSG_String::Format("%s [%s]", _TL("Couldn't create target file"), SG_File_Make_Path(Target_Directory, ftpFile).c_str()));
1493  }
1494 
1495  delete(pStream);
1496 
1497  return( false );
1498  }
1499 
1500  //-----------------------------------------------------
1501  pFile->Write(*pStream);
1502 
1503  delete(pFile);
1504  delete(pStream);
1505 
1506  return( true );
1507 }
1508 
1509 
1511 // //
1512 // //
1513 // //
1515 
1516 //---------------------------------------------------------
CSG_String::BeforeFirst
CSG_String BeforeFirst(char Character) const
Definition: api_string.cpp:666
CSG_MetaData::Destroy
void Destroy(void)
Definition: metadata.cpp:148
CSG_File::Open
virtual bool Open(const CSG_String &FileName, int Mode=SG_FILE_R, bool bBinary=true, int Encoding=SG_FILE_ENCODING_ANSI)
Definition: api_file.cpp:111
SG_T
#define SG_T(s)
Definition: api_core.h:531
CSG_MetaData::Del_Child
bool Del_Child(int Index)
Definition: metadata.cpp:329
SG_DATATYPE_String
@ SG_DATATYPE_String
Definition: api_core.h:997
_TL
#define _TL(s)
Definition: api_core.h:1480
CSG_HTTP::CSG_HTTP
CSG_HTTP(void)
Definition: metadata.cpp:1201
CSG_Array::Get_Size
sLong Get_Size(void) const
Definition: api_core.h:327
CSG_File::Get_Stream
class wxStreamBase * Get_Stream(void) const
Definition: api_core.h:1130
CSG_String::Length
size_t Length(void) const
Definition: api_string.cpp:172
CSG_String::b_str
const char * b_str(void) const
Definition: api_string.cpp:242
CSG_Strings::Del
bool Del(int Index)
Definition: api_core.h:713
CSG_MetaData::Get_Children_Count
int Get_Children_Count(void) const
Definition: metadata.h:149
CSG_MetaData::Load_HTTP
bool Load_HTTP(const CSG_String &Server, const CSG_String &Path, const SG_Char *Username=NULL, const SG_Char *Password=NULL)
Definition: metadata.cpp:1006
CSG_MetaData::Get_Content
const CSG_String & Get_Content(void) const
Definition: metadata.h:135
CSG_Table_Record
Definition: table.h:130
CSG_MetaData::Set_Content
void Set_Content(const CSG_String &Content)
Definition: metadata.h:142
CSG_MetaData::~CSG_MetaData
virtual ~CSG_MetaData(void)
Definition: metadata.cpp:142
SG_Get_String
SAGA_API_DLL_EXPORT CSG_String SG_Get_String(double Value, int Precision=-99)
Definition: api_string.cpp:1337
CSG_String::asInt
int asInt(void) const
Definition: api_string.cpp:722
CSG_MetaData::Del_Property
bool Del_Property(const CSG_String &Name)
Definition: metadata.cpp:573
SG_File_Cmp_Extension
SAGA_API_DLL_EXPORT bool SG_File_Cmp_Extension(const CSG_String &FileName, const CSG_String &Extension)
Definition: api_file.cpp:928
CSG_MetaData::Set_Property
bool Set_Property(const CSG_String &Name, const CSG_String &Value, bool bAddIfNotExists=true)
Definition: metadata.cpp:600
CSG_MetaData::from_JSON
bool from_JSON(const CSG_String &JSON)
Definition: metadata.cpp:1101
CSG_MetaData::Save
bool Save(const CSG_String &File, const SG_Char *Extension=NULL) const
Definition: metadata.cpp:883
CSG_MetaData::Get_Child
CSG_MetaData * Get_Child(int Index) const
Definition: metadata.h:150
CSG_HTTP::~CSG_HTTP
virtual ~CSG_HTTP(void)
Definition: metadata.cpp:1262
CSG_MetaData::Get_Property_Count
int Get_Property_Count(void) const
Definition: metadata.h:179
CSG_MetaData::Get_Name
const CSG_String & Get_Name(void) const
Definition: metadata.h:132
SG_FILE_R
@ SG_FILE_R
Definition: api_core.h:1101
CSG_File::Read
size_t Read(void *Buffer, size_t Size, size_t Count=1) const
Definition: api_file.cpp:322
CSG_File
Definition: api_core.h:1116
CSG_String::Cmp
int Cmp(const CSG_String &String) const
Definition: api_string.cpp:515
CSG_MetaData::Get_Property
const SG_Char * Get_Property(int i) const
Definition: metadata.h:181
CSG_String::BeforeLast
CSG_String BeforeLast(char Character) const
Definition: api_string.cpp:677
CSG_Bytes::Clear
bool Clear(void)
Definition: api_memory.cpp:844
CSG_HTTP::Destroy
bool Destroy(void)
Definition: metadata.cpp:1268
SG_File_Exists
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
Definition: api_file.cpp:834
CSG_MetaData::Cmp_Name
bool Cmp_Name(const CSG_String &String, bool bNoCase=true) const
Definition: metadata.cpp:437
CSG_Strings::Clear
void Clear(void)
Definition: api_core.h:728
CSG_MetaData::Ins_Child
CSG_MetaData * Ins_Child(int Position)
Definition: metadata.cpp:215
CSG_MetaData::from_XML
bool from_XML(const CSG_String &XML)
Definition: metadata.cpp:955
CSG_String::Trim
int Trim(bool fromRight=false)
Definition: api_string.cpp:590
CSG_Strings::Add
bool Add(const CSG_Strings &Strings)
Definition: api_string.cpp:1022
CSG_MetaData::CSG_MetaData
CSG_MetaData(void)
Definition: metadata.cpp:76
CSG_HTTP::m_pHTTP
class wxHTTP * m_pHTTP
Definition: metadata.h:260
CSG_Array::Destroy
bool Destroy(void)
Definition: api_memory.cpp:291
CSG_MetaData::Del_Children
bool Del_Children(int Depth=0, const SG_Char *Name=NULL)
Definition: metadata.cpp:373
CSG_File::is_Writing
bool is_Writing(void) const
Definition: api_core.h:1137
CSG_HTTP::Create
bool Create(void)
Definition: metadata.cpp:1207
sLong
signed long long sLong
Definition: api_core.h:158
CSG_MetaData::Add_Property
bool Add_Property(const CSG_String &Name, const CSG_String &Value)
Definition: metadata.cpp:544
CSG_Array::Create
void * Create(const CSG_Array &Array)
Definition: api_memory.cpp:250
CSG_Array::Get_Array
void * Get_Array(void) const
Definition: api_core.h:336
CSG_Bytes
Definition: api_core.h:804
CSG_MetaData::Add_Children
bool Add_Children(const CSG_MetaData &MetaData)
Definition: metadata.cpp:351
CSG_MetaData::Assign
bool Assign(const CSG_MetaData &MetaData, bool bAddChildren=true)
Definition: metadata.cpp:761
CSG_String::Format
static CSG_String Format(const char *Format,...)
Definition: api_string.cpp:270
CSG_String::Find
int Find(char Character, bool fromEnd=false) const
Definition: api_string.cpp:616
CSG_Table::Add_Field
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
Definition: table.cpp:487
CSG_MetaData::Save_JSON
bool Save_JSON(const CSG_String &File) const
Definition: metadata.cpp:1095
CSG_Table
Definition: table.h:283
CSG_MetaData::Mov_Child
bool Mov_Child(int from_Index, int to_Index)
Definition: metadata.cpp:289
CSG_MetaData::Cmp_Property
bool Cmp_Property(const CSG_String &Name, const CSG_String &String, bool bNoCase=false) const
Definition: metadata.cpp:673
CSG_File::Length
sLong Length(void) const
Definition: api_file.cpp:220
CSG_HTTP::is_Connected
bool is_Connected(void) const
Definition: metadata.cpp:1281
CSG_String::CmpNoCase
int CmpNoCase(const CSG_String &String) const
Definition: api_string.cpp:521
CSG_String::AfterFirst
CSG_String AfterFirst(char Character) const
Definition: api_string.cpp:644
CSG_MetaData::to_XML
bool to_XML(CSG_String &XML) const
Definition: metadata.cpp:974
CSG_String::Clear
void Clear(void)
Definition: api_string.cpp:259
CSG_MetaData::Get_Parent
CSG_MetaData * Get_Parent(void) const
Definition: metadata.h:147
SG_Char
#define SG_Char
Definition: api_core.h:530
CSG_Array::Inc_Array
bool Inc_Array(sLong nValues=1)
Definition: api_memory.cpp:414
CSG_Array
Definition: api_core.h:308
CSG_MetaData::Get_Table
class CSG_Table Get_Table(int Flags=0) const
Definition: metadata.cpp:737
CSG_String
Definition: api_core.h:557
CSG_Array::Dec_Array
bool Dec_Array(bool bShrink=true)
Definition: api_memory.cpp:425
CSG_MetaData
Definition: metadata.h:88
CSG_MetaData::Load
bool Load(const CSG_String &File, const SG_Char *Extension=NULL)
Definition: metadata.cpp:790
CSG_String::is_Empty
bool is_Empty(void) const
Definition: api_string.cpp:178
metadata.h
CSG_Table_Record::Set_Value
bool Set_Value(int Field, const CSG_String &Value)
Definition: table_record.cpp:270
CSG_String::asLongLong
sLong asLongLong(void) const
Definition: api_string.cpp:744
CSG_MetaData::to_WKT
bool to_WKT(CSG_String &WKT) const
Definition: metadata.cpp:1071
CSG_MetaData::Get_Property_Name
const CSG_String & Get_Property_Name(int i) const
Definition: metadata.h:180
CSG_HTTP::Request
bool Request(const CSG_String &Request, CSG_Bytes &Answer)
Definition: metadata.cpp:1335
CSG_MetaData::Set_Name
void Set_Name(const CSG_String &Name)
Definition: metadata.h:133
CSG_MetaData::Create
bool Create(void)
Definition: metadata.cpp:81
CSG_String::AfterLast
CSG_String AfterLast(char Character) const
Definition: api_string.cpp:655
CSG_MetaData::Fmt_Content
void Fmt_Content(const char *Format,...)
Definition: metadata.cpp:491
CSG_MetaData::from_WKT
bool from_WKT(const CSG_String &WKT)
Definition: metadata.cpp:1065
CSG_String::asDouble
double asDouble(void) const
Definition: api_string.cpp:760
SG_File_Make_Path
SAGA_API_DLL_EXPORT CSG_String SG_File_Make_Path(const CSG_String &Directory, const CSG_String &Name)
Definition: api_file.cpp:903
CSG_String::c_str
const SG_Char * c_str(void) const
Definition: api_string.cpp:236
CSG_MetaData::Cmp_Content
bool Cmp_Content(const CSG_String &String, bool bNoCase=false) const
Definition: metadata.cpp:533
CSG_Strings::Get_Count
int Get_Count(void) const
Definition: api_core.h:706
SG_UI_Msg_Add_Error
void SG_UI_Msg_Add_Error(const char *Message)
Definition: api_callback.cpp:544
CSG_MetaData::Add_Child
CSG_MetaData * Add_Child(void)
Definition: metadata.cpp:174
SG_FTP_Download
bool SG_FTP_Download(const CSG_String &Target_Directory, const CSG_String &Source, const SG_Char *Username, const SG_Char *Password, unsigned short Port, bool bBinary, bool bVerbose)
Definition: metadata.cpp:1424
CSG_MetaData::asText
CSG_String asText(int Flags=0) const
Definition: metadata.cpp:700
CSG_Table::Add_Record
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
Definition: table.cpp:799
table.h
SERVER_TRIM
#define SERVER_TRIM(s, p)
CSG_File::is_Reading
bool is_Reading(void) const
Definition: api_core.h:1136
CSG_String::Right
CSG_String Right(size_t count) const
Definition: api_string.cpp:693
CSG_MetaData::Load_JSON
bool Load_JSON(const CSG_String &File)
Definition: metadata.cpp:1082
CSG_MetaData::to_JSON
bool to_JSON(CSG_String &JSON) const
Definition: metadata.cpp:1188