aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-08 16:02:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-08 16:02:54 +0100
commit8718a44f82a3aaf6dd1b445545ce6568e24bd5df (patch)
tree642a733a7aaa70d3788be0cd0f7b47fb106b52c5
parenteb258b636721206a11f6783612c78ac026fc3d2f (diff)
downloadpaludis-8718a44f82a3aaf6dd1b445545ce6568e24bd5df.tar.gz
paludis-8718a44f82a3aaf6dd1b445545ce6568e24bd5df.tar.xz
Refactor to make later changes easier
-rw-r--r--paludis/dep_spec.cc81
-rw-r--r--paludis/dep_spec.hh52
2 files changed, 88 insertions, 45 deletions
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index 7b221f3..1943e58 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -183,14 +183,7 @@ ConditionalDepSpec::_as_string() const
return _imp->data->as_string();
}
-std::string
-StringDepSpec::text() const
-{
- return _str;
-}
-
NamedSetDepSpec::NamedSetDepSpec(const SetName & n) :
- StringDepSpec(stringify(n)),
_name(n)
{
}
@@ -201,6 +194,12 @@ NamedSetDepSpec::name() const
return _name;
}
+const std::string
+NamedSetDepSpec::text() const
+{
+ return stringify(_name);
+}
+
std::shared_ptr<DepSpec>
NamedSetDepSpec::clone() const
{
@@ -210,18 +209,24 @@ NamedSetDepSpec::clone() const
}
BlockDepSpec::BlockDepSpec(const std::string & s, const PackageDepSpec & p) :
- StringDepSpec(s),
+ _text(s),
_spec(p)
{
}
BlockDepSpec::BlockDepSpec(const BlockDepSpec & other) :
- StringDepSpec(other.text()),
+ _text(other._text),
_spec(other._spec)
{
set_annotations(other.maybe_annotations());
}
+const std::string
+BlockDepSpec::text() const
+{
+ return _text;
+}
+
std::ostream &
paludis::operator<< (std::ostream & s, const PlainTextDepSpec & a)
{
@@ -308,18 +313,8 @@ PackageDepSpecError::PackageDepSpecError(const std::string & msg) throw () :
{
}
-StringDepSpec::StringDepSpec(const std::string & s) :
- _str(s)
-{
-}
-
-StringDepSpec::~StringDepSpec()
-{
-}
-
-
PlainTextDepSpec::PlainTextDepSpec(const std::string & s) :
- StringDepSpec(s)
+ _text(s)
{
}
@@ -331,8 +326,14 @@ PlainTextDepSpec::clone() const
return result;
}
+const std::string
+PlainTextDepSpec::text() const
+{
+ return _text;
+}
+
PlainTextLabelDepSpec::PlainTextLabelDepSpec(const std::string & s) :
- StringDepSpec(s)
+ _text(s)
{
}
@@ -349,13 +350,19 @@ PlainTextLabelDepSpec::clone() const
}
const std::string
+PlainTextLabelDepSpec::text() const
+{
+ return _text;
+}
+
+const std::string
PlainTextLabelDepSpec::label() const
{
return text().substr(0, text().length() - 1);
}
LicenseDepSpec::LicenseDepSpec(const std::string & s) :
- StringDepSpec(s)
+ _text(s)
{
}
@@ -367,8 +374,14 @@ LicenseDepSpec::clone() const
return result;
}
+const std::string
+LicenseDepSpec::text() const
+{
+ return _text;
+}
+
SimpleURIDepSpec::SimpleURIDepSpec(const std::string & s) :
- StringDepSpec(s)
+ _text(s)
{
}
@@ -380,6 +393,12 @@ SimpleURIDepSpec::clone() const
return result;
}
+const std::string
+SimpleURIDepSpec::text() const
+{
+ return _text;
+}
+
const PackageDepSpec
BlockDepSpec::blocking() const
{
@@ -395,7 +414,7 @@ BlockDepSpec::clone() const
}
FetchableURIDepSpec::FetchableURIDepSpec(const std::string & s) :
- StringDepSpec(s)
+ _text(s)
{
}
@@ -442,6 +461,12 @@ FetchableURIDepSpec::clone() const
return result;
}
+const std::string
+FetchableURIDepSpec::text() const
+{
+ return _text;
+}
+
namespace paludis
{
template <typename T_>
@@ -522,7 +547,6 @@ namespace paludis
PackageDepSpec::PackageDepSpec(const std::shared_ptr<const PackageDepSpecData> & d) :
Cloneable<DepSpec>(),
- StringDepSpec(d->as_string()),
_imp(d)
{
}
@@ -533,13 +557,18 @@ PackageDepSpec::~PackageDepSpec()
PackageDepSpec::PackageDepSpec(const PackageDepSpec & d) :
Cloneable<DepSpec>(d),
- StringDepSpec(d._imp->data->as_string()),
CloneUsingThis<DepSpec, PackageDepSpec>(d),
_imp(d._imp->data)
{
set_annotations(d.maybe_annotations());
}
+const std::string
+PackageDepSpec::text() const
+{
+ return _imp->data->as_string();
+}
+
const std::shared_ptr<const NameRequirement>
PackageDepSpec::package_name_requirement() const
{
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index 46672f9..3e802c7 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -236,29 +236,11 @@ namespace paludis
class PALUDIS_VISIBLE StringDepSpec :
public DepSpec
{
- private:
- std::string _str;
-
- protected:
- ///\name Basic operations
- ///\{
-
- StringDepSpec(const std::string &);
-
- ~StringDepSpec();
-
- ///\}
-
- /**
- * Change our text.
- */
- void set_text(const std::string &);
-
public:
/**
* Fetch our text.
*/
- std::string text() const;
+ virtual const std::string text() const = 0;
};
/**
@@ -312,6 +294,8 @@ namespace paludis
///\}
+ virtual const std::string text() const;
+
/**
* Fetch the single NameRequirement, if we have one, or
* a null pointer otherwise.
@@ -428,6 +412,9 @@ namespace paludis
class PALUDIS_VISIBLE PlainTextDepSpec :
public StringDepSpec
{
+ private:
+ std::string _text;
+
public:
///\name Basic operations
///\{
@@ -436,6 +423,8 @@ namespace paludis
///\}
+ virtual const std::string text() const;
+
virtual std::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -459,6 +448,8 @@ namespace paludis
///\}
+ virtual const std::string text() const;
+
/// Fetch the name of our set.
const SetName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -475,6 +466,9 @@ namespace paludis
class PALUDIS_VISIBLE LicenseDepSpec :
public StringDepSpec
{
+ private:
+ std::string _text;
+
public:
///\name Basic operations
///\{
@@ -483,6 +477,8 @@ namespace paludis
///\}
+ virtual const std::string text() const;
+
virtual std::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -500,6 +496,9 @@ namespace paludis
class PALUDIS_VISIBLE FetchableURIDepSpec :
public StringDepSpec
{
+ private:
+ std::string _text;
+
public:
///\name Basic operations
///\{
@@ -508,6 +507,8 @@ namespace paludis
///\}
+ virtual const std::string text() const;
+
/**
* The original URL (that is, the text to the left of the arrow, if present,
* or the entire text otherwise).
@@ -541,6 +542,9 @@ namespace paludis
class PALUDIS_VISIBLE SimpleURIDepSpec :
public StringDepSpec
{
+ private:
+ std::string _text;
+
public:
///\name Basic operations
///\{
@@ -549,6 +553,8 @@ namespace paludis
///\}
+ virtual const std::string text() const;
+
virtual std::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -583,6 +589,7 @@ namespace paludis
public StringDepSpec
{
private:
+ std::string _text;
PackageDepSpec _spec;
public:
@@ -595,6 +602,8 @@ namespace paludis
///\}
+ virtual const std::string text() const;
+
/**
* Fetch the spec we're blocking.
*
@@ -651,6 +660,9 @@ namespace paludis
class PALUDIS_VISIBLE PlainTextLabelDepSpec :
public StringDepSpec
{
+ private:
+ std::string _text;
+
public:
///\name Basic operations
///\{
@@ -660,6 +672,8 @@ namespace paludis
///\}
+ virtual const std::string text() const;
+
virtual std::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
const std::string label() const PALUDIS_ATTRIBUTE((warn_unused_result));