1
/*---------------------------------------------------------------------\
3
| |__ / \ / / . \ . \ |
8
\---------------------------------------------------------------------*/
9
/** \file zypp/repo/RepoInfoBase.cc
14
#include "zypp/ZConfig.h"
15
#include "zypp/repo/RepoVariables.h"
17
#include "zypp/repo/RepoInfoBase.h"
18
#include "zypp/repo/RepoInfoBaseImpl.h"
22
///////////////////////////////////////////////////////////////////
24
{ /////////////////////////////////////////////////////////////////
25
///////////////////////////////////////////////////////////////////
27
{ /////////////////////////////////////////////////////////////////
29
///////////////////////////////////////////////////////////////////
31
// CLASS NAME : RepoInfoBase::Impl
33
///////////////////////////////////////////////////////////////////
35
/** \relates RepoInfo::Impl Stream output */
36
inline std::ostream & operator<<( std::ostream & str, const RepoInfoBase::Impl & obj )
38
return str << "RepoInfo::Impl";
41
void RepoInfoBase::Impl::setAlias(const string & alias_)
44
// replace slashes with underscores
47
std::string escaped_alias = alias_;
48
size_t pos = escaped_alias.find(fnd);
49
while (pos != string::npos)
51
escaped_alias.replace(pos, fnd.length(), rep);
52
pos = escaped_alias.find(fnd, pos+rep.length());
54
this->escaped_alias = escaped_alias;
57
///////////////////////////////////////////////////////////////////
59
// CLASS NAME : RepoInfoBase
61
///////////////////////////////////////////////////////////////////
63
///////////////////////////////////////////////////////////////////
65
// METHOD NAME : RepoInfoBase::RepoInfoBase
68
RepoInfoBase::RepoInfoBase()
69
: _pimpl( new Impl() )
72
///////////////////////////////////////////////////////////////////
74
// METHOD NAME : RepoInfoBase::RepoInfoBase
77
RepoInfoBase::RepoInfoBase(const string & alias)
78
: _pimpl( new Impl(alias) )
81
///////////////////////////////////////////////////////////////////
83
// METHOD NAME : RepoInfoBase::~RepoInfoBase
86
RepoInfoBase::~RepoInfoBase()
89
void RepoInfoBase::setEnabled( bool enabled )
91
_pimpl->enabled = enabled;
94
void RepoInfoBase::setAutorefresh( bool autorefresh )
96
_pimpl->autorefresh = autorefresh;
99
void RepoInfoBase::setAlias( const std::string &alias )
101
_pimpl->setAlias(alias);
104
void RepoInfoBase::setName( const std::string &name )
109
void RepoInfoBase::setFilepath( const Pathname &filepath )
111
_pimpl->filepath = filepath;
114
// true by default (if not set by setEnabled())
115
bool RepoInfoBase::enabled() const
116
{ return indeterminate(_pimpl->enabled) ? true : (bool) _pimpl->enabled; }
118
// false by default (if not set by setAutorefresh())
119
bool RepoInfoBase::autorefresh() const
120
{ return indeterminate(_pimpl->autorefresh) ? false : (bool) _pimpl->autorefresh; }
122
std::string RepoInfoBase::alias() const
123
{ return _pimpl->alias; }
125
std::string RepoInfoBase::escaped_alias() const
126
{ return _pimpl->escaped_alias; }
128
std::string RepoInfoBase::name() const
130
if ( _pimpl->name.empty() )
135
repo::RepoVariablesStringReplacer replacer;
136
return replacer(_pimpl->name);
139
std::string RepoInfoBase::label() const
141
if ( ZConfig::instance().repoLabelIsAlias() )
146
Pathname RepoInfoBase::filepath() const
147
{ return _pimpl->filepath; }
150
std::ostream & RepoInfoBase::dumpOn( std::ostream & str ) const
152
str << "--------------------------------------" << std::endl;
153
str << "- alias : " << alias() << std::endl;
154
str << "- name : " << name() << std::endl;
155
str << "- enabled : " << enabled() << std::endl;
156
str << "- autorefresh : " << autorefresh() << std::endl;
161
std::ostream & RepoInfoBase::dumpAsIniOn( std::ostream & str ) const
163
// we save the original data without variable replacement
164
str << "[" << alias() << "]" << endl;
165
str << "name=" << name() << endl;
166
str << "enabled=" << (enabled() ? "1" : "0") << endl;
167
str << "autorefresh=" << (autorefresh() ? "1" : "0") << endl;
172
std::ostream & RepoInfoBase::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
174
return str << "<!-- there's no XML representation of RepoInfoBase -->" << endl;
177
std::ostream & operator<<( std::ostream & str, const RepoInfoBase & obj )
179
return obj.dumpOn(str);
181
///////////////////////////////////////////////////////////////////
183
/////////////////////////////////////////////////////////////////
185
///////////////////////////////////////////////////////////////////
186
/////////////////////////////////////////////////////////////////
188
///////////////////////////////////////////////////////////////////