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