#ifndef _LLX_APT_SOURCES_ #define _LLX_APT_SOURCES_ #include #include #include namespace net { namespace lliurex { namespace apt { enum class SourceType { Deb , Source }; enum class UriType { Http, Https, Ftp, Cdrom, File }; enum class FindLineStatus { NotFound, Found, Partial }; class SourceLine { public: SourceType source_type; UriType uri_type; std::string uri; std::string dist; std::vector components; std::string ToString(); bool IsEqual(SourceLine & line); }; class Sources { protected: static std::string str_line; static std::string str_option; public: static const std::string SourcesList; bool optional; /*! describes de Sources */ std::mapname; /*! SourceList container */ std::vector lines; /*! Empty constructor */ Sources(); /*! Create a sources from a sources.list file */ Sources(std::string filename); /*! Adds a new SourceLine from a text input */ void Add(std::string line); /*! Add a new SourceLine to the list. if the line already exists it does nothing, if the line exists partially, components are merged */ void Push(SourceLine line); FindLineStatus Find(SourceLine line); /*! Pretty print source content to stdout */ void Print(); /*! Writes Sources content to disk, it fallbacks to a setuid backend + policykit to manage /etc/ write credentials */ void Write(std::string filename); }; /*! Overload addition operator merges two Sources */ Sources operator+(Sources & A,Sources & B); } } } #endif