27 using parser::ParseException;
35 const HistoryActionID HistoryActionID::NONE (HistoryActionID::NONE_e);
38 const HistoryActionID HistoryActionID::REPO_ADD (HistoryActionID::REPO_ADD_e);
39 const HistoryActionID HistoryActionID::REPO_REMOVE (HistoryActionID::REPO_REMOVE_e);
40 const HistoryActionID HistoryActionID::REPO_CHANGE_ALIAS (HistoryActionID::REPO_CHANGE_ALIAS_e);
41 const HistoryActionID HistoryActionID::REPO_CHANGE_URL (HistoryActionID::REPO_CHANGE_URL_e);
43 HistoryActionID::HistoryActionID(
const std::string & strval_r)
44 : _id(parse(strval_r))
49 typedef std::map<std::string,ID> MapType;
60 _table[
"NONE"] = _table[
"none"] =
NONE_e;
63 MapType::const_iterator it = _table.find( strval_r );
64 if ( it != _table.end() )
67 WAR <<
"Unknown history action ID '" + strval_r +
"'" << endl;
74 typedef std::pair<std::string,std::string> PairType;
75 typedef std::map<ID, PairType> MapType;
80 _table[
INSTALL_e] = PairType(
"install" ,
"install" );
81 _table[
REMOVE_e] = PairType(
"remove" ,
"remove " );
82 _table[
REPO_ADD_e] = PairType(
"radd" ,
"radd " );
86 _table[
NONE_e] = PairType(
"NONE" ,
"NONE " );
89 return( pad ? _table[
_id].second : _table[
_id].first );
93 {
return str <<
id.asString(); }
137 if ( fields_r.size() < expect_r )
139 ZYPP_THROW( ParseException(
str::form(
"Bad number of fields. Got %zd, expected at least %zd.",
147 catch (
const std::exception & excpt )
167 : _pimpl( new
Impl( fields_r, expect_r ) )
171 : _pimpl( new
Impl( fields_r, expectedId_r, expect_r ) )
179 if ( fields_r.size() >= 2 )
184 #define OUTS(E,T) case HistoryActionID::E: return Ptr( new T( fields_r ) ); break;
215 static const std::string _empty;
299 #if defined(WITH_DEPRECATED_HISTORYITEM_API)
306 HistoryItem::HistoryItem(FieldVector & fields)
308 if (fields.size() <= 2)
310 str::form(
"Bad number of fields. Got %zd, expected more than %d.",
317 void HistoryItem::dumpTo(ostream & str)
const
322 ostream &
operator<<(ostream & str,
const HistoryItem & obj)
335 HistoryItemInstall::HistoryItemInstall(FieldVector & fields)
336 : HistoryItem(fields)
338 if (fields.size() < 8)
340 str::form(
"Bad number of fields. Got %zu, expected %u.",
344 edition = Edition(fields[3]);
345 arch = Arch(fields[4]);
347 repoalias = fields[6];
351 void HistoryItemInstall::dumpTo(ostream & str)
const
353 HistoryItem::dumpTo(str);
363 ostream &
operator<<(ostream & str,
const HistoryItemInstall & obj)
376 HistoryItemRemove::HistoryItemRemove(FieldVector & fields)
377 : HistoryItem(fields)
379 if (fields.size() < 6)
381 str::form(
"Bad number of fields. Got %zu, expected %u.",
385 edition = Edition(fields[3]);
386 arch = Arch(fields[4]);
390 void HistoryItemRemove::dumpTo(ostream & str)
const
392 HistoryItem::dumpTo(str);
400 ostream &
operator<<(ostream & str,
const HistoryItemRemove & obj)
413 HistoryItemRepoAdd::HistoryItemRepoAdd(FieldVector & fields)
414 : HistoryItem(fields)
416 if (fields.size() < 4)
418 str::form(
"Bad number of fields. Got %zu, expected %u.",
422 url = Url(fields[3]);
425 void HistoryItemRepoAdd::dumpTo(ostream & str)
const
427 HistoryItem::dumpTo(str);
433 ostream &
operator<<(ostream & str,
const HistoryItemRepoAdd & obj)
446 HistoryItemRepoRemove::HistoryItemRepoRemove(FieldVector & fields)
447 : HistoryItem(fields)
449 if (fields.size() < 3)
451 str::form(
"Bad number of fields. Got %zu, expected %u.",
457 void HistoryItemRepoRemove::dumpTo(ostream & str)
const
459 HistoryItem::dumpTo(str);
463 ostream &
operator<<(ostream & str,
const HistoryItemRepoRemove & obj)
476 HistoryItemRepoAliasChange::HistoryItemRepoAliasChange(FieldVector & fields)
477 : HistoryItem(fields)
479 if (fields.size() < 4)
481 str::form(
"Bad number of fields. Got %zu, expected %u.",
484 oldalias = fields[2];
485 newalias = fields[3];
488 void HistoryItemRepoAliasChange::dumpTo(ostream & str)
const
490 HistoryItem::dumpTo(str);
491 str <<
"|" << oldalias <<
"|" << newalias;
494 ostream &
operator<<(ostream & str,
const HistoryItemRepoAliasChange & obj)
507 HistoryItemRepoUrlChange::HistoryItemRepoUrlChange(FieldVector & fields)
508 : HistoryItem(fields)
510 if (fields.size() < 4)
512 str::form(
"Bad number of fields. Got %zu, expected %u.",
516 newurl = Url(fields[3]);
519 void HistoryItemRepoUrlChange::dumpTo(ostream & str)
const
521 HistoryItem::dumpTo(str);
522 str <<
"|" << alias <<
"|" << newurl;
525 ostream &
operator<<(ostream & str,
const HistoryItemRepoUrlChange & obj)
530 #endif // WITH_DEPRECATED_HISTORYITEM_API