apt 3.0.3
commandline package manager
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
pkgTagSection Class Reference

Classes

struct  Tag
 

Public Member Functions

bool operator== (const pkgTagSection &rhs)
 
bool operator!= (const pkgTagSection &rhs)
 
std::string FindS (std::string_view sv) const
 
std::string FindRawS (std::string_view sv) const
 
bool Find (std::string_view Tag, const char *&Start, const char *&End) const
 
bool Find (std::string_view Tag, unsigned int &Pos) const
 
std::string_view Find (std::string_view Tag) const
 
std::string_view FindRaw (std::string_view Tag) const
 
signed int FindI (std::string_view Tag, signed long Default=0) const
 
bool FindB (std::string_view, bool Default=false) const
 
unsigned long long FindULL (std::string_view Tag, unsigned long long const &Default=0) const
 
bool FindFlag (std::string_view Tag, uint8_t &Flags, uint8_t const Flag) const
 
bool FindFlag (std::string_view Tag, unsigned long &Flags, unsigned long Flag) const
 
bool Exists (std::string_view Tag) const
 
bool Scan (const char *Start, unsigned long MaxLength, bool const Restart=true)
 searches the boundaries of the current section
 
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
 
void Get (const char *&Start, const char *&Stop, unsigned int I) const
 
void GetSection (const char *&Start, const char *&Stop) const
 
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
 

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.

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.

Referenced by EDSP::ReadResponse().

◆ 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!

◆ 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

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