bool TagEntry::operator ==(const TagEntry& rhs) { //Note: tree item id is not used in this function! bool res = m_scope == rhs.m_scope && m_file == rhs.m_file && m_kind == rhs.m_kind && m_parent == rhs.m_parent && m_pattern == rhs.m_pattern && m_name == rhs.m_name && m_path == rhs.m_path && m_lineNumber == rhs.m_lineNumber && GetInherits() == rhs.GetInherits() && GetAccess() == rhs.GetAccess() && GetSignature() == rhs.GetSignature() && GetTyperef() == rhs.GetTyperef(); bool res2 = m_scope == rhs.m_scope && m_file == rhs.m_file && m_kind == rhs.m_kind && m_parent == rhs.m_parent && m_pattern == rhs.m_pattern && m_name == rhs.m_name && m_path == rhs.m_path && GetInherits() == rhs.GetInherits() && GetAccess() == rhs.GetAccess() && GetSignature() == rhs.GetSignature() && GetTyperef() == rhs.GetTyperef(); if (res2 && !res) { // the entries are differs only in the line numbers m_differOnByLineNumber = true; } return res; }
static block_t *Block(access_t *access) { access_t *a = GetAccess(access); if (a == NULL) return NULL; if (likely(a->pf_block != NULL)) return vlc_access_Block(a); if (a->pf_read == NULL) { access->info.b_eof = true; return NULL; } /* Emulate pf_block in case of mixed pf_read and bf_block */ block_t *block = block_Alloc(4096); if (unlikely(block == NULL)) return NULL; ssize_t ret = vlc_access_Read(a, block->p_buffer, block->i_buffer); if (ret >= 0) { block->i_buffer = ret; access->info.i_pos += ret; } else { block_Release(block); block = NULL; } return block; }
EIRDataset::~EIRDataset() { FlushCache(); if( nBands > 0 && GetAccess() == GA_Update ) { int bNoDataSet; double dfNoData; RawRasterBand *poBand = (RawRasterBand *) GetRasterBand( 1 ); dfNoData = poBand->GetNoDataValue(&bNoDataSet); if( bNoDataSet ) { ResetKeyValue( "NODATA", CPLString().Printf( "%.8g", dfNoData ) ); } } if( fpImage != NULL ) VSIFCloseL( fpImage ); CSLDestroy( papszHDR ); CSLDestroy( papszExtraFiles ); }
CPLErr PAuxRasterBand::SetNoDataValue( double dfNewValue ) { if( GetAccess() == GA_ReadOnly ) { CPLError( CE_Failure, CPLE_NoWriteAccess, "Can't update readonly dataset." ); return CE_Failure; } char szTarget[128] = { '\0' }; char szValue[128] = { '\0' }; snprintf( szTarget, sizeof(szTarget), "METADATA_IMG_%d_NO_DATA_VALUE", nBand ); CPLsnprintf( szValue, sizeof(szValue), "%24.12f", dfNewValue ); PAuxDataset *poPDS = reinterpret_cast<PAuxDataset *>( poDS ); poPDS->papszAuxLines = CSLSetNameValue( poPDS->papszAuxLines, szTarget, szValue ); poPDS->bAuxUpdated = TRUE; return CE_None; }
int TagEntry::Update(wxSQLite3Statement& updatePerepareStmnt) { // If this node is a dummy, (IsOk() == false) we dont update it to database if( !IsOk() ) return TagOk; try { // see TagsDatabase::GetUpdateOneStatement() function for the order of binding updatePerepareStmnt.Bind(1, GetParentId()); updatePerepareStmnt.Bind(2, GetName()); updatePerepareStmnt.Bind(3, GetFile()); updatePerepareStmnt.Bind(4, GetLine()); updatePerepareStmnt.Bind(5, GetAccess()); updatePerepareStmnt.Bind(6, GetPattern()); updatePerepareStmnt.Bind(7, GetParent()); updatePerepareStmnt.Bind(8, GetInherits()); updatePerepareStmnt.Bind(9, GetTyperef()); updatePerepareStmnt.Bind(10, GetScope()); updatePerepareStmnt.Bind(11, GetKind()); updatePerepareStmnt.Bind(12, GetSignature()); updatePerepareStmnt.Bind(13, GetPath()); updatePerepareStmnt.ExecuteUpdate(); updatePerepareStmnt.Reset(); } catch(wxSQLite3Exception& exc) { wxLogMessage(exc.GetMessage()); return TagError; } return TagOk; }
int TagEntry::Store(wxSQLite3Statement& insertPerepareStmnt) { // If this node is a dummy, (IsOk() == false) we dont insert it to database if( !IsOk() ) return TagOk; try { // see TagsDatabase::GetInsertOneStatement() for the order of binding insertPerepareStmnt.Bind(1, GetParentId()); insertPerepareStmnt.Bind(2, GetName()); insertPerepareStmnt.Bind(3, GetFile()); insertPerepareStmnt.Bind(4, GetLine()); insertPerepareStmnt.Bind(5, GetKind()); insertPerepareStmnt.Bind(6, GetAccess()); insertPerepareStmnt.Bind(7, GetSignature()); insertPerepareStmnt.Bind(8, GetPattern()); insertPerepareStmnt.Bind(9, GetParent()); insertPerepareStmnt.Bind(10, GetInherits()); insertPerepareStmnt.Bind(11, GetPath()); insertPerepareStmnt.Bind(12, GetTyperef()); insertPerepareStmnt.Bind(13, GetScope()); insertPerepareStmnt.ExecuteUpdate(); insertPerepareStmnt.Reset(); } catch(wxSQLite3Exception& exc) { if(exc.ErrorCodeAsString(exc.GetErrorCode()) == wxT("SQLITE_CONSTRAINT")) return TagExist; wxLogMessage(exc.GetMessage()); return TagError; } return TagOk; }
int TagEntry::CompareDisplayString(const TagEntryPtr& rhs) const { wxString d1, d2; d1 << GetReturnValue() << wxT(": ") << GetFullDisplayName() << wxT(":") << GetAccess(); d2 << rhs->GetReturnValue() << wxT(": ") << rhs->GetFullDisplayName() << wxT(":") << rhs->GetAccess(); return d1.Cmp(d2); }
EnumTypeIR JsonIRReader::EnumTypeJsonToIR(const JsonObjectRef &enum_type) { EnumTypeIR enum_type_ir; ReadTypeInfo(enum_type, &enum_type_ir); enum_type_ir.SetUnderlyingType(enum_type.GetString("underlying_type")); enum_type_ir.SetAccess(GetAccess(enum_type)); ReadEnumFields(enum_type, &enum_type_ir); ReadTagTypeInfo(enum_type, &enum_type_ir); return enum_type_ir; }
void JsonIRReader::ReadBaseSpecifiers(const JsonObjectRef &record_type, RecordTypeIR *record_ir) { for (auto &&base_specifier : record_type.GetObjects("base_specifiers")) { CXXBaseSpecifierIR record_base_ir( base_specifier.GetString("referenced_type"), base_specifier.GetBool("is_virtual"), GetAccess(base_specifier)); record_ir->AddCXXBaseSpecifier(std::move(record_base_ir)); } }
void JsonIRReader::ReadRecordFields(const JsonObjectRef &record_type, RecordTypeIR *record_ir) { for (auto &&field : record_type.GetObjects("fields")) { RecordFieldIR record_field_ir( field.GetString("field_name"), field.GetString("referenced_type"), field.GetUint("field_offset"), GetAccess(field)); record_ir->AddRecordField(std::move(record_field_ir)); } }
FunctionIR JsonIRReader::FunctionJsonToIR(const JsonObjectRef &function) { FunctionIR function_ir; function_ir.SetLinkerSetKey(function.GetString("linker_set_key")); function_ir.SetName(function.GetString("function_name")); function_ir.SetAccess(GetAccess(function)); function_ir.SetSourceFile(function.GetString("source_file")); ReadFunctionParametersAndReturnType(function, &function_ir); ReadTemplateInfo(function, &function_ir); return function_ir; }
// // Calls each of the Get functions. // void CAccessDialog::GetAll(Access_Spec * spec) { spec->size = GetSize(); spec->of_size = GetAccess(); spec->reads = GetReads(); spec->random = GetRandom(); spec->delay = GetDelay(); spec->burst = GetBurst(); spec->align = GetAlign(); spec->reply = GetReply(); }
int OGRElasticDataSource::TestCapability(const char * pszCap) { if (EQUAL(pszCap, ODsCCreateLayer) || EQUAL(pszCap, ODsCDeleteLayer) || EQUAL(pszCap, ODsCCreateGeomFieldAfterCreateLayer) ) { return GetAccess() == GA_Update; } return FALSE; }
void JsonIRReader::ReadGlobalVariables(const JsonObjectRef &tu) { for (auto &&global_variable : tu.GetObjects("global_vars")) { GlobalVarIR global_variable_ir; global_variable_ir.SetName(global_variable.GetString("name")); global_variable_ir.SetAccess(GetAccess(global_variable)); global_variable_ir.SetSourceFile(global_variable.GetString("source_file")); global_variable_ir.SetReferencedType( global_variable.GetString("referenced_type")); global_variable_ir.SetLinkerSetKey( global_variable.GetString("linker_set_key")); module_->AddGlobalVariable(std::move(global_variable_ir)); } }
RecordTypeIR JsonIRReader::RecordTypeJsonToIR(const JsonObjectRef &record_type) { RecordTypeIR record_type_ir; ReadTypeInfo(record_type, &record_type_ir); ReadTemplateInfo(record_type, &record_type_ir); record_type_ir.SetAccess(GetAccess(record_type)); ReadVTableLayout(record_type, &record_type_ir); ReadRecordFields(record_type, &record_type_ir); ReadBaseSpecifiers(record_type, &record_type_ir); record_type_ir.SetRecordKind(GetRecordKind(record_type)); record_type_ir.SetAnonymity(record_type.GetBool("is_anonymous")); ReadTagTypeInfo(record_type, &record_type_ir); return record_type_ir; }
static ssize_t Read(access_t *access, void *buf, size_t len) { access_t *a = GetAccess(access); if (a == NULL) return 0; /* NOTE: Since we recreate the underlying access, the access method can * change. We need to check it. For instance, a path could point to a * regular file during Open() yet point to a directory here and now. */ if (unlikely(a->pf_read == NULL)) return 0; return vlc_stream_ReadPartial(a, buf, len); }
// // Checks for the validity of the entered access spec. // BOOL CAccessDialog::CheckAccess() { int line_index; int total_access = 0; CString spec_name; Test_Spec *name_spec; // There must be no more than 100 entries, the sum of the "% of Access" // fields for all the entries must equal 100, and all sizes must be > 0. for (line_index = 0; line_index < m_LAccess.GetItemCount(); line_index++) { item_being_changed = line_index; if (GetSize() <= 0) { ErrorMessage("A line in the access specification is for 0 bytes. " "All sizes must be greater than 0."); return FALSE; } total_access += GetAccess(); } if (total_access != 100) { ErrorMessage("Percent of Access Specification values must sum to exactly 100."); return FALSE; } // Update the spec's name with the name in the edit box. m_EName.GetWindowText(spec_name.GetBuffer(MAX_WORKER_NAME), MAX_WORKER_NAME); spec_name.ReleaseBuffer(); spec_name.TrimLeft(); //remove leading & trailing whitespace (bug #363) spec_name.TrimRight(); m_EName.SetWindowText(spec_name); //update edit control // Check for a blank name if (spec_name.IsEmpty()) { ErrorMessage("You must assign a name to this access specification."); return FALSE; } // Check for commas in the name. Commas invalidate the results file, which is comma separated. if (spec_name.Find(',') != -1) { ErrorMessage("Commas are not allowed in access specification names."); return FALSE; } // Check for duplicate names. name_spec = theApp.access_spec_list.RefByName((LPCTSTR) spec_name); if (name_spec && name_spec != spec) { ErrorMessage("An access specification named \"" + spec_name + "\" already exists. " + "Access specification names must be unique."); return FALSE; } return TRUE; }
void PAuxRasterBand::SetDescription( const char *pszNewDescription ) { if( GetAccess() == GA_Update ) { char szTarget[128]; snprintf( szTarget, sizeof(szTarget), "ChanDesc-%d", nBand ); PAuxDataset *poPDS = reinterpret_cast<PAuxDataset *>( poDS ); poPDS->papszAuxLines = CSLSetNameValue( poPDS->papszAuxLines, szTarget, pszNewDescription ); poPDS->bAuxUpdated = TRUE; } GDALRasterBand::SetDescription( pszNewDescription ); }
static int Seek(access_t *access, uint64_t position) { access_sys_t *sys = access->p_sys; if (sys->access != NULL) { vlc_access_Delete(sys->access); sys->access = NULL; } sys->next = sys->first; access->info.i_pos = 0; for (;;) { access_t *a = GetAccess(access); if (a == NULL) break; bool can_seek; access_Control(a, ACCESS_CAN_SEEK, &can_seek); if (!can_seek) break; uint64_t size; if (access_GetSize(a, &size)) break; if (position - access->info.i_pos < size) { if (vlc_access_Seek(a, position - access->info.i_pos)) break; access->info.i_pos = position; return VLC_SUCCESS; } access->info.i_pos += size; vlc_access_Delete(a); sys->access = NULL; } return VLC_EGENERIC; }
// Done bool OTVariable::Compare(OTVariable & rhs) { if (!(GetName().Compare(rhs.GetName()))) { OTLog::vOutput(0, "OTVariable::Compare: Names don't match: %s / %s \n", GetName().Get(), rhs.GetName().Get()); return false; } if ( ! (GetType() == rhs.GetType()) ) { OTLog::vOutput(0, "OTVariable::Compare: Type doesn't match: %s \n", GetName().Get()); return false; } if ( ! (GetAccess() == rhs.GetAccess()) ) { OTLog::vOutput(0, "OTVariable::Compare: Access types don't match: %s \n", GetName().Get()); return false; } // ------------------------------- bool bMatch = false; switch (GetType()) { case OTVariable::Var_Integer: bMatch = (GetValueInteger() == rhs.GetValueInteger()); break; case OTVariable::Var_Bool: bMatch = (GetValueBool() == rhs.GetValueBool()); break; case OTVariable::Var_String: bMatch = (GetValueString().compare(rhs.GetValueString()) == 0); break; default: OTLog::vError("OTVariable::Compare: Unknown type in variable %s.\n", m_strName.Get()); break; } return bMatch; }
void PAuxRasterBand::SetDescription( const char *pszNewDescription ) { PAuxDataset *poPDS = (PAuxDataset *) poDS; if( GetAccess() == GA_Update ) { char szTarget[128]; sprintf( szTarget, "ChanDesc-%d", nBand ); poPDS->papszAuxLines = CSLSetNameValue( poPDS->papszAuxLines, szTarget, pszNewDescription ); poPDS->bAuxUpdated = TRUE; } GDALRasterBand::SetDescription( pszNewDescription ); }
bool TagEntry::operator ==(const TagEntry& rhs) { //Note: tree item id is not used in this function! return m_parentId == rhs.m_parentId && m_scope == rhs.m_scope && m_file == rhs.m_file && m_kind == rhs.m_kind && m_parent == rhs.m_parent && m_pattern == rhs.m_pattern && m_lineNumber == rhs.m_lineNumber && m_name == rhs.m_name && m_path == rhs.m_path && GetInherits() == rhs.GetInherits() && GetAccess() == rhs.GetAccess() && GetSignature() == rhs.GetSignature() && GetPosition() == rhs.GetPosition() && GetTyperef() == rhs.GetTyperef(); }
static ssize_t Read(access_t *access, uint8_t *buf, size_t len) { access_t *a = GetAccess(access); if (a == NULL) return 0; /* NOTE: Since we recreate the underlying access, the access method can * change. We need to check it. For instance, a path could point to a * regular file during Open() yet point to a directory here and now. */ if (unlikely(a->pf_read == NULL)) { access->info.b_eof = true; return 0; } ssize_t ret = vlc_access_Read(a, buf, len); if (ret >= 0) access->info.i_pos += ret; return ret; }
CPLErr PAuxRasterBand::SetNoDataValue( double dfNewValue ) { PAuxDataset *poPDS = (PAuxDataset *) poDS; char szTarget[128]; char szValue[128]; if( GetAccess() == GA_ReadOnly ) { CPLError( CE_Failure, CPLE_NoWriteAccess, "Can't update readonly dataset." ); return CE_Failure; } sprintf( szTarget, "METADATA_IMG_%d_NO_DATA_VALUE", nBand ); sprintf( szValue, "%24.12f", dfNewValue ); poPDS->papszAuxLines = CSLSetNameValue( poPDS->papszAuxLines, szTarget, szValue ); poPDS->bAuxUpdated = TRUE; return CE_None; }
bool CGXDLMSObject::CanRead(int index) { return GetAccess(index) != ACCESSMODE_NONE; }
access_t *a = GetAccess(access); if (a == NULL) return 0; /* NOTE: Since we recreate the underlying access, the access method can * change. We need to check it. For instance, a path could point to a * regular file during Open() yet point to a directory here and now. */ if (unlikely(a->pf_read == NULL)) return 0; return vlc_stream_ReadPartial(a, buf, len); } static block_t *Block(access_t *access, bool *restrict eof) { access_t *a = GetAccess(access); if (a == NULL) { *eof = true; return NULL; } return vlc_stream_ReadBlock(a); } static int Seek(access_t *access, uint64_t position) { access_sys_t *sys = access->p_sys; if (sys->access != NULL) {
CPLErr RasterliteDataset::IBuildOverviews( const char * pszResampling, int nOverviews, int * panOverviewList, int nBands, int * panBandList, GDALProgressFunc pfnProgress, void * pProgressData ) { CPLErr eErr = CE_None; if (nLevel != 0) { CPLError(CE_Failure, CPLE_AppDefined, "Overviews can only be computed on the base dataset"); return CE_Failure; } if (osTableName.size() == 0) return CE_Failure; /* -------------------------------------------------------------------- */ /* If we don't have read access, then create the overviews */ /* externally. */ /* -------------------------------------------------------------------- */ if( GetAccess() != GA_Update ) { CPLDebug( "Rasterlite", "File open for read-only accessing, " "creating overviews externally." ); if (nResolutions != 1) { CPLError(CE_Failure, CPLE_NotSupported, "Cannot add external overviews to a " "dataset with internal overviews"); return CE_Failure; } bCheckForExistingOverview = FALSE; eErr = GDALDataset::IBuildOverviews( pszResampling, nOverviews, panOverviewList, nBands, panBandList, pfnProgress, pProgressData ); bCheckForExistingOverview = TRUE; return eErr; } /* -------------------------------------------------------------------- */ /* If zero overviews were requested, we need to clear all */ /* existing overviews. */ /* -------------------------------------------------------------------- */ if (nOverviews == 0) { return CleanOverviews(); } if( nBands != GetRasterCount() ) { CPLError( CE_Failure, CPLE_NotSupported, "Generation of overviews in RASTERLITE only" " supported when operating on all bands.\n" "Operation failed.\n" ); return CE_Failure; } if( !EQUALN(pszResampling, "NEAR", 4)) { CPLError( CE_Failure, CPLE_NotSupported, "Only NEAREST resampling is allowed for now " "for RASTERLITE overviews"); return CE_Failure; } int i; for(i=0;i<nOverviews && eErr == CE_None;i++) { if (panOverviewList[i] <= 1) continue; eErr = CleanOverviewLevel(panOverviewList[i]); if (eErr == CE_None) eErr = CreateOverviewLevel(panOverviewList[i], pfnProgress, pProgressData); ReloadOverviews(); } return eErr; }
CPLErr RasterliteDataset::IBuildOverviews( const char * pszResampling, int nOverviews, int * panOverviewList, int nBands, int * panBandList, GDALProgressFunc pfnProgress, void * pProgressData ) { CPLErr eErr = CE_None; if (nLevel != 0) { CPLError(CE_Failure, CPLE_AppDefined, "Overviews can only be computed on the base dataset"); return CE_Failure; } if (osTableName.size() == 0) return CE_Failure; /* -------------------------------------------------------------------- */ /* If we don't have read access, then create the overviews */ /* externally. */ /* -------------------------------------------------------------------- */ if( GetAccess() != GA_Update ) { CPLDebug( "Rasterlite", "File open for read-only accessing, " "creating overviews externally." ); if (nResolutions != 1) { CPLError(CE_Failure, CPLE_NotSupported, "Cannot add external overviews to a " "dataset with internal overviews"); return CE_Failure; } bCheckForExistingOverview = FALSE; eErr = GDALDataset::IBuildOverviews( pszResampling, nOverviews, panOverviewList, nBands, panBandList, pfnProgress, pProgressData ); bCheckForExistingOverview = TRUE; return eErr; } /* -------------------------------------------------------------------- */ /* If zero overviews were requested, we need to clear all */ /* existing overviews. */ /* -------------------------------------------------------------------- */ if (nOverviews == 0) { return CleanOverviews(); } if( nBands != GetRasterCount() ) { CPLError( CE_Failure, CPLE_NotSupported, "Generation of overviews in RASTERLITE only" " supported when operating on all bands.\n" "Operation failed.\n" ); return CE_Failure; } const char* pszOvrOptions = CPLGetConfigOption("RASTERLITE_OVR_OPTIONS", NULL); char** papszOptions = (pszOvrOptions) ? CSLTokenizeString2( pszOvrOptions, ",", 0) : NULL; GDALValidateCreationOptions( GetDriver(), papszOptions); int i; for(i=0;i<nOverviews && eErr == CE_None;i++) { if (panOverviewList[i] <= 1) continue; eErr = CleanOverviewLevel(panOverviewList[i]); if (eErr == CE_None) eErr = CreateOverviewLevel(pszResampling, panOverviewList[i], papszOptions, pfnProgress, pProgressData); ReloadOverviews(); } CSLDestroy(papszOptions); return eErr; }