This file defines several SeqDB utility functions related to byte order and file system portability. More...
Go to the source code of this file.
Go to the SVN repository for this file.
template<typename T > T SeqDB_GetStdOrdUnaligned (const T *stdord_obj) Reads a network order integer and returns a value. More...This file defines several SeqDB utility functions related to byte order and file system portability.
Implemented for: UNIX, MS-Windows
Definition in file seqdbgeneral.hpp.
◆ ALIGNED_TO_POW2 #define ALIGNED_TO_POW2 ( x, y ) (! ((x) & (0-y)))Checks if a number is congruent to zero, modulo a power of 2.
Definition at line 130 of file seqdbgeneral.hpp.
◆ FENCE_SENTRYFence Sentry value, which is placed at either end of ranges of data that are included in partially fetched sequences; this only applies to CSeqDBExpert objects, where SetOffsetRanges() has been called.
Definition at line 1229 of file seqdbgeneral.hpp.
◆ IS_POWER_OF_TWO #define IS_POWER_OF_TWO ( x ) (((x) & ((x)-1)) == 0)Discretely tests whether an integer is a power of two.
Definition at line 127 of file seqdbgeneral.hpp.
◆ PTR_ALIGNED_TO_SELF_SIZEIs the provided pointer aligned to the size (which must be a power of two) of the type to which it points?
Definition at line 134 of file seqdbgeneral.hpp.
◆ SEQDB_FILE_ASSERT #define SEQDB_FILE_ASSERT ( YESNO ) Value:do { \
if (! (YESNO)) { \
SeqDB_FileIntegrityAssert(__FILE__, __LINE__, (#YESNO)); \
} \
} while(0)
Definition at line 1123 of file seqdbgeneral.hpp.
◆ SEQDB_ISEOL #define SEQDB_ISEOL ( x ) (((x) == '\n') || ((x) == '\r')) ◆ s_SeqDB_QuickAssign() [1/2]Higher Performance String Assignment.
Gcc's default assignment and modifier methods (insert, operator = and operator += for instance) for strings do not use the capacity doubling technique (i.e. as used by vector::push_back()) until the length is about the size of a disk block. For our purposes, they often should use doubling. The following assignment function provides the doubling functionality for assignment. I use the assign(char*,char*) overload because it does not discard excess capacity.
Definition at line 210 of file seqdbgeneral.hpp.
Referenced by CSeqDB_BasePath::Assign(), CSeqDB_Path::Assign(), CSeqDB_Substring::GetStringQuick(), CSeqDB_BasePath::operator=(), CSeqDB_DirName::operator=(), CSeqDB_Path::operator=(), s_ConvertV4toV5(), s_SeqDB_QuickAssign(), s_SeqDB_ReadLine(), and SeqDB_JoinDelim().
◆ s_SeqDB_QuickAssign() [2/2]Higher Performance String Assignment.
String to string assignment, using the above function.
Definition at line 235 of file seqdbgeneral.hpp.
References s_SeqDB_QuickAssign().
◆ SeqDB_CombineAndQuote() ◆ SeqDB_CombinePath()Combine a filesystem path and file name.
Combine a provided filesystem path and a file name. This function tries to avoid duplicated delimiters. If either string is empty, the other is returned. Conceptually, the first path might be the current working directory and the second path is a filename. So, if the second path starts with "/", the first path is ignored. Also, care is taken to avoid duplicated delimiters. If the first path ends with the delimiter character, another delimiter will not be added between the strings. The delimiter used will vary from operating system to operating system, and is adjusted accordingly. If a file extension is specified, it will also be appended.
Definition at line 131 of file seqdbcommon.cpp.
References CSeqDB_Substring::Empty(), CSeqDB_Substring::GetBegin(), CSeqDB_Substring::GetEnd(), CDirEntry::GetPathSeparator(), CSeqDB_Substring::GetString(), isalpha(), and CSeqDB_Substring::Size().
Referenced by CSeqDB_BasePath::CSeqDB_BasePath(), CSeqDB_Path::CSeqDB_Path(), CSeqDBLMDBSet::CSeqDBLMDBSet(), CSeqDB_Path::ReplaceFilename(), s_SeqDB_TryPaths(), and CVDBAliasNode::x_ResolveVDBList().
◆ SeqDB_ConvertOSPath() void SeqDB_ConvertOSPath ( string & dbs ) ◆ SeqDB_FileIntegrityAssert()Report file corruption by throwing an eFile CSeqDBException.
This function is only called in the case of validation failure, and is used in code paths where the validation failure may be related to file corruption or filesystem problems. File data is considered a user input, so checks for corrupt file are treated as input validation. This means that (1) checks that may be caused by file corruption scenarios are not disabled in debug mode, and (2) an exception (rather than an abort) is used. Note that this function does not check the assert, so it should only be called in case of failure.
Definition at line 2255 of file seqdbcommon.cpp.
References CSeqDBException::eFileErr, file, NStr::IntToString(), msg(), SeqDB_ThrowException(), and text().
◆ SeqDB_FindBlastDBPath()Finds a file in the search path.
This function resolves the full name of a file. It searches for a file of the provided base name and returns the provided name with the full path attached. If the exact_name flag is set, the file is assumed to have any extension it may need, and none is added for searching or stripped from the return value. If exact_name is not set, the file is assumed to end in ".pin", ".nin", ".pal", or ".nal", and if such a file is found, that extension is stripped from the returned string. Furthermore, in the exact_name == false case, only file extensions relevant to the dbtype are considered. Thus, if dbtype is set to 'p' for protein, only ".pin" and ".pal" are checked for; if it is set to nucleotide, only ".nin" and ".nal" are considered. The places where the file may be found are dependant on the search path. The search path consists of the current working directory, the contents of the BLASTDB environment variable, the BLASTDB member of the BLAST group of settings in the NCBI meta-registry. This registry is an interface to settings found in (for example) a ".ncbirc" file found in the user's home directory (but several paths are usually checked). Finally, if the provided file_name starts with the default path delimiter (which is OS dependant, but for example, "/" on Linux), the path will be taken to be absolute, and the search path will not affect the results.
Definition at line 416 of file seqdbcommon.cpp.
References dbname(), CSeqDBAtlas::GetSearchPath(), and s_SeqDB_FindBlastDBPath().
Referenced by CSeqDBAliasSets::x_FindBlastDBPath(), and CSeqDBAliasNode::x_ResolveNames().
◆ SeqDB_GetBroken()template<typename T >
T SeqDB_GetBroken ( const T * stdord_obj ) inline ◆ SeqDB_GetBrokenUnaligned()template<typename T >
T SeqDB_GetBrokenUnaligned ( const T * stdord_obj ) inlineRead an unaligned integer into memory.
This template builds a function that reads an integer (on any platform) by reading one byte at a time and assembling the value. The word "Broken" refers to fact that the integer in question is in the opposite of network byte order, and this function is called in those cases. (Currently, this only happens for the 8 byte volume size stored in the index file.)
Definition at line 104 of file seqdbgeneral.hpp.
References T.
Referenced by SeqDB_GetBroken().
◆ SeqDB_GetStdOrd()template<typename T >
T SeqDB_GetStdOrd ( const T * stdord_obj ) inlineRead a network order integer value.
Definition at line 170 of file seqdbgeneral.hpp.
References SeqDB_GetStdOrdUnaligned().
Referenced by CTaxDBFileInfo::CTaxDBFileInfo(), CSeqDBIdxFile::GetAmbStartEnd(), CSeqDB::GetDate(), CSeqDBIdxFile::GetHdrStartEnd(), CSeqDBTaxId::GetOffset(), CSeqDBGiIndex::GetSeqGI(), CSeqDBIdxFile::GetSeqStart(), CSeqDBIdxFile::GetSeqStartEnd(), CSeqDBTaxId::GetTaxId(), CSeqDBRawFile::ReadSwapped(), s_ConvertV4toV5(), SeqDB_ReadBinaryGiList(), SeqDB_ReadMemoryGiList(), SeqDB_ReadMemoryPigList(), SeqDB_ReadMemoryTaxIdList(), SeqDB_ReadMemoryTiList(), SeqDB_UnpackAmbiguities(), CSeqDBIsam::x_DiffSample(), CSeqDBVol::x_GetAmbChar(), CSeqDBIsam::x_GetIndexKeyOffset(), CSeqDBIsam::x_GetNumericData(), CSeqDBIsam::x_GetNumericKey(), CSeqDBIsam::x_InitSearch(), CSeqDBIsam::x_LoadIndex(), and CSeqDBIsam::x_LoadPage().
◆ SeqDB_GetStdOrdUnaligned()template<typename T >
T SeqDB_GetStdOrdUnaligned ( const T * stdord_obj ) inlineReads a network order integer and returns a value.
Integer types stored in platform-independent blast database files usually have network byte order. This template builds a function which reads such an integer and returns its value. It may or may not need to swap the integer, depending on the endianness of the platform. If the integer is not aligned to a multiple of the size of the data type, it will still be read byte-wise rather than word-wise. This is done to avoid bus errors on some platforms.
Definition at line 59 of file seqdbgeneral.hpp.
References _ASSERT, CByteSwap::GetInt2(), CByteSwap::GetInt4(), CByteSwap::GetInt8(), and T.
Referenced by SeqDB_GetStdOrd().
◆ SeqDB_JoinDelim()Join two strings with a delimiter.
This function returns whichever of two provided strings is non-empty. If both are non-empty, they are joined with a delimiter placed between them. It is intended for use when combining strings, such as a space delimited list of database volumes. It is probably not suitable for joining file system paths with filenames (use something like SeqDB_CombinePaths).
Definition at line 480 of file seqdbcommon.cpp.
References a, b, and s_SeqDB_QuickAssign().
Referenced by CSeqDB_TitleWalker::AddString().
◆ SeqDB_MapFind()template<class T , class U >
◆ SeqDB_RemoveDirName() ◆ SeqDB_RemoveExtn() ◆ SeqDB_RemoveFileName() ◆ SeqDB_SplitQuoted() ◆ SeqDB_SplitString()Parse a prefix from a substring.
The `buffer' argument is searched for a character. If found, the region before the delimiter is returned in `front' and the region after the delimiter is returned in `buffer', and true is returned. If not found, neither argument changes and false is returned.
Definition at line 113 of file seqdbcommon.cpp.
References buffer, ctll::front(), and i.
Referenced by CSeqDBTaxInfo::GetTaxNames().
◆ SeqDB_ThrowException() ◆ SeqDB_VectorAssign()template<class T , class U >
int SeqDB_VectorAssign ( const T & data, vector< U > & v )Copy into a vector efficiently.
This copies data into a vector which may not be empty beforehand. It is more efficient than freeing the vector for cases like vector<string>, where the existing string buffers may be large enough to hold the new elements. The vector is NOT resized downward but the caller may do a resize() if needed. This design was chosen because for some types (such as vector<string>), more efficient code can be written if element destruction/construction is avoided. The number of elements assigned is returned.
Definition at line 1269 of file seqdbgeneral.hpp.
References data, i, ITERATE, and T.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4