27 #include "../common/ByteSwapUtils.h"
28 #include "../common/Globals.h"
29 #include "../common/StringUtils.h"
30 #include "../common/Translator.h"
31 #include "../dataaccess/dataset/DataSetType.h"
32 #include "../datatype/Array.h"
33 #include "../datatype/ByteArray.h"
34 #include "../datatype/DateTimeProperty.h"
35 #include "../datatype/SimpleData.h"
36 #include "../datatype/TimeInstant.h"
37 #include "../geometry/Envelope.h"
38 #include "../geometry/Geometry.h"
39 #include "../geometry/WKBReader.h"
51 #include <boost/dynamic_bitset.hpp>
52 #include <boost/lexical_cast.hpp>
56 if( FAILED(hr) ) _com_issue_error( hr );
71 FieldsPtr fields =
m_result->GetFields();
73 for(
int i = 0; i !=
m_ncols; ++i)
75 FieldPtr field = fields->GetItem((
long)i);
77 std::string columnName = field->GetName();
86 std::string tableName = (LPCSTR)(_bstr_t)field->GetProperties()->GetItem(
"BASETABLENAME")->GetValue();
119 throw Exception(
TR_ADO(
"Method getExtent: not implemented yet!"));
129 return m_datatypes[i];
134 return m_colNames[i];
139 throw Exception(
TR_ADO(
"Method getDatasetNameOfProperty: not implemented yet!"));
144 return (m_size == 0);
160 TESTHR(m_result->MoveNext());
163 bool teste = (m_i < m_size);
164 return (m_i < m_size);
170 m_result->MovePrevious();
178 if(m_result->BOF != 0)
181 TESTHR(m_result->MoveFirst());
189 m_result->MoveFirst();
196 TESTHR(m_result->MoveLast());
198 return (m_i < m_size);
209 long p =
static_cast<long>(i-m_i);
211 TESTHR(m_result->Move(p));
214 return (m_i < m_size);
229 return m_i == (m_size - 1);
234 return m_i >= m_size;
247 ival = (char)m_result->GetFields()->GetItem(vtIndex)->GetValue();
251 throw Exception(
TR_ADO(e.Description()));
259 return (
unsigned char)getChar(i);
272 ival = (int16_t)m_result->GetFields()->GetItem(vtIndex)->GetValue();
276 throw Exception(
TR_ADO(e.Description()));
292 ival = (int32_t)m_result->GetFields()->GetItem(vtIndex)->GetValue();
296 throw Exception(
TR_ADO(e.Description()));
312 ival = (int64_t)m_result->GetFields()->GetItem(vtIndex)->GetValue();
316 throw Exception(
TR_ADO(e.Description()));
332 ival = (bool)m_result->GetFields()->GetItem(vtIndex)->GetValue();
336 throw Exception(
TR_ADO(e.Description()));
352 value = (float)m_result->GetFields()->GetItem(vtIndex)->GetValue();
356 throw Exception(
TR_ADO(e.Description()));
372 value = (double)m_result->GetFields()->GetItem(vtIndex)->GetValue();
376 throw Exception(
TR_ADO(e.Description()));
384 throw Exception(
TR_ADO(
"Method getNumeric: not implemented yet!"));
397 ival = (LPCSTR)(_bstr_t)m_result->GetFields()->GetItem(vtIndex)->GetValue();
401 throw Exception(
TR_ADO(e.Description()));
422 if(m_result->MoveNext() == S_OK)
423 m_result->MovePrevious();
424 else if(m_result->MovePrevious() == S_OK)
425 m_result->MoveNext();
428 _RecordsetPtr copy = m_result->Clone(adLockReadOnly);
430 field = copy->GetFields()->GetItem(vtIndex);
433 field = m_result->GetFields()->GetItem(vtIndex);
435 size = field->ActualSize;
438 VariantInit(&varBLOB);
440 varBLOB = field->GetChunk(size);
442 if(varBLOB.vt == (VT_ARRAY | VT_UI1))
444 SafeArrayAccessData(varBLOB.parray,(
void **)&cdata);
445 data =
new char[size];
446 memcpy(data, cdata, size);
447 SafeArrayUnaccessData(varBLOB.parray);
453 throw Exception(
TR_ADO(e.Description()));
461 std::auto_ptr<te::dt::ByteArray> ba(getByteArray(i));
465 std::size_t wkb_size = geom->getWkbSize();
467 if(ba->bytesUsed() - wkb_size >= 4)
468 geom->setSRID(*((
int*)(ba->getData() + wkb_size)));
475 throw Exception(
TR_ADO(
"Method getRaster: not implemented yet!"));
491 value = m_result->GetFields()->GetItem(vtIndex)->Value;
495 throw Exception(
TR_ADO(e.Description()));
498 if(value.vt == VT_NULL)
499 return std::auto_ptr<te::dt::DateTime>(0);
501 strDate = (LPCSTR)(_bstr_t)value;
518 throw Exception(
TR_ADO(
"Method getArray: not implemented yet!"));
525 std::string propertyName = getPropertyName(i);
529 value = m_result->GetFields()->GetItem(static_cast<long>(i))->GetValue();
534 throw Exception(
TR_ADO(e.Description()));
537 if(value.vt == VT_NULL)
bool isNull(std::size_t i) const
It checks if the attribute value is NULL.
int Convert2Terralib(ADOX::DataTypeEnum adoType)
Bind ADOX Type to TerraLib Type.
The transactor class for the Microsoft Access driver.
bool isEmpty() const
It returns true if the collection is empty.
Utility functions for ADO.
te::common::TraverseType getTraverseType() const
It returns the traverse type associated to the dataset.
bool isAfterEnd() const
It tells if the dataset internal pointer is on the sentinel position after the last element of the co...
DataSet class implementation for Microsoft Access driver.
te::common::AccessPolicy getAccessPolicy() const
It returns the read and write permission associated to the dataset.
bool getBool(std::size_t i) const
Method for retrieving a boolean attribute value.
int m_size
The number of datasets in the collection.
boost::int16_t getInt16(std::size_t i) const
Method for retrieving a 16-bit integer attribute value (2 bytes long).
std::string getPropertyName(std::size_t i) const
It returns the property name at position pos.
DataSet()
Default constructor.
std::string getString(std::size_t i) const
Method for retrieving a string value attribute.
static Geometry * read(const char *wkb)
It returns a valid geometry from a given WKB.
std::auto_ptr< te::dt::ByteArray > getByteArray(std::size_t i) const
Method for retrieving a byte array.
boost::int64_t getInt64(std::size_t i) const
Method for retrieving a 64-bit integer attribute value (8 bytes long).
std::auto_ptr< te::rst::Raster > getRaster(std::size_t i) const
Method for retrieving a raster attribute value.
std::vector< std::string > m_colNames
A vector of columns names.
char getChar(std::size_t i) const
Method for retrieving a signed character attribute value (1 byte long).
bool isBeforeBegin() const
It tells if the dataset internal pointer is in a position before the first element of the collection ...
A class that implements a connection to a ADO database.
float getFloat(std::size_t i) const
Method for retrieving a float attribute value.
~DataSet()
The destructor will clear the internal ADO _RecordsetPtr.
AccessPolicy
Supported data access policies (can be used as bitfield).
bool isGeometryColumn(const std::string &datasetName, const std::string &colName) const
bool isConnected() const
It returns true if the dataset is connected and false if it is disconnected. A dataset can be connect...
DataSourceTransactor class implementation for Microsoft Access driver.
bool move(std::size_t i)
It moves the dataset internal pointer to a given position.
bool isAtEnd() const
It tells if the dataset internal pointer is on the last element of the collection.
std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const
Method for retrieving a geometric attribute value.
std::auto_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
Implementation of the data source class for the ADO driver.
bool moveLast()
It sets the dataset internal pointer to the last item in the collection.
std::string GetSystemDateTimeFormat(std::string &indAM, std::string &indPM, std::string &sepD, std::string &sepT)
It gets the system Date and Time format.
TraverseType
A dataset can be traversed in two ways:
double getDouble(std::size_t i) const
Method for retrieving a double attribute value.
std::vector< int > m_datatypes
A vector of data types.
std::string getDatasetNameOfProperty(std::size_t i) const
It returns the underlying dataset name of the property at position pos.
std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const
Method for retrieving a date and time attribute value.
_RecordsetPtr m_result
The internal buffer with the result query.
DataSource * getAdoDataSource() const
boost::int32_t getInt32(std::size_t i) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
bool moveFirst()
It moves the internal pointer to the first item in the collection.
std::size_t getNumProperties() const
It returns the number of properties that composes an item of the dataset.
bool isAtBegin() const
It tells if the dataset internal pointer is on the first element of the collection or not...
unsigned char getUChar(std::size_t i) const
Method for retrieving an unsigned character attribute value (1 byte long).
A class for representing binary data.
std::auto_ptr< te::dt::Array > getArray(std::size_t i) const
Method for retrieving an array.
bool moveNext()
It moves the internal pointer to the next item of the collection.
int getPropertyDataType(std::size_t i) const
It returns the underlying data type of the property at position pos.
An exception class for ADO.
bool movePrevious()
It moves the internal pointer to the previous item of the collection.
Transactor * m_t
The DataSet Transactor.
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
std::size_t size() const
It returns the collection size, if it is known.
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.
int m_ncols
The number of properties in the collection.
std::string getNumeric(std::size_t i) const
Method for retrieving a numeric attribute value.
#define TR_ADO(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...