array<System::Byte>^ zDBBinaryReader::ToBytes(int offset, int length) { const unsigned char* puData; // Pointer into raw data array<System::Byte>^ rg; // Managed byte array of data PinnedBytePtr pinRg; // Pinned pointer into rg[] CHECK_DISPOSED(m_disposed); if(offset < 0) throw gcnew ArgumentException(); if(length < 0) throw gcnew ArgumentException(); if((offset + length) > m_cb) throw gcnew ArgumentOutOfRangeException(); // Special case: If the caller wants zero bytes, don't go pinning // pointers and copying nothing. Just return what they want if(length == 0) return gcnew array<System::Byte>(0); rg = gcnew array<System::Byte>(length); // Create return array pinRg = &rg[0]; // Pin and get a pointer // Only copy the amount of data that the caller is looking for puData = reinterpret_cast<const unsigned char*>(sqlite3_column_blob(m_pStatement->Handle, m_ordinal)); memcpy_s(pinRg, length, puData + offset, length); return rg; }
void StorageDirectoryEnumerator::Reset(void) { CHECK_DISPOSED(m_disposed); m_enum->Reset(); // Reset the real enumerator m_spent = false; // Enumerator is no longer spent }
bool StorageDirectoryEnumerator::MoveNext(void) { bool result; // Operational result CHECK_DISPOSED(m_disposed); result = m_enum->MoveNext(); // Move the real enumerator if(!result) m_spent = true; // Set spent enumerator flag return result; // Return result from MoveNext() }
VirtualDirectory^ StorageDirectoryEnumerator::Current::get(void) { StorageContainer^ container; // Object to be returned StoragePath^ path; // New StoragePath instance CHECK_DISPOSED(m_disposed); container = m_enum->Current; path = gcnew StoragePath(m_path, m_path->Full + "/" + container->Name); return gcnew StorageDirectory(path, container); }
SByte zDBBinaryReader::ToSByte(int offset) { const char* pu; // Pointer into the data CHECK_DISPOSED(m_disposed); if(offset < 0) throw gcnew ArgumentException(); if(offset > (m_cb - 1)) throw gcnew ArgumentOutOfRangeException(); pu = reinterpret_cast<const char*>(sqlite3_column_blob(m_pStatement->Handle, m_ordinal)); return *(pu + offset); }
VirtualFile^ StorageFileEnumerator::Current::get(void) { StorageObject^ object; // Object to be returned StoragePath^ path; // New virtual file path CHECK_DISPOSED(m_disposed); object = m_enum->Current; path = gcnew StoragePath(m_path, m_path->Full + "/" + object->Name); return gcnew StorageFile(path, object); }
Diagnostic^ LoadedDiagnosticCollection::default::get(int index) { CHECK_DISPOSED(m_disposed); // Check for a cached instance of the Diagnostic first, this will also // validate that the index is within the boundaries of the collection Diagnostic^ cached = m_cache[index]; if(!Object::ReferenceEquals(cached, nullptr)) return cached; // Create a new diagnostic and cache it to prevent multiple creations, there // is no translation unit associated with the loaded diagnostics to use here m_cache[index] = Diagnostic::Create(m_handle, TranslationUnitHandle::Null, clang_getDiagnosticInSet(DiagnosticSetHandle::Reference(m_handle), static_cast<unsigned int>(index))); return m_cache[index]; }
float zDBBinaryReader::ToSingle(int offset) { int cb = sizeof(float); // Number of bytes to alloc/copy const unsigned char* puData; // Pointer into raw data array<System::Byte>^ rg; // Managed byte array of data PinnedBytePtr pinRg; // Pinned pointer into rg[] CHECK_DISPOSED(m_disposed); if(offset < 0) throw gcnew ArgumentException(); if(offset > (m_cb - cb)) throw gcnew ArgumentOutOfRangeException(); rg = gcnew array<System::Byte>(cb); // Allocate the local buffer pinRg = &rg[0]; // Pin it down for memcpy_s // Copy only the amount of data we specifically need from SQLite, and attempt // to convert it using a standard binary conversion mechanism puData = reinterpret_cast<const unsigned char*>(sqlite3_column_blob(m_pStatement->Handle, m_ordinal)); memcpy_s(pinRg, cb, puData + offset, cb); return BitConverter::ToSingle(rg, 0); }
array<__wchar_t>^ zDBBinaryReader::ToChars(int offset, int length) { int cb; // Local size information const wchar_t* pwchData; // Pointer into raw data array<__wchar_t>^ rg; // Managed char array of data PinnedCharPtr pinRg; // Pinned pointer into rg[] int cch; // Unicode character count CHECK_DISPOSED(m_disposed); if(offset < 0) throw gcnew ArgumentException(); if(length < 0) throw gcnew ArgumentException(); if((offset % sizeof(wchar_t)) != 0) throw gcnew ArgumentException(); if((length % sizeof(wchar_t)) != 0) throw gcnew ArgumentException(); // When accessing things as Unicode character data, ask SQLite for a // specific size that will properly adjusted as necessary cb = sqlite3_column_bytes16(m_pStatement->Handle, m_ordinal); if((offset + length) > cb) throw gcnew ArgumentOutOfRangeException(); // Special case: If the caller wants zero bytes, don't go pinning // pointers and copying nothing. Just return what they want if(length == 0) return gcnew array<__wchar_t>(0); cch = length / sizeof(wchar_t); // Calculate character count rg = gcnew array<__wchar_t>(cch); // Create return array pinRg = &rg[0]; // Pin and get a pointer // Only copy the amount of data that the caller is looking for from // the SQLite buffer into the managed Char array buffer pwchData = reinterpret_cast<const wchar_t*>(sqlite3_column_text16(m_pStatement->Handle, m_ordinal)); wmemcpy_s(pinRg, cch, pwchData + (offset / sizeof(wchar_t)), cch); return rg; }
zDBConnection^ zDBVirtualTable<_cursor>::Connection::get(void) { CHECK_DISPOSED(m_disposed); return m_args->Connection; }
ReadOnlyCollection<String^>^ zDBVirtualTable<_cursor>::Arguments::get(void) { CHECK_DISPOSED(m_disposed); return m_args->Arguments; }
String^ zDBVirtualTable<_cursor>::DatabaseName::get(void) { CHECK_DISPOSED(m_disposed); return m_args->DatabaseName; }
bool zDBBinaryReader::ToBoolean(int offset) { CHECK_DISPOSED(m_disposed); return ToByte(offset) != 0; // Use ToByte() instead }
array<System::Byte>^ zDBBinaryReader::ToBytes(int offset) { CHECK_DISPOSED(m_disposed); return ToBytes(offset, m_cb - offset); }
array<__wchar_t>^ zDBBinaryReader::ToChars(void) { CHECK_DISPOSED(m_disposed); return ToChars(0, m_cb); }
Guid zDBBinaryReader::ToGuid(int offset) { CHECK_DISPOSED(m_disposed); return Guid(ToBytes(0, 16)); }
DateTime zDBBinaryReader::ToDateTime(int offset) { CHECK_DISPOSED(m_disposed); return DateTime(ToInt64(offset)); // Use ToInt64() instead }
int LoadedDiagnosticCollection::Count::get(void) { CHECK_DISPOSED(m_disposed); return m_cache->Length; }
int zDBBinaryReader::Length::get(void) { CHECK_DISPOSED(m_disposed); return m_cb; }
String^ zDBBinaryReader::ToString(void) { CHECK_DISPOSED(m_disposed); return String::Format(BINARY_DATA_STRING, m_cb);; }
array<__wchar_t>^ zDBBinaryReader::ToChars(int offset) { CHECK_DISPOSED(m_disposed); return ToChars(offset, m_cb - offset); }
TypeCode zDBBinaryReader::GetTypeCode(void) { CHECK_DISPOSED(m_disposed); return TypeCode::Object; }
array<System::Byte>^ zDBBinaryReader::ToBytes(void) { CHECK_DISPOSED(m_disposed); return ToBytes(0, m_cb); }