[gnome-commander] XML config: write SearchConfig data to XML::xstream



commit e944fc15ccfe6218dc9a62d1fdf077c74b63871f
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Wed Sep 2 18:59:33 2009 +0200

    XML config: write SearchConfig data to XML::xstream

 src/gnome-cmd-data.cc |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 src/gnome-cmd-data.h  |    4 ++++
 2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 81b47c6..8d8366e 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -1756,6 +1756,12 @@ void GnomeCmdData::save()
         xml << XML::tag("GnomeCommander") << XML::attr("version") << VERSION;
 
         xml << advrename_defaults;
+        xml << search_defaults;
+
+        xml << XML::tag("Selections");
+        for (vector<Selection>::iterator i=selections.begin(); i!=selections.end(); ++i)
+            xml << *i;
+        xml << XML::endtag("Selections");
 
         xml << XML::endtag("GnomeCommander");
 
@@ -2083,3 +2089,44 @@ XML::xstream &operator << (XML::xstream &xml, GnomeCmdData::AdvrenameConfig &cfg
 
     return xml;
 }
+
+
+XML::xstream &operator << (XML::xstream &xml, GnomeCmdData::Selection &cfg)
+{
+    xml << XML::tag("Profile") << XML::attr("name") << XML::escape(cfg.name);
+
+        xml << XML::tag("Pattern") << XML::attr("syntax") << (cfg.syntax==Filter::TYPE_REGEX ? "regex" : "shell")
+                                   << XML::attr("match-case") << 0 << XML::chardata() << XML::escape(cfg.filename_pattern) << XML::endtag();
+        xml << XML::tag("Path") << XML::attr("recursive") << cfg.recursive << XML::endtag();
+        xml << XML::tag("Text") << XML::attr("match-case") << cfg.match_case << XML::chardata() << XML::escape(cfg.text_pattern) << XML::endtag();
+
+    xml << XML::endtag();
+
+    return xml;
+}
+
+
+XML::xstream &operator << (XML::xstream &xml, GnomeCmdData::SearchConfig &cfg)
+{
+    xml << XML::tag("SearchTool");
+
+        xml << XML::tag("WindowSize") << XML::attr("width") << cfg.width << XML::attr("height") << cfg.height << XML::endtag();
+        xml << cfg.default_profile;
+
+        xml << XML::tag("History");
+
+        for (GList *i=cfg.name_patterns.ents; i; i=i->next)
+            xml << XML::tag("Pattern") << XML::chardata() << XML::escape((const gchar *) i->data) << XML::endtag();
+
+        for (GList *i=cfg.directories.ents; i; i=i->next)
+            xml << XML::tag("Path") << XML::chardata() << XML::escape((const gchar *) i->data) << XML::endtag();
+
+        for (GList *i=cfg.content_patterns.ents; i; i=i->next)
+            xml << XML::tag("Text") << XML::chardata() << XML::escape((const gchar *) i->data) << XML::endtag();
+
+        xml << XML::endtag();
+
+    xml << XML::endtag();
+
+    return xml;
+}
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 5157b03..4165579 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -65,6 +65,8 @@ struct GnomeCmdData
         Selection(): syntax(Filter::TYPE_REGEX),
                      recursive(TRUE),
                      match_case(FALSE)                          {}
+
+        friend XML::xstream &operator << (XML::xstream &xml, Selection &cfg);
     };
 
     struct SearchConfig
@@ -81,6 +83,8 @@ struct GnomeCmdData
                         name_patterns(SEARCH_HISTORY_SIZE),
                         directories(SEARCH_HISTORY_SIZE),
                         content_patterns(SEARCH_HISTORY_SIZE)   {}
+
+        friend XML::xstream &operator << (XML::xstream &xml, SearchConfig &cfg);
     };
 
     struct AdvrenameConfig



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]