From 3ccc8adaa879a38eec65a5f3ef0ac3bfeef45164 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Wed, 23 Nov 2005 19:23:15 +0000 Subject: [PATCH] Fixed printing of dependencies. Added zypp/NeedAType.h for drafting types to implement. --- zypp/Capability.cc | 2 +- zypp/Edition.h | 2 +- zypp/Makefile.am | 2 +- zypp/NeedAType.h | 124 ++++++++++++++++++++++++++++++++++++++++++ zypp/Rel.h | 2 +- zypp/ResObject.cc | 4 +- zypp/ResObject.h | 4 +- zypp/base/PtrTypes.h | 18 ++++++ zypp/detail/ResObjectImplIf.h | 13 ++--- 9 files changed, 156 insertions(+), 15 deletions(-) create mode 100644 zypp/NeedAType.h diff --git a/zypp/Capability.cc b/zypp/Capability.cc index 4746779..bf0e9c4 100644 --- a/zypp/Capability.cc +++ b/zypp/Capability.cc @@ -59,7 +59,7 @@ namespace zypp */ std::ostream & operator<<( std::ostream & str, const Capability & obj ) { - return str << obj._pimpl._dptr; + return str << obj._pimpl; } ///////////////////////////////////////////////////////////////// diff --git a/zypp/Edition.h b/zypp/Edition.h index c364062..6235dbb 100644 --- a/zypp/Edition.h +++ b/zypp/Edition.h @@ -64,7 +64,7 @@ namespace zypp public: /** Compare two Editions using relational operator \a op. - * \return Result of expression \t ( \a lhs \a op \a rhs \t ).
+ * \return Result of expression \c ( \a lhs \a op \a rhs \c ).
* If \a op is Rel::ANY, the expression is always \c true.
* If \a op is Rel::NONE, the expression is always \c false. * diff --git a/zypp/Makefile.am b/zypp/Makefile.am index 2431e83..9cdc547 100644 --- a/zypp/Makefile.am +++ b/zypp/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = base parser capability source detail ## ################################################## -include_HEADERS = \ +include_HEADERS = NeedAType.h \ Arch.h \ Capability.h \ CapFactory.h \ diff --git a/zypp/NeedAType.h b/zypp/NeedAType.h new file mode 100644 index 0000000..3645668 --- /dev/null +++ b/zypp/NeedAType.h @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/NeedAType.h + * +*/ +#ifndef ZYPP_NEEDATYPE_H +#define ZYPP_NEEDATYPE_H + +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /** \defgroup NEEDATYPE Wishlist of types + + Whenever you find something that might be worth being a + type, and not just an \c unsigned or \c string. Keep it here. + + Start with a resonable \c typedef or \c class draft, so you + can start using the type within the implementation. If you're + in need for interface methods, add them to the draft. Think about + the interface and expected behaviour, but implement \b here just + as much as you actually need. + + Goal is to provide a real class for it, or to find out that a + typedef is sufficient, ot the type is not needed anyway. + + If you already implemented something which would fit into this + group, but don't want to move it here, put doxygens + \code \ingroup NEEDATYPE \endcode tag in it's comment. So it will + at least appear in the doc. + + \note Don't put stuff here, that's (almost) ready to use. This is + not meant to be a convenience include. Goal is to have this file empty. + */ + //@{ + + + /** Class representing an URL. + something like liby2utils Url class. But we + need clearly documented rules for parsing, and the way the broken down + URL parts are stored withtin the class. This addresses especially + the escaping and deescaping of special characters. It must be obvious to + the user of the class, wheter an interface funtion deals with + escaped, deescaped or hidden (in case of password) representation of the + value. + + These rule may depend on the kind of URL protocol. The same for the + recognized set of URL options we support. User/Passwd can be given + in the URL or as option. + + There could be a common URL interface class which forwards all requests + to an implementation class which may be specialized dependent on the URL + protocol. + + There should be no obvious difference between known and unknown protocols. + It should be possible to register an implementation class factory (or + prototype) for a certain protocol at runtime. + */ + typedef std::string Url; + + /** Convenient handling of pathnmes. */ + typedef std::string Pathname; + + /** Single line of (human readable) text. + probabely sufficient as typedef. we may use it to classify the + various strings and string lists within resolvable and other classes. + More a hint to the UI describing the purpose of the string. */ + typedef std::string Label; + + /** Single line of (human readable) text. See Label. A description would + Text, while a a packages file list would be list */ + typedef std::list Text; + + /** Class representing a Date (time_t). Basically store a time_t and offer + conversions into formated strings. */ + typedef time_t Date; + + /** Class representing a F(ile)Size, or ammount of byte. arithmetic + operations needed e.g. for disk usage calculation. conversions into + formated strings. Interface supports specifying FSize in (ammount,unit) + KB MB GB.... + */ + typedef long long FSize; + + /** Vendor. Worth a typedef. Maybe a class unifying the strings. */ + typedef std::string Vendor; + + /** Handle Strings like "en_US". Offerrs their CountryCode and + LanguageCode parts. */ + typedef std::string Locale; + + /** CountryCode of locale (from libutil incl. translations) */ + typedef std::string CountryCode; + + /** LanguageCode of locale (from libutil incl. translations) */ + typedef std::string LanguageCode; + + /** Handle data depending on a locale. Translated strings, maybe + other too. */ + template + struct MultiLocale : public std::map + {}; + + /** stream reading compessed or uncompress files */ + typedef std::ifstream ifgzstream; + + /** stream writing compessed or uncompress files */ + typedef std::ofstream ofgzstream; + + //@} + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_NEEDATYPE_H diff --git a/zypp/Rel.h b/zypp/Rel.h index b5f1ac3..cd534d0 100644 --- a/zypp/Rel.h +++ b/zypp/Rel.h @@ -41,7 +41,7 @@ namespace zypp struct Rel { /** \name Relational operators - * These are the \en real relational operator contants to + * These are the \em real relational operator contants to * use. Don't mind that it's not an enum. See also: \ref inSwitch */ //@{ diff --git a/zypp/ResObject.cc b/zypp/ResObject.cc index 8970a45..eea62c9 100644 --- a/zypp/ResObject.cc +++ b/zypp/ResObject.cc @@ -43,10 +43,10 @@ namespace zypp // /////////////////////////////////////////////////////////////////// - string ResObject::summary() const + Label ResObject::summary() const { return pimpl().summary(); } - text ResObject::description() const + Text ResObject::description() const { return pimpl().description(); } ///////////////////////////////////////////////////////////////// diff --git a/zypp/ResObject.h b/zypp/ResObject.h index 6c7face..7d81b71 100644 --- a/zypp/ResObject.h +++ b/zypp/ResObject.h @@ -36,9 +36,9 @@ namespace zypp public: /** */ - line summary() const; + Label summary() const; /** */ - text description() const; + Text description() const; protected: /** Ctor */ diff --git a/zypp/base/PtrTypes.h b/zypp/base/PtrTypes.h index 48b3819..fdcc142 100644 --- a/zypp/base/PtrTypes.h +++ b/zypp/base/PtrTypes.h @@ -13,6 +13,8 @@ #ifndef ZYPP_BASE_PTRTYPES_H #define ZYPP_BASE_PTRTYPES_H +#include + #include #include #include @@ -101,6 +103,21 @@ namespace zypp _Ptr _dptr; }; + + /** \relates ImplPtr Stream output. + * + * Print the \r _D object the ImplPtr refers, or \c "NULL" + * if the pointer is \c NULL. + */ + template + inline std::ostream & + operator<<( std::ostream & str, const ImplPtr<_D, _Ptr> & obj ) + { + if ( obj.get() ) + return str << *obj.get(); + return str << std::string("NULL"); + } + /////////////////////////////////////////////////////////////////// /** Wrapper for \c const correct access via pointer. * @@ -133,6 +150,7 @@ namespace zypp _P * _dptr; }; + ///////////////////////////////////////////////////////////////// /*@}*/ diff --git a/zypp/detail/ResObjectImplIf.h b/zypp/detail/ResObjectImplIf.h index 1dbed50..40f63f4 100644 --- a/zypp/detail/ResObjectImplIf.h +++ b/zypp/detail/ResObjectImplIf.h @@ -17,15 +17,14 @@ #include "zypp/detail/ResObjectFactory.h" +#include "zypp/NeedAType.h" // volatile include propagating type drafts + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// class Resolvable; - typedef std::string line; - typedef std::list text; - /////////////////////////////////////////////////////////////////// namespace detail { ///////////////////////////////////////////////////////////////// @@ -52,11 +51,11 @@ namespace zypp Resolvable *const self() { return _backRef; } /** */ - virtual line summary() const - { return line(); } + virtual Label summary() const + { return Label(); } /** */ - virtual text description() const - { return text(); } + virtual Text description() const + { return Text(); } public: /** Ctor */ -- 2.7.4