Utils.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/ado/Utils.cpp
22 
23  \brief Utility functions for ADO.
24 */
25 
26 // TerraLib
27 #include "../common/Exception.h"
28 #include "../common/Translator.h"
29 #include "../datatype.h"
30 #include "../dataaccess/dataset/DataSetType.h"
31 #include "../dataaccess/dataset/ForeignKey.h"
32 #include "../dataaccess/dataset/CheckConstraint.h"
33 #include "../dataaccess/dataset/Constraint.h"
34 #include "../dataaccess/dataset/PrimaryKey.h"
35 #include "../dataaccess/dataset/UniqueKey.h"
36 #include "../dataaccess/utils/Utils.h"
37 #include "../geometry/GeometryProperty.h"
38 #include "../geometry/Envelope.h"
39 #include "../geometry/Enums.h"
40 #include "../memory/DataSet.h"
41 #include "../memory/DataSetItem.h"
42 #include "DataSet.h"
43 #include "Config.h"
44 #include "Utils.h"
45 #include "Globals.h"
46 
47 // Boost
48 #include <boost/format.hpp>
49 #include <boost/lexical_cast.hpp>
50 
51 inline void TESTHR( HRESULT hr )
52 {
53  if( FAILED(hr) ) _com_issue_error( hr );
54 }
55 
56 void te::ado::Blob2Variant(const char* blob, int size, _variant_t & var)
57 {
58  char *pByte;
59 
60  SAFEARRAY FAR* psa;
61  SAFEARRAYBOUND rgsabound[1];
62  rgsabound[0].lLbound = 0;
63  rgsabound[0].cElements = size;
64 
65  psa = SafeArrayCreate(VT_I1, 1, rgsabound);
66 
67  if(SafeArrayAccessData(psa,(void **)&pByte) == NOERROR)
68  memcpy(pByte, blob, size);
69  SafeArrayUnaccessData(psa);
70 
71  var.vt = VT_ARRAY | VT_UI1;
72  var.parray = psa;
73 }
74 
75 std::string te::ado::MakeConnectionStr(const std::map<std::string, std::string>& dsInfo)
76 {
77  std::map<std::string, std::string>::const_iterator it = dsInfo.find("PROVIDER");
78  std::map<std::string, std::string>::const_iterator it_end = dsInfo.end();
79  std::string connInfo;
80 
81  if(it != it_end)
82  connInfo += "Provider=" + it->second;
83 
84  it = dsInfo.find("DB_NAME");
85 
86  if(it != it_end)
87  connInfo += ";Data Source=" + it->second;
88 
89  it = dsInfo.find("USER_NAME");
90 
91  if(it != it_end)
92  connInfo += ";User Id=" + it->second;
93 
94  it = dsInfo.find("PASSWORD");
95 
96  if(it != it_end)
97  connInfo += ";Jet OLEDB:Database Password=" + it->second + ";";
98 
99  return connInfo;
100 }
101 
102 void te::ado::Variant2Blob(const _variant_t var, int size, char* & blob)
103 {
104  try
105  {
106  char *cdata = 0;
107  if(var.vt == (VT_ARRAY | VT_UI1))
108  {
109  SafeArrayAccessData(var.parray,(void **)&cdata);
110  blob = new char[size];
111  memcpy(blob, cdata, size);
112  SafeArrayUnaccessData(var.parray);
113  }
114  }
115  catch(_com_error& e)
116  {
117  throw te::common::Exception((LPCSTR)e.ErrorMessage());
118  }
119 }
120 
121 ADOX::DataTypeEnum te::ado::Convert2Ado(int terralib)
122 {
123  switch(terralib)
124  {
125  case te::dt::CHAR_TYPE:
126  case te::dt::UCHAR_TYPE:
127  return ADOX::adWChar;
128  break;
129 
130  case te::dt::INT16_TYPE:
131  return ADOX::adInteger;
132  break;
133 
134  case te::dt::INT32_TYPE:
135  return ADOX::adInteger;
136  break;
137 
138  case te::dt::INT64_TYPE:
139  return ADOX::adInteger;
140  break;
141 
143  return ADOX::adDate;
144 
145  case te::dt::FLOAT_TYPE:
146  case te::dt::DOUBLE_TYPE:
148  return ADOX::adDouble;
149  break;
150 
151  case te::dt::STRING_TYPE:
152  return ADOX::adLongVarWChar;
153  break;
154 
156  return ADOX::adBoolean;
157  break;
158 
160  return ADOX::adLongVarBinary;
161  break;
162 
164  case te::dt::ARRAY_TYPE:
165  return ADOX::adLongVarBinary;
166  break;
167 
168  default:
169  throw te::common::Exception(TE_TR("The informed type could not be mapped to ADO type system!"));
170  break;
171  }
172 }
173 
174 std::string te::ado::GetAdoStringType(const int& terralib)
175 {
176  ADOX::DataTypeEnum aType = te::ado::Convert2Ado(terralib);
177 
178  switch(aType)
179  {
180  case ADOX::adInteger:
181  return "Integer";
182  break;
183 
184  case ADOX::adDate:
185  return "Date/Time";
186  break;
187 
188  case ADOX::adDouble:
189  return "Double";
190  break;
191 
192  case ADOX::adBoolean:
193  return "Yes/No";
194  break;
195 
196  case ADOX::adLongVarBinary:
197  return "Memo";
198  break;
199 
200  case ADOX::adLongVarWChar:
201  return "Text";
202  break;
203  }
204 
205  return "";
206 }
207 
208 void te::ado::Convert2Ado(const te::gm::Geometry* geo, _variant_t & var)
209 {
210  long size = (long)geo->getWkbSize();
211 
212  char* wkb = new char[size];
213 
214  geo->getWkb(wkb, te::common::NDR);
215 
216  unsigned int newWkbSize = size+4;
217 
218  char* newWkb = new char[newWkbSize];
219 
220  memcpy(newWkb, wkb, size);
221 
222  unsigned int srid = geo->getSRID();
223 
224  memcpy(newWkb+size, &srid, 4);
225 
226  te::ado::Blob2Variant(newWkb, newWkbSize, var);
227 }
228 
229 int te::ado::Convert2Terralib(ADOX::DataTypeEnum adoType)
230 {
231  switch(adoType)
232  {
233  case ADOX::adBoolean:
234  return te::dt::BOOLEAN_TYPE;
235  break;
236 
237  case ADOX::adEmpty:
238  return te::dt::VOID_TYPE;
239  break;
240 
241  case ADOX::adBinary:
242  case ADOX::adVarBinary:
243  case ADOX::adLongVarBinary:
245  break;
246 
247  case ADOX::adVarWChar:
248  case ADOX::adWChar:
249  case ADOX::adVarChar:
250  case ADOX::adLongVarChar:
251  case ADOX::adLongVarWChar:
252  case ADOX::adBSTR:
253  case ADOX::adChar:
254  return te::dt::STRING_TYPE;
255  break;
256 
257  case ADOX::adBigInt:
258  return te::dt::INT16_TYPE;
259  break;
260 
261  case ADOX::adSingle:
262  return te::dt::FLOAT_TYPE;
263  break;
264 
265  case ADOX::adDouble:
266  case ADOX::adDecimal:
267  return te::dt::DOUBLE_TYPE;
268  break;
269 
270  case ADOX::adInteger:
271  return te::dt::INT32_TYPE;
272  break;
273 
274  case ADOX::adTinyInt:
275  case ADOX::adSmallInt:
276  return te::dt::INT16_TYPE;
277  break;
278 
279  case ADOX::adUnsignedBigInt:
280  return te::dt::UINT64_TYPE;
281  break;
282 
283  case ADOX::adUnsignedInt:
284  return te::dt::UINT32_TYPE;
285  break;
286 
287  case ADOX::adUnsignedSmallInt:
288  case ADOX::adUnsignedTinyInt:
289  return te::dt::UINT16_TYPE;
290  break;
291 
292  case ADOX::adDate:
293  case ADOX::adDBDate:
294  case ADOX::adDBTime:
295  case ADOX::adDBTimeStamp:
296  return te::dt::DATETIME_TYPE;
297  break;
298 
299  //case ADOX::adGUID:
300  //case ADOX::adError:
301  //case ADOX::adSingle:
302  //case ADOX::adDecimal:
303  //case ADOX::adNumeric:
304  //case ADOX::adChapter:
305  //case ADOX::adVarNumeric:
306  //case ADOX::adCurrency:
307  //case ADOX::adFileTime:
308  //case ADOX::adPropVariant:
309  //case ADOX::adUserDefined:
310 
311  default:
312  return te::dt::UNKNOWN_TYPE;
313  break;
314  }
315 }
316 
317 int te::ado::Convert2Terralib(::DataTypeEnum adoType)
318 {
319  switch(adoType)
320  {
321  case ::adBoolean:
322  return te::dt::BOOLEAN_TYPE;
323  break;
324 
325  case ::adEmpty:
326  return te::dt::VOID_TYPE;
327  break;
328 
329  case ::adBinary:
330  case ::adVarBinary:
331  case ::adLongVarBinary:
333  break;
334 
335  case ::adVarWChar:
336  case ::adWChar:
337  case ::adVarChar:
338  case ::adLongVarChar:
339  case ::adLongVarWChar:
340  case ::adBSTR:
341  case ::adChar:
342  return te::dt::STRING_TYPE;
343  break;
344 
345  case ::adBigInt:
346  return te::dt::INT16_TYPE;
347  break;
348 
349  case ::adSingle:
350  return te::dt::FLOAT_TYPE;
351  break;
352 
353  case ::adDouble:
354  case ::adDecimal:
355  return te::dt::DOUBLE_TYPE;
356  break;
357 
358  case ::adInteger:
359  return te::dt::INT32_TYPE;
360  break;
361 
362  case ::adTinyInt:
363  case ::adSmallInt:
364  return te::dt::INT16_TYPE;
365  break;
366 
367  case ::adUnsignedBigInt:
368  return te::dt::UINT64_TYPE;
369  break;
370 
371  case ::adUnsignedInt:
372  return te::dt::UINT32_TYPE;
373  break;
374 
375  case ::adUnsignedSmallInt:
376  case ::adUnsignedTinyInt:
377  return te::dt::UINT16_TYPE;
378  break;
379 
380  case ::adDate:
381  case ::adDBDate:
382  case ::adDBTime:
383  case ::adDBTimeStamp:
384  return te::dt::DATETIME_TYPE;
385  break;
386 
387  //case ::adGUID:
388  //case ::adError:
389  //case ::adSingle:
390  //case ::adDecimal:
391  //case ::adNumeric:
392  //case ::adChapter:
393  //case ::adVarNumeric:
394  //case ::adCurrency:
395  //case ::adFileTime:
396  //case ::adPropVariant:
397  //case ::adUserDefined:
398 
399  default:
400  return te::dt::UNKNOWN_TYPE;
401  break;
402  }
403 }
404 
406 {
407  te::dt::Property* prop = 0;
408 
409  _bstr_t cName = column->GetName();
410 
411  ADOX::DataTypeEnum cType = column->GetType();
412 
413  long cSize = column->GetDefinedSize();
414 
415  switch(cType)
416  {
417  case ::adBoolean:
418  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
419  break;
420 
421  case ::adVarWChar:
422  case ::adWChar:
423  case ::adVarChar:
424  case ::adLongVarChar:
425  case ::adLongVarWChar:
426  case ::adBSTR:
427  case ::adChar:
428  prop = new te::dt::StringProperty(std::string(cName), (te::dt::StringType)Convert2Terralib(cType), cSize);
429  break;
430 
431  case ADOX::adTinyInt:
432  case ADOX::adSmallInt:
433  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
434  break;
435 
436  case ADOX::adInteger:
437  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
438  break;
439 
440  case ADOX::adBigInt:
441  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
442  break;
443 
444  case ADOX::adDouble:
445  case ADOX::adDecimal:
446  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
447  break;
448 
449  case ::adUnsignedBigInt:
450  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
451  break;
452 
453  case ::adUnsignedInt:
454  prop = new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType));
455  break;
456 
457  case ::adUnsignedSmallInt:
458  case ::adUnsignedTinyInt:
459  prop = new te::dt::SimpleProperty(std::string(cName),Convert2Terralib(cType));
460  break;
461 
462  case ADOX::adLongVarBinary:
463  prop = new te::dt::ArrayProperty(std::string(cName), new te::dt::SimpleProperty(std::string(cName), Convert2Terralib(cType)));
464  break;
465 
466  case ADOX::adDate:
467  case ADOX::adDBDate:
468  prop = new te::dt::DateTimeProperty(std::string(cName), te::dt::DATE);
469  break;
470 
471  case ADOX::adDBTime:
472  prop = new te::dt::DateTimeProperty(std::string(cName), te::dt::TIME_DURATION);
473  break;
474 
475  case ADOX::adDBTimeStamp:
476  prop = new te::dt::DateTimeProperty(std::string(cName), te::dt::TIME_INSTANT);
477  break;
478 
479  default:
480  throw te::common::Exception(TE_TR("The informed column could not be mapped to TerraLib Data Set Type!"));
481  }
482 
483  return prop;
484 }
485 
486 std::vector<te::dt::Property*> te::ado::Convert2Terralib(ADOX::ColumnsPtr columns)
487 {
488  std::vector<te::dt::Property*> properties;
489 
490  for(long i = 0; i < columns->GetCount(); i++)
491  properties.push_back(Convert2Terralib(columns->GetItem(i)));
492 
493  return properties;
494 }
495 
497 {
498 
499  if(key->GetType() == ADOX::adKeyPrimary)
500  {
501  te::da::PrimaryKey* con = new te::da::PrimaryKey(std::string(key->GetName()));
502  con->setProperties(Convert2Terralib(key->GetColumns()));
503 
504  return con;
505  }
506  else if(key->GetType() == ADOX::adKeyForeign)
507  {
508  te::da::ForeignKey* con = new te::da::ForeignKey(std::string(key->GetName()));
509  con->setProperties(Convert2Terralib(key->GetColumns()));
510 
511  return con;
512  }
513  else if(key->GetType() == ADOX::adKeyUnique)
514  {
515  te::da::UniqueKey* con = new te::da::UniqueKey(std::string(key->GetName()));
516  con->setProperties(Convert2Terralib(key->GetColumns()));
517 
518  return con;
519  }
520  else
521  throw te::common::Exception(TE_TR("Unknown type!"));
522 
523 }
524 
526 {
527  switch(t)
528  {
530  return Globals::sm_geometryTypeName;
531  break;
532 
533  case te::gm::PointType:
534  return Globals::sm_pointTypeName;
535  break;
536 
538  return Globals::sm_lineStringTypeName;
539  break;
540 
541  case te::gm::PolygonType:
542  return Globals::sm_polygonTypeName;
543  break;
544 
546  return Globals::sm_multiPointTypeName;
547  break;
548 
550  return Globals::sm_multiLineStringTypeName;
551  break;
552 
554  return Globals::sm_multiPolygonTypeName;
555  break;
556 
558  return Globals::sm_curvePolygonTypeName;
559  break;
560 
562  return Globals::sm_polyhedralSurfaceTypeName;
563  break;
564 
566  return Globals::sm_geometryZTypeName;
567  break;
568 
569  case te::gm::PointZType:
570  return Globals::sm_pointZTypeName;
571  break;
572 
574  return Globals::sm_lineStringZTypeName;
575  break;
576 
578  return Globals::sm_polygonZTypeName;
579  break;
580 
582  return Globals::sm_multiPointZTypeName;
583  break;
584 
586  return Globals::sm_multiLineStringZTypeName;
587  break;
588 
590  return Globals::sm_multiPolygonZTypeName;
591  break;
592 
594  return Globals::sm_curvePolygonZTypeName;
595  break;
596 
598  return Globals::sm_polyhedralSurfaceZTypeName;
599  break;
600 
602  return Globals::sm_geometryMTypeName;
603  break;
604 
605  case te::gm::PointMType:
606  return Globals::sm_pointMTypeName;
607  break;
608 
610  return Globals::sm_lineStringMTypeName;
611  break;
612 
614  return Globals::sm_polygonMTypeName;
615  break;
616 
618  return Globals::sm_multiPointMTypeName;
619  break;
620 
622  return Globals::sm_multiLineStringMTypeName;
623  break;
624 
626  return Globals::sm_multiPolygonMTypeName;
627  break;
628 
630  return Globals::sm_curvePolygonMTypeName;
631  break;
632 
634  return Globals::sm_polyhedralSurfaceMTypeName;
635  break;
636 
638  return Globals::sm_geometryZMTypeName;
639  break;
640 
641  case te::gm::PointZMType:
642  return Globals::sm_pointZMTypeName;
643  break;
644 
646  return Globals::sm_lineStringZMTypeName;
647  break;
648 
650  return Globals::sm_polygonZMTypeName;
651  break;
652 
654  return Globals::sm_multiPointZMTypeName;
655  break;
656 
658  return Globals::sm_multiLineStringZMTypeName;
659  break;
660 
662  return Globals::sm_multiPolygonZMTypeName;
663  break;
664 
666  return Globals::sm_curvePolygonZMTypeName;
667  break;
668 
670  return Globals::sm_polyhedralSurfaceZMTypeName;
671  break;
672 
673  default:
674  return Globals::sm_geometryTypeName;
675  }
676 }
677 
679 {
680 
681  if(t == Globals::sm_geometryTypeName)
682  return te::gm::GeometryType;
683 
684  else if(t == Globals::sm_pointTypeName)
685  return te::gm::PointType;
686 
687 
688  else if(t == Globals::sm_lineStringTypeName)
689  return te::gm::LineStringType;
690 
691 
692  else if(t == Globals::sm_polygonTypeName)
693  return te::gm::PolygonType;
694 
695 
696  else if(t == Globals::sm_multiPointTypeName)
697  return te::gm::MultiPointType;
698 
699 
700  else if(t == Globals::sm_multiLineStringTypeName)
702 
703 
704  else if(t == Globals::sm_multiPolygonTypeName)
706 
707 
708  else if(t == Globals::sm_curvePolygonTypeName)
710 
711 
712  else if(t == Globals::sm_polyhedralSurfaceTypeName)
714 
715 
716  else if(t == Globals::sm_geometryZTypeName)
717  return te::gm::GeometryZType;
718 
719 
720  else if(t == Globals::sm_pointZTypeName)
721  return te::gm::PointZType;
722 
723 
724  else if(t == Globals::sm_lineStringZTypeName)
726 
727 
728  else if(t == Globals::sm_polygonZTypeName)
729  return te::gm::PolygonZType;
730 
731 
732  else if(t == Globals::sm_multiPointZTypeName)
734 
735 
736  else if(t == Globals::sm_multiLineStringZTypeName)
738 
739 
740  else if(t == Globals::sm_multiPolygonZTypeName)
742 
743 
744  else if(t == Globals::sm_curvePolygonZTypeName)
745 
747 
748  else if(t == Globals::sm_polyhedralSurfaceZTypeName)
750 
751 
752  else if(t == Globals::sm_geometryMTypeName)
753  return te::gm::GeometryMType;
754 
755 
756  else if(t == Globals::sm_pointMTypeName)
757  return te::gm::PointMType;
758 
759 
760  else if(t == Globals::sm_lineStringMTypeName)
762 
763 
764  else if(t == Globals::sm_polygonMTypeName)
765  return te::gm::PolygonMType;
766 
767 
768  else if(t == Globals::sm_multiPointMTypeName)
770 
771 
772  else if(t == Globals::sm_multiLineStringMTypeName)
774 
775 
776  else if(t == Globals::sm_multiPolygonMTypeName)
778 
779 
780  else if(t == Globals::sm_curvePolygonMTypeName)
782 
783 
784  else if(t == Globals::sm_polyhedralSurfaceMTypeName)
786 
787 
788  else if(t == Globals::sm_geometryZMTypeName)
789  return te::gm::GeometryZMType;
790 
791 
792  else if(t == Globals::sm_pointZMTypeName)
793  return te::gm::PointZMType;
794 
795 
796  else if(t == Globals::sm_lineStringZMTypeName)
798 
799 
800  else if(t == Globals::sm_polygonZMTypeName)
801  return te::gm::PolygonZMType;
802 
803 
804  else if(t == Globals::sm_multiPointZMTypeName)
806 
807 
808  else if(t == Globals::sm_multiLineStringZMTypeName)
810 
811 
812  else if(t == Globals::sm_multiPolygonZMTypeName)
814 
815 
816  else if(t == Globals::sm_curvePolygonZMTypeName)
818 
819 
820  else if(t == Globals::sm_polyhedralSurfaceZMTypeName)
822 
823  else
825 
826 }
827 
828 int te::ado::GetSRID(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
829 {
830  _RecordsetPtr recset;
831  TESTHR(recset.CreateInstance(__uuidof(Recordset)));
832 
833  std::string sel = "SELECT * FROM geometry_columns where f_table_name = '";
834  sel += tableName + "' and f_geometry_column = '" + geomPropName + "'";
835 
836  _variant_t variantSel;
837  variantSel.SetString(sel.c_str());
838 
839  try
840  {
841  TESTHR(recset->Open(variantSel, _variant_t((IDispatch *)adoConn),
842  adOpenStatic, adLockReadOnly, adCmdText));
843  }
844  catch(_com_error& e)
845  {
846  throw te::common::Exception((LPCSTR)e.ErrorMessage());
847  }
848 
849  return (int32_t)recset->GetFields()->GetItem("srid")->GetValue();
850 }
851 
852 te::gm::GeomType te::ado::GetType(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
853 {
854  _RecordsetPtr recset;
855  TESTHR(recset.CreateInstance(__uuidof(Recordset)));
856 
857  std::string sel = "SELECT * FROM geometry_columns where f_table_name = '";
858  sel += tableName + "' and f_geometry_column = '" + geomPropName + "'";
859 
860  _variant_t variantSel;
861  variantSel.SetString(sel.c_str());
862 
863  try
864  {
865  TESTHR(recset->Open(variantSel, _variant_t((IDispatch *)adoConn),
866  adOpenStatic, adLockReadOnly, adCmdText));
867  }
868  catch(_com_error& e)
869  {
870  throw te::common::Exception((LPCSTR)e.ErrorMessage());
871  }
872 
873  std::string type = (LPCSTR)(_bstr_t)recset->GetFields()->GetItem("type")->GetValue();
874 
875  return GetGeometryType(type);
876 }
877 
878 bool te::ado::IsGeomProperty(_ConnectionPtr adoConn, std::string tableName, std::string columnName)
879 {
880  ADOX::_CatalogPtr pCatalog;
881 
882  TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
883 
884  try
885  {
886  pCatalog->PutActiveConnection(variant_t((IDispatch *)adoConn));
887 
888  for(long i = 0; i < pCatalog->GetTables()->Count; i++)
889  {
890  if(std::string(pCatalog->GetTables()->GetItem(i)->GetName()) == "geometry_columns")
891  {
892  _RecordsetPtr recset;
893  TESTHR(recset.CreateInstance(__uuidof(Recordset)));
894 
895  TESTHR(recset->Open(_bstr_t("geometry_columns"),
896  _variant_t((IDispatch*)adoConn,true), adOpenKeyset, adLockOptimistic, adCmdTable));
897 
898  while(!recset->EndOfFile)
899  {
900  if(std::string((_bstr_t)recset->Fields->GetItem("f_table_name")->Value) == tableName
901  && std::string((_bstr_t)recset->Fields->GetItem("f_geometry_column")->Value) == columnName)
902  return true;
903 
904  recset->MoveNext();
905  }
906  }
907  }
908  }
909  catch(_com_error& e)
910  {
911  throw te::common::Exception((LPCSTR)e.ErrorMessage());
912  }
913 
914  return false;
915 }
916 
918 {
919  if( (type >= 1000 && type < 2000) || (type >= 3000 && type < 4000) )
920  return true;
921  return false;
922 }
923 
924 std::string te::ado::GetSystemDateTimeFormat(std::string& indAM, std::string& indPM, std::string& sepD, std::string& sepT)
925 {
926  std::string key = "Control Panel\\International";
927  std::string dateFormat = "sShortDate"; //formato da data d/M/yyyy
928  std::string timeFormat = "sTimeFormat"; //formato da hora HH:mm:ss
929  std::string hourFormat = "iTime"; //12 horas (0) ou 24 horas(1)
930  std::string indicatorAM = "s1159"; //AM
931  std::string indicatorPM = "s2359"; //PM
932  std::string dateSeparator = "sDate"; //separador de data
933  std::string timeSeparator = "sTime"; //separador de hora
934 
935  std::string rdateFormat;
936  std::string rtimeFormat;
937  std::string rhourFormat;
938  std::string rdateSeparator;
939  std::string rtimeSeparator;
940 
941  HKEY hk;
942  DWORD DataSize = 1024;
943  DWORD Type = REG_SZ;
944  char buf[1024];
945 
946  if (RegOpenKeyExA(HKEY_CURRENT_USER, key.c_str(), 0, KEY_READ, &hk) == ERROR_SUCCESS)
947  {
948  memset (buf, 0, 1024);
949  DataSize = 1024;
950  //date format
951  if (RegQueryValueExA(hk, dateFormat.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
952  rdateFormat = buf;
953 
954  memset (buf, 0, 1024);
955  DataSize = 1024;
956  //date separator
957  if (RegQueryValueExA(hk, dateSeparator.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
958  rdateSeparator = buf;
959 
960  memset (buf, 0, 1024);
961  DataSize = 1024;
962  //time format
963  if (RegQueryValueExA(hk, timeFormat.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
964  rtimeFormat = buf;
965 
966  memset (buf, 0, 1024);
967  DataSize = 1024;
968  //hour format
969  if (RegQueryValueExA(hk, hourFormat.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
970  rhourFormat = buf;
971 
972  memset (buf, 0, 1024);
973  DataSize = 1024;
974  //indicator AM
975  if (RegQueryValueExA(hk, indicatorAM.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
976  indAM = buf;
977 
978  memset (buf, 0, 1024);
979  DataSize = 1024;
980  //indicator PM
981  if (RegQueryValueExA(hk, indicatorPM.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
982  indPM = buf;
983 
984  memset (buf, 0, 1024);
985  DataSize = 1024;
986  //time separator
987  if (RegQueryValueExA(hk, timeSeparator.c_str(), NULL, &Type, (LPBYTE)buf, &DataSize) == ERROR_SUCCESS)
988  rtimeSeparator = buf;
989  }
990  else
991  return "";
992 
993  sepD = rdateSeparator;
994  sepT = rtimeSeparator;
995 
996  //DATE
997  //first
998  int pos = (int)rdateFormat.find(rdateSeparator);
999  std::string firstD = rdateFormat.substr(0,pos);
1000  std::string temp = rdateFormat.substr(pos+1);
1001  //second and third
1002  pos = (int)temp.find(rdateSeparator);
1003  std::string secondD = temp.substr(0,pos);
1004  std::string thirdD = temp.substr(pos+1);
1005 
1006  //passar para o formato
1007  if(firstD.find("a")==0)
1008  replace(firstD.begin(), firstD.end(), 97, 89);
1009  else if(secondD.find("a")==0)
1010  replace(secondD.begin(), secondD.end(),97, 89);
1011  else if(thirdD.find("a")==0)
1012  replace(thirdD.begin(), thirdD.end(), 97, 89);
1013 
1014  //TIME
1015  //first
1016  pos = (int)rtimeFormat.find(rtimeSeparator);
1017  std::string firstT = rtimeFormat.substr(0,pos);
1018  temp = rtimeFormat.substr(pos+1);
1019  //second and third
1020  pos = (int)temp.find(rtimeSeparator);
1021  std::string secondT = temp.substr(0,pos);
1022  int posEmpth = (int)temp.find(" ");
1023  std::string thirdT;
1024 
1025  if(posEmpth==-1)
1026  thirdT = temp.substr(pos+1);
1027  else
1028  thirdT = temp.substr(pos+1, (posEmpth-(pos+1)));
1029 
1030  int hFormat = atoi(rhourFormat.c_str());
1031 
1032  //passar para o formato
1033 
1034  firstT = te::common::Convert2UCase(firstT);
1035  secondT = te::common::Convert2UCase(secondT);
1036  thirdT = te::common::Convert2UCase(thirdT);
1037 
1038  if((firstT.find("M")==0))
1039  replace(firstT.begin(), firstT.end(), 77, 109);
1040  else if(secondT.find("M")==0)
1041  replace(secondT.begin(), secondT.end(), 77, 109);
1042  else if(thirdT.find("M")==0)
1043  replace(thirdT.begin(), thirdT.end(), 77, 109);
1044 
1045  std::string timef;
1046  if(hFormat==0)
1047  timef = "sTT";
1048  else
1049  timef = "";
1050 
1051  std::string result = te::common::Convert2UCase(firstD) +"s"+
1052  te::common::Convert2UCase(secondD) +"s"+
1053  te::common::Convert2UCase(thirdD) +"s"+
1054  firstT +"s"+
1055  secondT +"s"+
1056  thirdT + timef;
1057 
1058  RegCloseKey (hk);
1059  return result;
1060 }
1061 
1062 int te::ado::GetMonth(const std::string& month)
1063 {
1064  std::string tempM = te::common::Convert2UCase(month);
1065  if(tempM=="JAN")
1066  return 1;
1067  else if(tempM=="FEB")
1068  return 2;
1069  else if(tempM=="MAR")
1070  return 3;
1071  else if(tempM=="APR")
1072  return 4;
1073  else if(tempM=="MAY")
1074  return 5;
1075  else if(tempM=="JUN")
1076  return 6;
1077  else if(tempM=="JUL")
1078  return 7;
1079  else if(tempM=="AUG")
1080  return 8;
1081  else if(tempM=="SEP")
1082  return 9;
1083  else if(tempM=="OCT")
1084  return 12;
1085  else if(tempM=="NOV")
1086  return 11;
1087  else if(tempM=="DEC")
1088  return 12;
1089 
1090  return -1;
1091 }
1092 
1093 std::auto_ptr<te::dt::DateTime> te::ado::GetDateTime(std::string& value, std::string& mask,
1094  std::string& sepD, std::string& sepT)
1095 {
1096  int sec = 0;
1097  int min = 0;
1098  int hour = 0;
1099  int day = 0;
1100  int mon = 0;
1101  int year = 0;
1102 
1103  if(mask == "DDsMMsYYYYsHHsmmsSS")
1104  {
1105  std::vector<std::string> tokGeneral;
1106  te::common::Tokenize(value, tokGeneral, " ");
1107 
1108  // Only Date or only Time
1109  if(tokGeneral.size() == 1)
1110  {
1111  std::vector<std::string> tokDate;
1112  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1113  std::vector<std::string> tokTime;
1114  te::common::Tokenize(tokGeneral[0], tokTime, sepT);
1115 
1116  // Only Date
1117  if(tokDate.size() > 1)
1118  {
1119  day = boost::lexical_cast<int>(tokDate[0]);
1120  mon = boost::lexical_cast<int>(tokDate[1]);
1121  year = boost::lexical_cast<int>(tokDate[2]);
1122  }
1123  // Only Time
1124  else if(tokTime.size() > 1)
1125  {
1126  hour = boost::lexical_cast<int>(tokTime[0]);
1127  min = boost::lexical_cast<int>(tokTime[1]);
1128  sec = boost::lexical_cast<int>(tokTime[2]);
1129  }
1130  }
1131  // Date and Time
1132  else if(tokGeneral.size() == 2)
1133  {
1134  std::vector<std::string> tokDate;
1135  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1136  std::vector<std::string> tokTime;
1137  te::common::Tokenize(tokGeneral[1], tokTime, sepT);
1138 
1139  day = boost::lexical_cast<int>(tokDate[0]);
1140  mon = boost::lexical_cast<int>(tokDate[1]);
1141  year = boost::lexical_cast<int>(tokDate[2]);
1142  hour = boost::lexical_cast<int>(tokTime[0]);
1143  min = boost::lexical_cast<int>(tokTime[1]);
1144  sec = boost::lexical_cast<int>(tokTime[2]);
1145  }
1146  }
1147  else if(mask == "MsDsYYYYsHsmmsSSsTT")
1148  {
1149  std::vector<std::string> tokGeneral;
1150  te::common::Tokenize(value, tokGeneral, " ");
1151 
1152  // Only Date
1153  if(tokGeneral.size() == 1)
1154  {
1155  std::vector<std::string> tokDate;
1156  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1157  mon = boost::lexical_cast<int>(tokDate[0]);
1158  day = boost::lexical_cast<int>(tokDate[1]);
1159  year = boost::lexical_cast<int>(tokDate[2]);
1160  }
1161  // Only Time
1162  else if(tokGeneral.size() == 2)
1163  {
1164  std::vector<std::string> tokTime;
1165  te::common::Tokenize(tokGeneral[0], tokTime, sepT);
1166  hour = boost::lexical_cast<int>(tokTime[0]);
1167  min = boost::lexical_cast<int>(tokTime[1]);
1168  sec = boost::lexical_cast<int>(tokTime[2]);
1169  }
1170  // Date and Time
1171  else if(tokGeneral.size() == 3)
1172  {
1173  std::vector<std::string> tokDate;
1174  std::vector<std::string> tokTime;
1175  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1176  te::common::Tokenize(tokGeneral[1], tokTime, sepT);
1177 
1178  mon = boost::lexical_cast<int>(tokDate[0]);
1179  day = boost::lexical_cast<int>(tokDate[1]);
1180  year = boost::lexical_cast<int>(tokDate[2]);
1181  hour = boost::lexical_cast<int>(tokTime[0]);
1182  min = boost::lexical_cast<int>(tokTime[1]);
1183  sec = boost::lexical_cast<int>(tokTime[2]);
1184  }
1185  }
1186  else if(mask == "YYYYsMMsDDsHHsmmsSS")
1187  {
1188  std::vector<std::string> tokGeneral;
1189  te::common::Tokenize(value, tokGeneral, " ");
1190 
1191  // Only Date or only Time
1192  if(tokGeneral.size() == 1)
1193  {
1194  std::vector<std::string> tokDate;
1195  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1196  std::vector<std::string> tokTime;
1197  te::common::Tokenize(tokGeneral[0], tokTime, sepT);
1198 
1199  // Only Date
1200  if(tokDate.size() > 1)
1201  {
1202  year = boost::lexical_cast<int>(tokDate[0]);
1203  mon = boost::lexical_cast<int>(tokDate[1]);
1204  day = boost::lexical_cast<int>(tokDate[2]);
1205  }
1206  // Only Time
1207  else if(tokTime.size() > 1)
1208  {
1209  hour = boost::lexical_cast<int>(tokTime[0]);
1210  min = boost::lexical_cast<int>(tokTime[1]);
1211  sec = boost::lexical_cast<int>(tokTime[2]);
1212  }
1213  }
1214  // Date and Time
1215  else if(tokGeneral.size() == 2)
1216  {
1217  std::vector<std::string> tokDate;
1218  te::common::Tokenize(tokGeneral[0], tokDate, sepD);
1219  std::vector<std::string> tokTime;
1220  te::common::Tokenize(tokGeneral[1], tokTime, sepT);
1221 
1222  year = boost::lexical_cast<int>(tokDate[0]);
1223  mon = boost::lexical_cast<int>(tokDate[1]);
1224  day = boost::lexical_cast<int>(tokDate[2]);
1225  hour = boost::lexical_cast<int>(tokTime[0]);
1226  min = boost::lexical_cast<int>(tokTime[1]);
1227  sec = boost::lexical_cast<int>(tokTime[2]);
1228  }
1229  }
1230  else
1231  throw te::common::Exception((boost::format(TE_TR("DateTime format not provided or invalid: %1%!")) % mask).str());
1232 
1233  te::dt::DateTime* result = 0;
1234 
1235  if((day > 0 || mon > 0 || year > 0) && (sec > 0 || min > 0 || hour > 0))
1236  {
1237  te::dt::Date d((unsigned short)year, (unsigned short)mon, (unsigned short)day);
1238  te::dt::TimeDuration td(hour, min, sec);
1239  result = new te::dt::TimeInstant(d, td);
1240  }
1241  else if(day > 0 || mon > 0 || year > 0)
1242  {
1243  result = new te::dt::Date((unsigned short)year, (unsigned short)mon, (unsigned short)day);
1244  }
1245  else if(sec > 0 || min > 0 || hour > 0)
1246  {
1247  result = new te::dt::TimeDuration(hour, min, sec);
1248  }
1249  else
1250  return std::auto_ptr<te::dt::DateTime>(0);
1251 
1252  return std::auto_ptr<te::dt::DateTime>(result);
1253 }
1254 
1256 {
1257  std::string result = "";
1258 
1259  te::dt::Date* dtime = dynamic_cast<te::dt::Date*>(dateTime);
1260 
1261  std::string mAM, mPM, sepD, sepT;
1262 
1263  std::string mask = GetSystemDateTimeFormat(mAM, mPM, sepD, sepT);
1264 
1265  if(dtime)
1266  {
1267  if(mask.find("DDsMMsYYYY") != std::string::npos)
1268  {
1269  result = boost::lexical_cast<std::string>(dtime->getDay()) + sepD;
1270  result += boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(dtime->getMonth()))) + sepD;
1271  result += boost::lexical_cast<std::string>(dtime->getYear());
1272  }
1273  else if(mask.find("MsDsYYYY") != std::string::npos)
1274  {
1275  result = boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(dtime->getMonth()))) + sepD;
1276  result += boost::lexical_cast<std::string>(dtime->getDay()) + sepD;
1277  result += boost::lexical_cast<std::string>(dtime->getYear());
1278  }
1279  else if(mask.find("YYYYsMMsDD") != std::string::npos)
1280  {
1281  result = boost::lexical_cast<std::string>(dtime->getYear()) + sepD;
1282  result += boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(dtime->getMonth()))) + sepD;
1283  result += boost::lexical_cast<std::string>(dtime->getDay());
1284  }
1285  }
1286 
1287  te::dt::TimeDuration* tduration = dynamic_cast<te::dt::TimeDuration*>(dateTime);
1288 
1289  if(tduration)
1290  {
1291  if(mask.find("HHsmmsSS") != std::string::npos)
1292  {
1293  result = boost::lexical_cast<std::string>(tduration->getHours()) + sepT;
1294  result += boost::lexical_cast<std::string>(tduration->getMinutes()) + sepT;
1295  result += boost::lexical_cast<std::string>(tduration->getSeconds());
1296  }
1297  else if(mask.find("HsmmsSSsTT") != std::string::npos)
1298  {
1299  result = boost::lexical_cast<std::string>(tduration->getHours()) + sepT;
1300  result += boost::lexical_cast<std::string>(tduration->getMinutes()) + sepT;
1301  result += boost::lexical_cast<std::string>(tduration->getSeconds());
1302  }
1303  }
1304 
1305  te::dt::TimeInstant* tinst = dynamic_cast<te::dt::TimeInstant*>(dateTime);
1306 
1307  if(tinst)
1308  {
1309  te::dt::Date date = tinst->getDate();
1310  te::dt::TimeDuration time = tinst->getTime();
1311 
1312  if(mask == "DDsMMsYYYYsHHsmmsSS")
1313  {
1314  result = boost::lexical_cast<std::string>(date.getDay()) + sepD;
1315  result += boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(date.getMonth()))) + sepD;
1316  result += boost::lexical_cast<std::string>(date.getYear()) + " ";
1317  result += boost::lexical_cast<std::string>(time.getHours()) + sepT;
1318  result += boost::lexical_cast<std::string>(time.getMinutes()) + sepT;
1319  result += boost::lexical_cast<std::string>(time.getSeconds());
1320  }
1321  else if(mask == "MsDsYYYYsHsmmsSSsTT")
1322  {
1323  result = boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(date.getMonth()))) + sepD;
1324  result += boost::lexical_cast<std::string>(date.getDay()) + sepD;
1325  result += boost::lexical_cast<std::string>(date.getYear()) + " ";
1326  result += boost::lexical_cast<std::string>(time.getHours()) + sepT;
1327  result += boost::lexical_cast<std::string>(time.getMinutes()) + sepT;
1328  result += boost::lexical_cast<std::string>(time.getSeconds());
1329  }
1330  else if(mask == "YYYYsMMsDDsHHsmmsSS")
1331  {
1332  result = boost::lexical_cast<std::string>(date.getYear()) + sepD;
1333  result += boost::lexical_cast<std::string>(GetMonth(boost::lexical_cast<std::string>(date.getMonth()))) + sepD;
1334  result += boost::lexical_cast<std::string>(date.getDay()) + " ";
1335  result += boost::lexical_cast<std::string>(time.getHours()) + sepT;
1336  result += boost::lexical_cast<std::string>(time.getMinutes()) + sepT;
1337  result += boost::lexical_cast<std::string>(time.getSeconds());
1338  }
1339  }
1340 
1341  te::dt::TimeInstantTZ* tinstZ = dynamic_cast<te::dt::TimeInstantTZ*>(dateTime);
1342 
1343  if(tinstZ)
1344  {
1345  boost::local_time::local_date_time boostTime = tinstZ->getTimeInstantTZ();
1346 
1347  int hh = boostTime.utc_time().time_of_day().hours();
1348  int mm = boostTime.utc_time().time_of_day().minutes();
1349  int ss = boostTime.utc_time().time_of_day().seconds();
1350 
1351  if(mask.find("HHsmmsSS") != std::string::npos)
1352  {
1353  result = boost::lexical_cast<std::string>(hh) + sepT;
1354  result += boost::lexical_cast<std::string>(mm) + sepT;
1355  result += boost::lexical_cast<std::string>(ss);
1356  }
1357  else if(mask.find("HsmmsSSsTT") != std::string::npos)
1358  {
1359  result = boost::lexical_cast<std::string>(hh) + sepT;
1360  result += boost::lexical_cast<std::string>(mm) + sepT;
1361  result += boost::lexical_cast<std::string>(ss);
1362  }
1363  }
1364 
1365  return result;
1366 }
1367 
StringType
The subtype of string property.
Definition: Enums.h:171
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
Definition: Geometry.h:189
int GetMonth(const std::string &month)
It gets the index of a month.
Definition: Utils.cpp:1062
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
DataSet class implementation for Microsoft Access driver.
int GetSRID(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
Read the geometry_columns table end return a SRID.
Definition: Utils.cpp:828
An atomic property like an integer or double.
const std::string & GetGeometryName(te::gm::GeomType t)
It returns the geometry OGC names.
Definition: Utils.cpp:525
void setProperties(const std::vector< te::dt::Property * > &properties)
It sets the properties that form the unique key.
Definition: UniqueKey.h:117
te::gm::GeomType GetType(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
Read the geometry_columns table end return a geometry type.
Definition: Utils.cpp:852
void getWkb(char *wkb, te::common::MachineByteOrder byteOrder) const
It serializes the geometry to a WKB representation into the specified buffer.
Definition: Geometry.cpp:139
int Convert2Terralib(ADOX::DataTypeEnum adoType)
Bind ADOX Type to TerraLib Type.
Definition: Utils.cpp:229
long getSeconds() const
It returns the seconds of a minute - from 0 to 59.
Definition: TimeDuration.h:105
Spatial reference system transformation function.
void Blob2Variant(const char *blob, int size, _variant_t &var)
Convert a blob to a variant.
Definition: Utils.cpp:56
boost::gregorian::greg_year getYear() const
It returns the gregorian year.
Definition: Date.h:111
Configuration flags for the TerraLib ADO Data Access driver.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
Definition: StringUtils.h:166
boost::gregorian::greg_day getDay() const
It returns the gregorian day - from 1 to 31.
Definition: Date.h:97
std::string GetSystemDateTimeFormat(std::string &indAM, std::string &indPM, std::string &sepD, std::string &sepT)
It gets the system Date and Time format.
Definition: Utils.cpp:924
std::string MakeConnectionStr(const std::map< std::string, std::string > &dsInfo)
Create a connection string based on a map.
Definition: Utils.cpp:75
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:346
std::string GetFormattedDateTime(te::dt::DateTime *dateTime)
It gets a formatted DateTime string for ADO.
Definition: Utils.cpp:1255
std::size_t getWkbSize() const
It returns the size required by a WKB representation for this geometric object.
Definition: Geometry.cpp:134
It models a property definition.
Definition: Property.h:59
A class to represent time instant.
Definition: TimeInstant.h:55
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
Definition: StringUtils.h:219
std::string GetAdoStringType(const int &terralib)
Bind TerraLib type to an ADO valid fiel type name.
Definition: Utils.cpp:174
Date getDate() const
It returns the date associated to time instant.
Definition: TimeInstant.h:106
A base class for date data types.
Definition: Date.h:53
void setProperties(const std::vector< te::dt::Property * > &properties)
It sets the properties that form the primary key.
Definition: PrimaryKey.h:116
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
const boost::local_time::local_date_time & getTimeInstantTZ() const
It returns the boost time instant with time zone type.
Definition: TimeInstantTZ.h:71
The type for string types: FIXED_STRING, VAR_STRING or STRING.
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
te::common::AccessPolicy Convert2Terralib(std::string accessPolicy)
Definition: Serializer.cpp:397
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
void setProperties(const std::vector< te::dt::Property * > &properties)
It sets the properties that take part of the foreign key constraint.
Definition: ForeignKey.h:121
const te::gm::GeomType GetGeometryType(std::string t)
It returns the geometry type concerning the OGC name.
Definition: Utils.cpp:678
The type for variable-length multidimensional arrays.
Definition: ArrayProperty.h:45
Utility functions for ADO.
A class to represent time duration with nano-second/micro-second resolution.
Definition: TimeDuration.h:51
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
ADOX::DataTypeEnum Convert2Ado(int terralib)
Bind TerraLib Type to ADO Type.
Definition: Utils.cpp:121
The type for date and time types: date, date period, date duration, time duration, time instant, time period, time instant with time zone or time period with time zone.
TimeDuration getTime() const
It returns the time duration associated to time instant.
Definition: TimeInstant.cpp:49
bool IsZProperty(te::gm::GeomType type)
Verifies whether Z property.
Definition: Utils.cpp:917
bool IsGeomProperty(_ConnectionPtr adoConn, std::string tableName, std::string columnName)
Verifies whether is in the geometry_columns table.
Definition: Utils.cpp:878
long getMinutes() const
It returns the minutes of a hour - from 0 to 59.
Definition: TimeDuration.h:98
std::auto_ptr< te::dt::DateTime > GetDateTime(std::string &value, std::string &mask, std::string &sepD, std::string &sepT)
It gets the DateTime TerraLib 5 from string.
Definition: Utils.cpp:1093
A class to represent time instant with time zone.
Definition: TimeInstantTZ.h:52
void TESTHR(HRESULT hr)
Definition: Utils.cpp:51
boost::gregorian::greg_month getMonth() const
It returns the gregorian month - from 1 to 12.
Definition: Date.h:104
An static class with global definitions.
void Variant2Blob(const _variant_t var, int size, char *&blob)
Convert a variant to a blob.
Definition: Utils.cpp:102
long getHours() const
It returns the hours of a day - from 0 to 23.
Definition: TimeDuration.h:91