apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pkgTagSection Class Reference

#include <tagfile.h>

Collaboration diagram for pkgTagSection:
[legend]

Classes

struct  Tag
 

Public Member Functions

bool operator== (const pkgTagSection &rhs)
 
bool operator!= (const pkgTagSection &rhs)
 
std::string FindS (APT::StringView sv) const
 
std::string FindRawS (APT::StringView sv) const
 
APT_HIDDEN bool Find (Key key, const char *&Start, const char *&End) const
 
APT_HIDDEN bool Find (Key key, unsigned int &Pos) const
 
APT_HIDDEN signed int FindI (Key key, signed long Default=0) const
 
APT_HIDDEN bool FindB (Key key, bool Default=false) const
 
APT_HIDDEN unsigned long long FindULL (Key key, unsigned long long const &Default=0) const
 
APT_HIDDEN bool FindFlag (Key key, uint8_t &Flags, uint8_t const Flag) const
 
APT_HIDDEN bool FindFlag (Key key, unsigned long &Flags, unsigned long Flag) const
 
APT_HIDDEN bool Exists (Key key) const
 
APT_HIDDEN APT::StringView Find (Key key) const
 
APT_HIDDEN APT::StringView FindRaw (Key key) const
 
bool Find (APT::StringView Tag, const char *&Start, const char *&End) const
 
bool Find (APT::StringView Tag, unsigned int &Pos) const
 
APT::StringView Find (APT::StringView Tag) const
 
APT::StringView FindRaw (APT::StringView Tag) const
 
signed int FindI (APT::StringView Tag, signed long Default=0) const
 
bool FindB (APT::StringView, bool Default=false) const
 
unsigned long long FindULL (APT::StringView Tag, unsigned long long const &Default=0) const
 
bool FindFlag (APT::StringView Tag, uint8_t &Flags, uint8_t const Flag) const
 
bool FindFlag (APT::StringView Tag, unsigned long &Flags, unsigned long Flag) const
 
bool Exists (APT::StringView Tag) const
 
APT_MUSTCHECK bool Scan (const char *Start, unsigned long MaxLength, bool const Restart=true)
 searches the boundaries of the current section More...
 
unsigned long size () const
 
void Trim ()
 
virtual void TrimRecord (bool BeforeRecord, const char *&End)
 
unsigned int Count () const
 amount of Tags in the current section More...
 
void Get (const char *&Start, const char *&Stop, unsigned int I) const
 
void GetSection (const char *&Start, const char *&Stop) const
 
 pkgTagSection ()
 
virtual ~pkgTagSection ()
 
bool Write (FileFd &File, char const *const *const Order=NULL, std::vector< Tag > const &Rewrite=std::vector< Tag >()) const
 

Static Public Member Functions

static bool FindFlag (uint8_t &Flags, uint8_t const Flag, const char *const Start, const char *const Stop)
 
static bool FindFlag (unsigned long &Flags, unsigned long Flag, const char *Start, const char *Stop)
 

Protected Attributes

const char * Stop
 

Private Member Functions

APT_HIDDEN bool FindInternal (unsigned int Pos, const char *&Start, const char *&End) const
 
APT_HIDDEN APT::StringView FindInternal (unsigned int Pos) const
 
APT_HIDDEN APT::StringView FindRawInternal (unsigned int Pos) const
 
APT_HIDDEN signed int FindIInternal (unsigned int Pos, signed long Default=0) const
 
APT_HIDDEN bool FindBInternal (unsigned int Pos, bool Default=false) const
 
APT_HIDDEN unsigned long long FindULLInternal (unsigned int Pos, unsigned long long const &Default=0) const
 
APT_HIDDEN bool FindFlagInternal (unsigned int Pos, uint8_t &Flags, uint8_t const Flag) const
 
APT_HIDDEN bool FindFlagInternal (unsigned int Pos, unsigned long &Flags, unsigned long Flag) const
 

Private Attributes

const char * Section
 
unsigned int AlphaIndexes [128]
 
unsigned int BetaIndexes [128]
 
pkgTagSectionPrivate *const d
 

Detailed Description

single deb822 stanza and provides various Find methods to extract the included values. It can also be used to modify and write a valid deb822 stanza optionally (re)ordering the fields inside the stanza.

Beware: This class does NOT support (#-)comments in in- or output! If the input contains comments they have to be stripped first like pkgTagFile does with SUPPORT_COMMENTS flag set.

Definition at line 44 of file tagfile.h.

Constructor & Destructor Documentation

◆ pkgTagSection()

Definition at line 476 of file tagfile.cc.

References AlphaIndexes, and BetaIndexes.

◆ ~pkgTagSection()

~pkgTagSection ( )
virtual

Definition at line 1078 of file tagfile.cc.

References d.

Member Function Documentation

◆ Count()

APT_PURE unsigned int Count ( ) const

amount of Tags in the current section

Note: if a Tag is mentioned repeatedly it will be counted multiple times, but only the last occurrence is available via Find methods.

Definition at line 942 of file tagfile.cc.

References d, and pkgTagSectionPrivate::Tags.

Referenced by ReadPinFile(), EDSP::ReadResponse(), EIPP::ReadResponse(), pkgTagFile::Step(), and pkgDepCache::writeStateFile().

◆ Exists() [1/2]

bool Exists ( APT::StringView  Tag) const

Definition at line 624 of file tagfile.cc.

References Find().

◆ Exists() [2/2]

◆ Find() [1/6]

StringView Find ( APT::StringView  Tag) const

Definition at line 698 of file tagfile.cc.

References Find().

◆ Find() [2/6]

bool Find ( APT::StringView  Tag,
const char *&  Start,
const char *&  End 
) const

Definition at line 684 of file tagfile.cc.

References Find(), and FindInternal().

◆ Find() [3/6]

bool Find ( APT::StringView  Tag,
unsigned int &  Pos 
) const

◆ Find() [4/6]

StringView Find ( Key  key) const

Definition at line 706 of file tagfile.cc.

References Find().

◆ Find() [5/6]

◆ Find() [6/6]

bool Find ( Key  key,
unsigned int &  Pos 
) const

Definition at line 633 of file tagfile.cc.

References AlphaIndexes.

◆ FindB() [1/2]

bool FindB ( APT::StringView  Tag,
bool  Default = false 
) const

Definition at line 840 of file tagfile.cc.

References Find(), and FindBInternal().

◆ FindB() [2/2]

bool FindB ( Key  key,
bool  Default = false 
) const

Definition at line 835 of file tagfile.cc.

References Find(), and FindBInternal().

Referenced by debReleaseIndex::Load(), and edspListParser::ParseStatus().

◆ FindBInternal()

bool FindBInternal ( unsigned int  Pos,
bool  Default = false 
) const
private

Definition at line 828 of file tagfile.cc.

References FindInternal(), Stop, and StringToBool().

Referenced by FindB().

◆ FindFlag() [1/6]

bool FindFlag ( APT::StringView  Tag,
uint8_t &  Flags,
uint8_t const  Flag 
) const

Definition at line 866 of file tagfile.cc.

References Find(), and FindFlagInternal().

◆ FindFlag() [2/6]

bool FindFlag ( APT::StringView  Tag,
unsigned long &  Flags,
unsigned long  Flag 
) const

Definition at line 908 of file tagfile.cc.

References Find(), and FindFlagInternal().

◆ FindFlag() [3/6]

bool FindFlag ( Key  key,
uint8_t &  Flags,
uint8_t const  Flag 
) const

◆ FindFlag() [4/6]

bool FindFlag ( Key  key,
unsigned long &  Flags,
unsigned long  Flag 
) const

Definition at line 902 of file tagfile.cc.

References Find(), and FindFlagInternal().

◆ FindFlag() [5/6]

bool FindFlag ( uint8_t &  Flags,
uint8_t const  Flag,
const char *const  Start,
const char *const  Stop 
)
static

Definition at line 874 of file tagfile.cc.

References Stop, and StringToBool().

◆ FindFlag() [6/6]

bool FindFlag ( unsigned long &  Flags,
unsigned long  Flag,
const char *  Start,
const char *  Stop 
)
static

Definition at line 914 of file tagfile.cc.

References Stop, and StringToBool().

◆ FindFlagInternal() [1/2]

bool FindFlagInternal ( unsigned int  Pos,
uint8_t &  Flags,
uint8_t const  Flag 
) const
private

Definition at line 849 of file tagfile.cc.

References FindFlag(), FindInternal(), and Stop.

Referenced by FindFlag().

◆ FindFlagInternal() [2/2]

bool FindFlagInternal ( unsigned int  Pos,
unsigned long &  Flags,
unsigned long  Flag 
) const
private

Definition at line 893 of file tagfile.cc.

References FindFlag(), FindInternal(), and Stop.

◆ FindI() [1/2]

signed int FindI ( APT::StringView  Tag,
signed long  Default = 0 
) const

Definition at line 782 of file tagfile.cc.

References Find(), and FindIInternal().

◆ FindI() [2/2]

◆ FindIInternal()

signed int FindIInternal ( unsigned int  Pos,
signed long  Default = 0 
) const
private

Definition at line 750 of file tagfile.cc.

References FindInternal(), and Stop.

Referenced by FindI().

◆ FindInternal() [1/2]

APT_HIDDEN APT::StringView FindInternal ( unsigned int  Pos) const
private

◆ FindInternal() [2/2]

bool FindInternal ( unsigned int  Pos,
const char *&  Start,
const char *&  End 
) const
private

◆ FindRaw() [1/2]

StringView FindRaw ( APT::StringView  Tag) const

Definition at line 736 of file tagfile.cc.

References Find(), and FindRawInternal().

◆ FindRaw() [2/2]

StringView FindRaw ( Key  key) const

Definition at line 741 of file tagfile.cc.

References Find(), and FindRawInternal().

Referenced by RewriteTags(), and Write().

◆ FindRawInternal()

StringView FindRawInternal ( unsigned int  Pos) const
private

Definition at line 716 of file tagfile.cc.

References d, isspace_ascii(), Section, and pkgTagSectionPrivate::Tags.

Referenced by FindRaw().

◆ FindRawS()

std::string FindRawS ( APT::StringView  sv) const
inline

Definition at line 71 of file tagfile.h.

◆ FindS()

◆ FindULL() [1/2]

unsigned long long FindULL ( APT::StringView  Tag,
unsigned long long const &  Default = 0 
) const

Definition at line 818 of file tagfile.cc.

References Find(), and FindULLInternal().

◆ FindULL() [2/2]

unsigned long long FindULL ( Key  key,
unsigned long long const &  Default = 0 
) const

◆ FindULLInternal()

unsigned long long FindULLInternal ( unsigned int  Pos,
unsigned long long const &  Default = 0 
) const
private

Definition at line 792 of file tagfile.cc.

References FindInternal(), and Stop.

Referenced by FindULL().

◆ Get()

void Get ( const char *&  Start,
const char *&  Stop,
unsigned int  I 
) const

Definition at line 934 of file tagfile.cc.

References I.

◆ GetSection()

void GetSection ( const char *&  Start,
const char *&  Stop 
) const
inline

◆ operator!=()

bool operator!= ( const pkgTagSection rhs)
inline

Definition at line 67 of file tagfile.h.

References Section.

◆ operator==()

bool operator== ( const pkgTagSection rhs)
inline

Definition at line 66 of file tagfile.h.

References Section.

◆ Scan()

bool Scan ( const char *  Start,
unsigned long  MaxLength,
bool const  Restart = true 
)

searches the boundaries of the current section

While parameter Start marks the beginning of the section, this method will search for the first double newline in the data stream which marks the end of the section. It also does a first pass over the content of the section parsing it as encountered for processing later on by Find

Parameters
Startis the beginning of the section
MaxLengthis the size of valid data in the stream pointed to by Start
Restartif enabled internal state will be cleared, otherwise it is assumed that now more data is available in the stream and the parsing will start were it encountered insufficient data the last time.
Returns
true if section end was found, false otherwise. Beware that internal state will be inconsistent if false is returned!

Definition at line 484 of file tagfile.cc.

References AlphaIndexes, BetaHash(), BetaIndexes, d, pkgTagSectionPrivate::TagData::EndTag, isspace_ascii(), pkgTagSectionPrivate::TagData::NextInBucket, Section, pkgTagSectionPrivate::TagData::StartValue, Stop, pkgTagSectionPrivate::Tags, and TrimRecord().

Referenced by DisplayRecordV2(), DoIt(), SourcesWriter::DoPackage(), DumpAvail(), pkgTagFile::Jump(), debDebFileRecordParser::LoadContent(), DebFile::ParseInfo(), and pkgTagFile::Step().

◆ size()

unsigned long size ( ) const
inline

Definition at line 122 of file tagfile.h.

Referenced by DoIt(), pkgDepCache::readStateFile(), debListParser::Size(), and pkgTagFile::Step().

◆ Trim()

void Trim ( )

Definition at line 618 of file tagfile.cc.

References Section, and Stop.

Referenced by SourcesWriter::DoPackage(), and pkgTagFile::Step().

◆ TrimRecord()

void TrimRecord ( bool  BeforeRecord,
const char *&  End 
)
virtual

Definition at line 608 of file tagfile.cc.

References Stop.

Referenced by Scan().

◆ Write()

bool Write ( FileFd File,
char const *const *const  Order = NULL,
std::vector< Tag > const &  Rewrite = std::vector<Tag>() 
) const

Write this section (with optional rewrites) to a file

Parameters
Fileto write the section to
Orderin which tags should appear in the file
Rewriteis a set of tags to be renamed, rewritten and/or removed
Returns
true if successful, otherwise false

Definition at line 999 of file tagfile.cc.

References d, Exists(), FindRaw(), I, pkgTagSection::Tag::REMOVE, pkgTagSection::Tag::RENAME, RewriteTags(), Section, pkgTagSectionPrivate::Tags, and WriteTag().

Referenced by TranslationsCopy::CopyTranslations(), DisplayRecordV2(), DoIt(), PackagesWriter::DoPackage(), SourcesWriter::DoPackage(), DumpAvail(), PackageCopy::RewriteEntry(), SourceCopy::RewriteEntry(), and pkgDepCache::writeStateFile().

Member Data Documentation

◆ AlphaIndexes

unsigned int AlphaIndexes[128]
private

Definition at line 47 of file tagfile.h.

Referenced by Find(), pkgTagSection(), and Scan().

◆ BetaIndexes

unsigned int BetaIndexes[128]
private

Definition at line 48 of file tagfile.h.

Referenced by Find(), pkgTagSection(), and Scan().

◆ d

pkgTagSectionPrivate* const d
private

Definition at line 50 of file tagfile.h.

Referenced by Count(), Find(), FindInternal(), FindRawInternal(), Scan(), Write(), and ~pkgTagSection().

◆ Section

const char* Section
private

Definition at line 46 of file tagfile.h.

Referenced by Find(), FindInternal(), FindRawInternal(), operator!=(), operator==(), Scan(), Trim(), and Write().

◆ Stop

const char* Stop
protected

The documentation for this class was generated from the following files: