Imported Upstream version 17.23.0
[platform/upstream/libzypp.git] / zypp / HistoryLogData.cc
index 3c73af5..0307a5d 100644 (file)
@@ -39,6 +39,8 @@ namespace zypp
   const HistoryActionID HistoryActionID::REPO_REMOVE           (HistoryActionID::REPO_REMOVE_e);
   const HistoryActionID HistoryActionID::REPO_CHANGE_ALIAS     (HistoryActionID::REPO_CHANGE_ALIAS_e);
   const HistoryActionID HistoryActionID::REPO_CHANGE_URL       (HistoryActionID::REPO_CHANGE_URL_e);
+  const HistoryActionID HistoryActionID::STAMP_COMMAND         (HistoryActionID::STAMP_COMMAND_e);
+  const HistoryActionID HistoryActionID::PATCH_STATE_CHANGE     (HistoryActionID::PATCH_STATE_CHANGE_e);
 
   HistoryActionID::HistoryActionID(const std::string & strval_r)
     : _id(parse(strval_r))
@@ -57,6 +59,8 @@ namespace zypp
       _table["rremove"]        = REPO_REMOVE_e;
       _table["ralias"] = REPO_CHANGE_ALIAS_e;
       _table["rurl"]   = REPO_CHANGE_URL_e;
+      _table["command"]        = STAMP_COMMAND_e;
+      _table["patch"]  = PATCH_STATE_CHANGE_e;
       _table["NONE"]   = _table["none"] = NONE_e;
     }
 
@@ -83,6 +87,8 @@ namespace zypp
       _table[REPO_REMOVE_e]       = PairType( "rremove"        , "rremove" );
       _table[REPO_CHANGE_ALIAS_e] = PairType( "ralias" , "ralias " );
       _table[REPO_CHANGE_URL_e]   = PairType( "rurl"   , "rurl   " );
+      _table[STAMP_COMMAND_e]     = PairType( "command"        , "command" );
+      _table[PATCH_STATE_CHANGE_e]= PairType( "patch"   , "patch  " );
       _table[NONE_e]              = PairType( "NONE"   , "NONE   " );
     }
 
@@ -188,6 +194,8 @@ namespace zypp
        OUTS( REPO_REMOVE_e,            HistoryLogDataRepoRemove );
        OUTS( REPO_CHANGE_ALIAS_e,      HistoryLogDataRepoAliasChange );
        OUTS( REPO_CHANGE_URL_e,        HistoryLogDataRepoUrlChange );
+       OUTS( STAMP_COMMAND_e,          HistoryLogDataStampCommand );
+        OUTS( PATCH_STATE_CHANGE_e,     HistoryLogPatchStateChange );
 #undef OUTS
        // intentionally no default:
        case HistoryActionID::NONE_e:
@@ -244,6 +252,22 @@ namespace zypp
     CheckSum   HistoryLogDataInstall::checksum()       const { return optionalAt( CHEKSUM_INDEX ); }
     std::string        HistoryLogDataInstall::userdata()       const { return optionalAt( USERDATA_INDEX ); }
 
+    ///////////////////////////////////////////////////////////////////
+    // class HistoryLogPatchStateChange
+    ///////////////////////////////////////////////////////////////////
+    HistoryLogPatchStateChange::HistoryLogPatchStateChange( FieldVector & fields_r )
+      : HistoryLogData( fields_r )
+    {}
+    std::string        HistoryLogPatchStateChange::name()      const { return optionalAt( NAME_INDEX ); }
+    Edition    HistoryLogPatchStateChange::edition()   const { return Edition( optionalAt( EDITION_INDEX ) ); }
+    Arch       HistoryLogPatchStateChange::arch()      const { return Arch( optionalAt( ARCH_INDEX ) ); }
+    std::string        HistoryLogPatchStateChange::repoAlias() const { return optionalAt( REPOALIAS_INDEX ); }
+    Patch::SeverityFlag HistoryLogPatchStateChange::severity() const { return Patch::severityFlag( optionalAt( SEVERITY_INDEX ) ); }
+    Patch::Category HistoryLogPatchStateChange::category() const { return Patch::categoryEnum( optionalAt( CATEGORY_INDEX ) ); }
+    string HistoryLogPatchStateChange::oldstate() const { return optionalAt( OLDSTATE_INDEX ); }
+    string HistoryLogPatchStateChange::newstate() const { return optionalAt( NEWSTATE_INDEX ); }
+    std::string        HistoryLogPatchStateChange::userdata()  const { return optionalAt( USERDATA_INDEX ); }
+
   ///////////////////////////////////////////////////////////////////
   //   class HistoryLogDataRemove
   ///////////////////////////////////////////////////////////////////
@@ -295,239 +319,15 @@ namespace zypp
     Url                HistoryLogDataRepoUrlChange::newUrl()   const { return optionalAt( NEWURL_INDEX ); }
     std::string        HistoryLogDataRepoUrlChange::userdata() const { return optionalAt( USERDATA_INDEX ); }
 
-
-#if defined(WITH_DEPRECATED_HISTORYITEM_API)
   ///////////////////////////////////////////////////////////////////
-  /// \class HistoryItem
-  /// \deprecated Old unextensible \ref zypp::parser::HistoryLogReader data class.
-  /// They grant direct access to data members, so can not be extended
-  /// without losing binary compatibility.
+  //   class HistoryLogDataStampCommand
   ///////////////////////////////////////////////////////////////////
-  HistoryItem::HistoryItem(FieldVector & fields)
-  {
-    if (fields.size() <= 2)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zd, expected more than %d.",
-          fields.size(), 2)));
-
-    date = Date(fields[0], HISTORY_LOG_DATE_FORMAT);
-    action = HistoryActionID(str::trim(fields[1]));
-  }
-
-  void HistoryItem::dumpTo(ostream & str) const
-  {
-    str << date.form(HISTORY_LOG_DATE_FORMAT) << "|" << action.asString();
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItem & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemInstall (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemInstall::HistoryItemInstall(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 8)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 8)));
-
-    name      = fields[2];
-    edition   = Edition(fields[3]);
-    arch      = Arch(fields[4]);
-    reqby     = fields[5];
-    repoalias = fields[6];
-    checksum  = CheckSum::sha(fields[7]);
-  }
-
-  void HistoryItemInstall::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|"
-      << name << "|"
-      << edition << "|"
-      << arch << "|"
-      << reqby << "|"
-      << repoalias << "|"
-      << checksum;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemInstall & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRemove (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRemove::HistoryItemRemove(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 6)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 6)));
-
-    name      = fields[2];
-    edition   = Edition(fields[3]);
-    arch      = Arch(fields[4]);
-    reqby     = fields[5];
-  }
-
-  void HistoryItemRemove::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|"
-      << name << "|"
-      << edition << "|"
-      << arch << "|"
-      << reqby;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRemove & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoAdd (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRepoAdd::HistoryItemRepoAdd(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 4)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 4)));
-
-    alias = fields[2];
-    url = Url(fields[3]);
-  }
-
-  void HistoryItemRepoAdd::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|"
-      << alias << "|"
-      << url;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRepoAdd & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoRemove (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRepoRemove::HistoryItemRepoRemove(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 3)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 3)));
-
-    alias = fields[2];
-  }
-
-  void HistoryItemRepoRemove::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|" << alias;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRepoRemove & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoAliasChange (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRepoAliasChange::HistoryItemRepoAliasChange(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 4)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 4)));
-
-    oldalias = fields[2];
-    newalias = fields[3];
-  }
-
-  void HistoryItemRepoAliasChange::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|" << oldalias << "|" << newalias;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRepoAliasChange & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-
-
-  /////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME: HistoryItemRepoUrlChange (deprecated!)
-  //
-  /////////////////////////////////////////////////////////////////////
-
-  HistoryItemRepoUrlChange::HistoryItemRepoUrlChange(FieldVector & fields)
-    : HistoryItem(fields)
-  {
-    if (fields.size() < 4)
-      ZYPP_THROW(ParseException(
-        str::form("Bad number of fields. Got %zu, expected %u.",
-          fields.size(), 4)));
-
-    alias = fields[2];
-    newurl = Url(fields[3]);
-  }
-
-  void HistoryItemRepoUrlChange::dumpTo(ostream & str) const
-  {
-    HistoryItem::dumpTo(str);
-    str << "|" << alias << "|" << newurl;
-  }
-
-  ostream & operator<<(ostream & str, const HistoryItemRepoUrlChange & obj)
-  {
-    obj.dumpTo(str);
-    return str;
-  }
-#endif // WITH_DEPRECATED_HISTORYITEM_API
+    HistoryLogDataStampCommand::HistoryLogDataStampCommand( FieldVector & fields_r )
+    : HistoryLogData( fields_r )
+    {}
+    std::string        HistoryLogDataStampCommand::executedBy()        const { return optionalAt( USER_INDEX ); }
+    std::string HistoryLogDataStampCommand::command()          const { return optionalAt( COMMAND_INDEX ); }
+    std::string        HistoryLogDataStampCommand::userdata()          const { return optionalAt( USERDATA_INDEX ); }
 
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////