From 8f3ba4e8708cb72be19dacc2af4f601ee5fea292 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 13:31:29 +0200 Subject: do not pollute namespace in the headers with using (Closes: #500198) --- apt-pkg/contrib/cdromutl.cc | 2 + apt-pkg/contrib/cdromutl.h | 12 ++--- apt-pkg/contrib/configuration.h | 46 ++++++++-------- apt-pkg/contrib/fileutl.h | 42 +++++++-------- apt-pkg/contrib/hashes.cc | 26 ++++----- apt-pkg/contrib/hashes.h | 17 +++--- apt-pkg/contrib/hashsum.cc | 2 +- apt-pkg/contrib/hashsum_template.h | 13 ++--- apt-pkg/contrib/md5.h | 3 -- apt-pkg/contrib/mmap.h | 4 +- apt-pkg/contrib/netrc.cc | 1 + apt-pkg/contrib/netrc.h | 2 +- apt-pkg/contrib/progress.h | 18 +++---- apt-pkg/contrib/sha1.h | 3 -- apt-pkg/contrib/strutl.h | 108 ++++++++++++++++++------------------- 15 files changed, 138 insertions(+), 161 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 9de795b60..187f6bd59 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -30,6 +30,8 @@ #include /*}}}*/ +using std::string; + // IsMounted - Returns true if the mount point is mounted /*{{{*/ // --------------------------------------------------------------------- /* This is a simple algorithm that should always work, we stat the mount point diff --git a/apt-pkg/contrib/cdromutl.h b/apt-pkg/contrib/cdromutl.h index 38ed2996e..2c6afac0f 100644 --- a/apt-pkg/contrib/cdromutl.h +++ b/apt-pkg/contrib/cdromutl.h @@ -12,13 +12,11 @@ #include -using std::string; - // mount cdrom, DeviceName (e.g. /dev/sr0) is optional -bool MountCdrom(string Path, string DeviceName=""); -bool UnmountCdrom(string Path); -bool IdentCdrom(string CD,string &Res,unsigned int Version = 2); -bool IsMounted(string &Path); -string FindMountPointForDevice(const char *device); +bool MountCdrom(std::string Path, std::string DeviceName=""); +bool UnmountCdrom(std::string Path); +bool IdentCdrom(std::string CD,std::string &Res,unsigned int Version = 2); +bool IsMounted(std::string &Path); +std::string FindMountPointForDevice(const char *device); #endif diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index 2844ec097..f6f2a3c1d 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -34,21 +34,19 @@ #include #include -using std::string; - class Configuration { public: struct Item { - string Value; - string Tag; + std::string Value; + std::string Tag; Item *Parent; Item *Child; Item *Next; - string FullTag(const Item *Stop = 0) const; + std::string FullTag(const Item *Stop = 0) const; Item() : Parent(0), Child(0), Next(0) {}; }; @@ -67,35 +65,35 @@ class Configuration public: - string Find(const char *Name,const char *Default = 0) const; - string Find(string const &Name,const char *Default = 0) const {return Find(Name.c_str(),Default);}; - string Find(string const &Name, string const &Default) const {return Find(Name.c_str(),Default.c_str());}; - string FindFile(const char *Name,const char *Default = 0) const; - string FindDir(const char *Name,const char *Default = 0) const; - std::vector FindVector(const char *Name) const; - std::vector FindVector(string const &Name) const { return FindVector(Name.c_str()); }; + std::string Find(const char *Name,const char *Default = 0) const; + std::string Find(std::string const &Name,const char *Default = 0) const {return Find(Name.c_str(),Default);}; + std::string Find(std::string const &Name, std::string const &Default) const {return Find(Name.c_str(),Default.c_str());}; + std::string FindFile(const char *Name,const char *Default = 0) const; + std::string FindDir(const char *Name,const char *Default = 0) const; + std::vector FindVector(const char *Name) const; + std::vector FindVector(std::string const &Name) const { return FindVector(Name.c_str()); }; int FindI(const char *Name,int const &Default = 0) const; - int FindI(string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);}; + int FindI(std::string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);}; bool FindB(const char *Name,bool const &Default = false) const; - bool FindB(string const &Name,bool const &Default = false) const {return FindB(Name.c_str(),Default);}; - string FindAny(const char *Name,const char *Default = 0) const; + bool FindB(std::string const &Name,bool const &Default = false) const {return FindB(Name.c_str(),Default);}; + std::string FindAny(const char *Name,const char *Default = 0) const; - inline void Set(const string &Name,const string &Value) {Set(Name.c_str(),Value);}; - void CndSet(const char *Name,const string &Value); + inline void Set(const std::string &Name,const std::string &Value) {Set(Name.c_str(),Value);}; + void CndSet(const char *Name,const std::string &Value); void CndSet(const char *Name,const int Value); - void Set(const char *Name,const string &Value); + void Set(const char *Name,const std::string &Value); void Set(const char *Name,const int &Value); - inline bool Exists(const string &Name) const {return Exists(Name.c_str());}; + inline bool Exists(const std::string &Name) const {return Exists(Name.c_str());}; bool Exists(const char *Name) const; bool ExistsAny(const char *Name) const; // clear a whole tree - void Clear(const string &Name); + void Clear(const std::string &Name); // remove a certain value from a list (e.g. the list of "APT::Keep-Fds") - void Clear(string const &List, string const &Value); - void Clear(string const &List, int const &Value); + void Clear(std::string const &List, std::string const &Value); + void Clear(std::string const &List, int const &Value); inline const Item *Tree(const char *Name) const {return Lookup(Name);}; @@ -127,11 +125,11 @@ class Configuration extern Configuration *_config; -bool ReadConfigFile(Configuration &Conf,const string &FName, +bool ReadConfigFile(Configuration &Conf,const std::string &FName, bool const &AsSectional = false, unsigned const &Depth = 0); -bool ReadConfigDir(Configuration &Conf,const string &Dir, +bool ReadConfigDir(Configuration &Conf,const std::string &Dir, bool const &AsSectional = false, unsigned const &Depth = 0); diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 973a38cff..0d0451a46 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -31,8 +31,6 @@ /* Define this for python-apt */ #define APT_HAS_GZIP 1 -using std::string; - class FileFd { protected: @@ -41,8 +39,8 @@ class FileFd enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2), HitEof = (1<<3), Replace = (1<<4) }; unsigned long Flags; - string FileName; - string TemporaryFileName; + std::string FileName; + std::string TemporaryFileName; gzFile gz; public: @@ -79,7 +77,7 @@ class FileFd return T; } - bool Open(string FileName,OpenMode Mode,unsigned long Perms = 0666); + bool Open(std::string FileName,OpenMode Mode,unsigned long Perms = 0666); bool OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose=false); bool Close(); bool Sync(); @@ -93,9 +91,9 @@ class FileFd inline void EraseOnFailure() {Flags |= DelOnFail;}; inline void OpFail() {Flags |= Fail;}; inline bool Eof() {return (Flags & HitEof) == HitEof;}; - inline string &Name() {return FileName;}; + inline std::string &Name() {return FileName;}; - FileFd(string FileName,OpenMode Mode,unsigned long Perms = 0666) : iFd(-1), + FileFd(std::string FileName,OpenMode Mode,unsigned long Perms = 0666) : iFd(-1), Flags(0), gz(NULL) { Open(FileName,Mode,Perms); @@ -107,12 +105,12 @@ class FileFd bool RunScripts(const char *Cnf); bool CopyFile(FileFd &From,FileFd &To); -int GetLock(string File,bool Errors = true); -bool FileExists(string File); -bool RealFileExists(string File); -bool DirectoryExists(string const &Path) __attrib_const; -bool CreateDirectory(string const &Parent, string const &Path); -time_t GetModificationTime(string const &Path); +int GetLock(std::string File,bool Errors = true); +bool FileExists(std::string File); +bool RealFileExists(std::string File); +bool DirectoryExists(std::string const &Path) __attrib_const; +bool CreateDirectory(std::string const &Parent, std::string const &Path); +time_t GetModificationTime(std::string const &Path); /** \brief Ensure the existence of the given Path * @@ -120,13 +118,13 @@ time_t GetModificationTime(string const &Path); * /apt/ will be removed before CreateDirectory call. * \param Path which should exist after (successful) call */ -bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path); +bool CreateAPTDirectoryIfNeeded(std::string const &Parent, std::string const &Path); -std::vector GetListOfFilesInDir(string const &Dir, string const &Ext, +std::vector GetListOfFilesInDir(std::string const &Dir, std::string const &Ext, bool const &SortList, bool const &AllowNoExt=false); -std::vector GetListOfFilesInDir(string const &Dir, std::vector const &Ext, +std::vector GetListOfFilesInDir(std::string const &Dir, std::vector const &Ext, bool const &SortList); -string SafeGetCWD(); +std::string SafeGetCWD(); void SetCloseExec(int Fd,bool Close); void SetNonBlock(int Fd,bool Block); bool WaitFd(int Fd,bool write = false,unsigned long timeout = 0); @@ -134,10 +132,10 @@ pid_t ExecFork(); bool ExecWait(pid_t Pid,const char *Name,bool Reap = false); // File string manipulators -string flNotDir(string File); -string flNotFile(string File); -string flNoLink(string File); -string flExtension(string File); -string flCombine(string Dir,string File); +std::string flNotDir(std::string File); +std::string flNotFile(std::string File); +std::string flNoLink(std::string File); +std::string flExtension(std::string File); +std::string flCombine(std::string Dir,std::string File); #endif diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index fd76bf229..05001f042 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -32,20 +32,20 @@ HashString::HashString() { } -HashString::HashString(string Type, string Hash) : Type(Type), Hash(Hash) +HashString::HashString(std::string Type, std::string Hash) : Type(Type), Hash(Hash) { } -HashString::HashString(string StringedHash) /*{{{*/ +HashString::HashString(std::string StringedHash) /*{{{*/ { // legacy: md5sum without "MD5Sum:" prefix - if (StringedHash.find(":") == string::npos && StringedHash.size() == 32) + if (StringedHash.find(":") == std::string::npos && StringedHash.size() == 32) { Type = "MD5Sum"; Hash = StringedHash; return; } - string::size_type pos = StringedHash.find(":"); + std::string::size_type pos = StringedHash.find(":"); Type = StringedHash.substr(0,pos); Hash = StringedHash.substr(pos+1, StringedHash.size() - pos); @@ -53,34 +53,34 @@ HashString::HashString(string StringedHash) /*{{{*/ std::clog << "HashString(string): " << Type << " : " << Hash << std::endl; } /*}}}*/ -bool HashString::VerifyFile(string filename) const /*{{{*/ +bool HashString::VerifyFile(std::string filename) const /*{{{*/ { - string fileHash; + std::string fileHash; FileFd Fd(filename, FileFd::ReadOnly); if(Type == "MD5Sum") { MD5Summation MD5; MD5.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)MD5.Result(); + fileHash = (std::string)MD5.Result(); } else if (Type == "SHA1") { SHA1Summation SHA1; SHA1.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)SHA1.Result(); + fileHash = (std::string)SHA1.Result(); } else if (Type == "SHA256") { SHA256Summation SHA256; SHA256.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)SHA256.Result(); + fileHash = (std::string)SHA256.Result(); } else if (Type == "SHA512") { SHA512Summation SHA512; SHA512.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)SHA512.Result(); + fileHash = (std::string)SHA512.Result(); } Fd.Close(); @@ -100,9 +100,9 @@ bool HashString::empty() const return (Type.empty() || Hash.empty()); } -string HashString::toStr() const +std::string HashString::toStr() const { - return Type+string(":")+Hash; + return Type + std::string(":") + Hash; } // Hashes::AddFD - Add the contents of the FD /*{{{*/ @@ -117,7 +117,7 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5, while (Size != 0 || ToEOF) { unsigned long long n = sizeof(Buf); - if (!ToEOF) n = min(Size, n); + if (!ToEOF) n = std::min(Size, n); Res = read(Fd,Buf,n); if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read return false; diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 40c2ad064..81851dede 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -22,31 +22,28 @@ #include #include -using std::min; -using std::vector; - // helper class that contains hash function name // and hash class HashString { protected: - string Type; - string Hash; + std::string Type; + std::string Hash; static const char * _SupportedHashes[10]; public: - HashString(string Type, string Hash); - HashString(string StringedHashString); // init from str as "type:hash" + HashString(std::string Type, std::string Hash); + HashString(std::string StringedHashString); // init from str as "type:hash" HashString(); // get hash type used - string HashType() { return Type; }; + std::string HashType() { return Type; }; // verify the given filename against the currently loaded hash - bool VerifyFile(string filename) const; + bool VerifyFile(std::string filename) const; // helper - string toStr() const; // convert to str as "type:hash" + std::string toStr() const; // convert to str as "type:hash" bool empty() const; // return the list of hashes we support diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc index 0edcbb364..ff3b112bb 100644 --- a/apt-pkg/contrib/hashsum.cc +++ b/apt-pkg/contrib/hashsum.cc @@ -14,7 +14,7 @@ bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) { while (Size != 0 || ToEOF) { unsigned long long n = sizeof(Buf); - if (!ToEOF) n = min(Size, n); + if (!ToEOF) n = std::min(Size, n); Res = read(Fd, Buf, n); if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read return false; diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index 9157754e3..c109a8212 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -15,9 +15,6 @@ #include #include -using std::string; -using std::min; - template class HashSumValue { @@ -31,7 +28,7 @@ class HashSumValue return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0; }; - string Value() const + std::string Value() const { char Conv[16] = { '0','1','2','3','4','5','6','7','8','9','a','b', @@ -48,7 +45,7 @@ class HashSumValue Result[I] = Conv[Sum[J] >> 4]; Result[I + 1] = Conv[Sum[J] & 0xF]; } - return string(Result); + return std::string(Result); }; inline void Value(unsigned char S[N/8]) @@ -57,12 +54,12 @@ class HashSumValue S[I] = Sum[I]; }; - inline operator string() const + inline operator std::string() const { return Value(); }; - bool Set(string Str) + bool Set(std::string Str) { return Hex2Num(Str,Sum,sizeof(Sum)); }; @@ -73,7 +70,7 @@ class HashSumValue Sum[I] = S[I]; }; - HashSumValue(string Str) + HashSumValue(std::string Str) { memset(Sum,0,sizeof(Sum)); Set(Str); diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h index 305cdb20d..a207da4e4 100644 --- a/apt-pkg/contrib/md5.h +++ b/apt-pkg/contrib/md5.h @@ -29,9 +29,6 @@ #include #include -using std::string; -using std::min; - #include "hashsum_template.h" typedef HashSumValue<128> MD5SumValue; diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h index e0ff8db95..387e9a170 100644 --- a/apt-pkg/contrib/mmap.h +++ b/apt-pkg/contrib/mmap.h @@ -29,8 +29,6 @@ #include #include -using std::string; - /* This should be a 32 bit type, larger tyes use too much ram and smaller types are too small. Where ever possible 'unsigned long' should be used instead of this internal type */ @@ -102,7 +100,7 @@ class DynamicMMap : public MMap unsigned long RawAllocate(unsigned long long Size,unsigned long Aln = 0); unsigned long Allocate(unsigned long ItemSize); unsigned long WriteString(const char *String,unsigned long Len = (unsigned long)-1); - inline unsigned long WriteString(const string &S) {return WriteString(S.c_str(),S.length());}; + inline unsigned long WriteString(const std::string &S) {return WriteString(S.c_str(),S.length());}; void UsePools(Pool &P,unsigned int Count) {Pools = &P; PoolCount = Count;}; DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &WorkSpace = 2*1024*1024, diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index b9d0749e2..9aa1376dc 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -24,6 +24,7 @@ #include "netrc.h" +using std::string; /* Get user and password from .netrc when given a machine name */ diff --git a/apt-pkg/contrib/netrc.h b/apt-pkg/contrib/netrc.h index 02a5eb09f..86afa43d1 100644 --- a/apt-pkg/contrib/netrc.h +++ b/apt-pkg/contrib/netrc.h @@ -25,5 +25,5 @@ // If login[0] != 0, search for password within machine and login. int parsenetrc (char *host, char *login, char *password, char *filename); -void maybe_add_auth (URI &Uri, string NetRCFile); +void maybe_add_auth (URI &Uri, std::string NetRCFile); #endif diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h index 5344323f6..7635719bc 100644 --- a/apt-pkg/contrib/progress.h +++ b/apt-pkg/contrib/progress.h @@ -25,8 +25,6 @@ #include #include -using std::string; - class Configuration; class OpProgress { @@ -38,13 +36,13 @@ class OpProgress // Change reduction code struct timeval LastTime; - string LastOp; - string LastSubOp; + std::string LastOp; + std::string LastSubOp; protected: - string Op; - string SubOp; + std::string Op; + std::string SubOp; float Percent; bool MajorChange; @@ -55,9 +53,9 @@ class OpProgress public: void Progress(unsigned long long Current); - void SubProgress(unsigned long long SubTotal, const string &Op = "", float const Percent = -1); + void SubProgress(unsigned long long SubTotal, const std::string &Op = "", float const Percent = -1); void OverallProgress(unsigned long long Current,unsigned long long Total, - unsigned long long Size,const string &Op); + unsigned long long Size,const std::string &Op); virtual void Done() {}; OpProgress(); @@ -67,8 +65,8 @@ class OpProgress class OpTextProgress : public OpProgress { protected: - - string OldOp; + + std::string OldOp; bool NoUpdate; bool NoDisplay; unsigned long LastLen; diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h index 916faec1b..b4b139a22 100644 --- a/apt-pkg/contrib/sha1.h +++ b/apt-pkg/contrib/sha1.h @@ -18,9 +18,6 @@ #include #include -using std::string; -using std::min; - #include "hashsum_template.h" typedef HashSumValue<160> SHA1SumValue; diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index ab4b54722..93f4bef4f 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -27,60 +27,56 @@ #include "macros.h" -using std::string; -using std::vector; -using std::ostream; - -bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest); +bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest); char *_strstrip(char *String); char *_strtabexpand(char *String,size_t Len); -bool ParseQuoteWord(const char *&String,string &Res); -bool ParseCWord(const char *&String,string &Res); -string QuoteString(const string &Str,const char *Bad); -string DeQuoteString(const string &Str); -string DeQuoteString(string::const_iterator const &begin, string::const_iterator const &end); +bool ParseQuoteWord(const char *&String,std::string &Res); +bool ParseCWord(const char *&String,std::string &Res); +std::string QuoteString(const std::string &Str,const char *Bad); +std::string DeQuoteString(const std::string &Str); +std::string DeQuoteString(std::string::const_iterator const &begin, std::string::const_iterator const &end); // unescape (\0XX and \xXX) from a string -string DeEscapeString(const string &input); - -string SizeToStr(double Bytes); -string TimeToStr(unsigned long Sec); -string Base64Encode(const string &Str); -string OutputInDepth(const unsigned long Depth, const char* Separator=" "); -string URItoFileName(const string &URI); -string TimeRFC1123(time_t Date); +std::string DeEscapeString(const std::string &input); + +std::string SizeToStr(double Bytes); +std::string TimeToStr(unsigned long Sec); +std::string Base64Encode(const std::string &Str); +std::string OutputInDepth(const unsigned long Depth, const char* Separator=" "); +std::string URItoFileName(const std::string &URI); +std::string TimeRFC1123(time_t Date); bool RFC1123StrToTime(const char* const str,time_t &time) __must_check; bool FTPMDTMStrToTime(const char* const str,time_t &time) __must_check; -__deprecated bool StrToTime(const string &Val,time_t &Result); -string LookupTag(const string &Message,const char *Tag,const char *Default = 0); -int StringToBool(const string &Text,int Default = -1); -bool ReadMessages(int Fd, vector &List); +__deprecated bool StrToTime(const std::string &Val,time_t &Result); +std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0); +int StringToBool(const std::string &Text,int Default = -1); +bool ReadMessages(int Fd, std::vector &List); bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0); bool StrToNum(const char *Str,unsigned long long &Res,unsigned Len,unsigned Base = 0); bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len); -bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length); +bool Hex2Num(const std::string &Str,unsigned char *Num,unsigned int Length); bool TokSplitString(char Tok,char *Input,char **List, unsigned long ListMax); -vector VectorizeString(string const &haystack, char const &split) __attrib_const; -void ioprintf(ostream &out,const char *format,...) __like_printf(2); -void strprintf(string &out,const char *format,...) __like_printf(2); +std::vector VectorizeString(std::string const &haystack, char const &split) __attrib_const; +void ioprintf(std::ostream &out,const char *format,...) __like_printf(2); +void strprintf(std::string &out,const char *format,...) __like_printf(2); char *safe_snprintf(char *Buffer,char *End,const char *Format,...) __like_printf(3); -bool CheckDomainList(const string &Host, const string &List); +bool CheckDomainList(const std::string &Host, const std::string &List); int tolower_ascii(int const c) __attrib_const __hot; -string StripEpoch(const string &VerStr); +std::string StripEpoch(const std::string &VerStr); #define APT_MKSTRCMP(name,func) \ inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ -inline int name(const string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \ -inline int name(const string& A,const string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \ -inline int name(const string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}; +inline int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \ +inline int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \ +inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}; #define APT_MKSTRCMP2(name,func) \ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ -inline int name(const string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \ -inline int name(const string& A,const string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \ -inline int name(const string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);}; +inline int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \ +inline int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \ +inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);}; int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd); int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd); @@ -89,17 +85,17 @@ int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd) case the definition of string::const_iterator is not the same as const char * and we need these extra functions */ #if __GNUC__ >= 3 -int stringcmp(string::const_iterator A,string::const_iterator AEnd, +int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd, const char *B,const char *BEnd); -int stringcmp(string::const_iterator A,string::const_iterator AEnd, - string::const_iterator B,string::const_iterator BEnd); -int stringcasecmp(string::const_iterator A,string::const_iterator AEnd, +int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd, + std::string::const_iterator B,std::string::const_iterator BEnd); +int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd, const char *B,const char *BEnd); -int stringcasecmp(string::const_iterator A,string::const_iterator AEnd, - string::const_iterator B,string::const_iterator BEnd); +int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd, + std::string::const_iterator B,std::string::const_iterator BEnd); -inline int stringcmp(string::const_iterator A,string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));}; -inline int stringcasecmp(string::const_iterator A,string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));}; +inline int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));}; +inline int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));}; #endif APT_MKSTRCMP2(stringcmp,stringcmp); @@ -109,34 +105,34 @@ inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);}; class URI { - void CopyFrom(const string &From); + void CopyFrom(const std::string &From); public: - string Access; - string User; - string Password; - string Host; - string Path; + std::string Access; + std::string User; + std::string Password; + std::string Host; + std::string Path; unsigned int Port; - operator string(); - inline void operator =(const string &From) {CopyFrom(From);}; + operator std::string(); + inline void operator =(const std::string &From) {CopyFrom(From);}; inline bool empty() {return Access.empty();}; - static string SiteOnly(const string &URI); - static string NoUserPassword(const string &URI); + static std::string SiteOnly(const std::string &URI); + static std::string NoUserPassword(const std::string &URI); - URI(string Path) {CopyFrom(Path);}; + URI(std::string Path) {CopyFrom(Path);}; URI() : Port(0) {}; }; struct SubstVar { const char *Subst; - const string *Contents; + const std::string *Contents; }; -string SubstVar(string Str,const struct SubstVar *Vars); -string SubstVar(const string &Str,const string &Subst,const string &Contents); +std::string SubstVar(std::string Str,const struct SubstVar *Vars); +std::string SubstVar(const std::string &Str,const std::string &Subst,const std::string &Contents); struct RxChoiceList { -- cgit v1.2.3 From 472ff00ef2e48383805d281c6364ec27839e3f4d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 19:14:19 +0200 Subject: use forward declaration in headers if possible instead of includes --- apt-pkg/contrib/cmndline.cc | 1 + apt-pkg/contrib/cmndline.h | 4 +--- apt-pkg/contrib/mmap.cc | 1 + apt-pkg/contrib/mmap.h | 3 ++- apt-pkg/contrib/netrc.cc | 2 ++ apt-pkg/contrib/netrc.h | 4 +++- 6 files changed, 10 insertions(+), 5 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index 34e90da20..997f26bc7 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -13,6 +13,7 @@ // Include files /*{{{*/ #include +#include #include #include #include diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h index 7c0c71aa7..b201d9855 100644 --- a/apt-pkg/contrib/cmndline.h +++ b/apt-pkg/contrib/cmndline.h @@ -44,9 +44,7 @@ #ifndef PKGLIB_CMNDLINE_H #define PKGLIB_CMNDLINE_H - - -#include +class Configuration; class CommandLine { diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index a110a7019..f76169a92 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -21,6 +21,7 @@ #include #include +#include #include #include diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h index 387e9a170..2ed4a95f8 100644 --- a/apt-pkg/contrib/mmap.h +++ b/apt-pkg/contrib/mmap.h @@ -27,7 +27,8 @@ #include -#include + +class FileFd; /* This should be a 32 bit type, larger tyes use too much ram and smaller types are too small. Where ever possible 'unsigned long' should be used diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 9aa1376dc..cb7d36088 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -14,7 +14,9 @@ #include #include +#include #include + #include #include #include diff --git a/apt-pkg/contrib/netrc.h b/apt-pkg/contrib/netrc.h index 86afa43d1..7b94eba88 100644 --- a/apt-pkg/contrib/netrc.h +++ b/apt-pkg/contrib/netrc.h @@ -14,11 +14,13 @@ #ifndef NETRC_H #define NETRC_H -#include +#include #define DOT_CHAR "." #define DIR_CHAR "/" +class URI; + // Assume: password[0]=0, host[0] != 0. // If login[0] = 0, search for login and password within a machine section // in the netrc. -- cgit v1.2.3 From 99a2ea5a2737ba6bf346e15a609d927dc03a02ea Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 11 Oct 2011 18:34:21 +0200 Subject: * apt-pkg/pkgcachegen.cc: - refactor MergeList by creating -Group, -Package and -Version specialist --- apt-pkg/contrib/hashsum_template.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index c109a8212..27d192b82 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -26,7 +26,11 @@ class HashSumValue bool operator ==(const HashSumValue &rhs) const { return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0; - }; + }; + bool operator !=(const HashSumValue &rhs) const + { + return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0; + }; std::string Value() const { -- cgit v1.2.3