Author: aschnell
Date: Tue Feb 3 18:31:48 2009
New Revision: 55218
URL: http://svn.opensuse.org/viewcvs/yast?rev=55218&view=rev
Log:
- some restructuring affecting storage interface
Added:
trunk/storage/libstorage/src/Graph.h
trunk/storage/libstorage/src/HumanString.cc
trunk/storage/libstorage/src/HumanString.h
Modified:
trunk/storage/POTFILES
trunk/storage/libstorage/bindings/ycp/LibStorage.i
trunk/storage/libstorage/examples/SaveGraph.cc
trunk/storage/libstorage/src/AppUtil.cc
trunk/storage/libstorage/src/AppUtil.h
trunk/storage/libstorage/src/Graph.cc
trunk/storage/libstorage/src/Makefile.am
trunk/storage/libstorage/src/Storage.cc
trunk/storage/libstorage/src/Storage.h
trunk/storage/libstorage/src/StorageInterface.h
trunk/storage/libstorage/src/Volume.cc
trunk/storage/libstorage/testsuite/humanstring1.cc
trunk/storage/libstorage/testsuite/humanstring2.cc
trunk/storage/storage/src/modules/Storage.ycp
Modified: trunk/storage/POTFILES
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/POTFILES?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/POTFILES (original)
+++ trunk/storage/POTFILES Tue Feb 3 18:31:48 2009
@@ -6,6 +6,7 @@
libstorage/src/DmCo.cc
libstorage/src/EtcFstab.cc
libstorage/src/EtcRaidtab.cc
+libstorage/src/HumanString.cc
libstorage/src/Loop.cc
libstorage/src/LoopCo.cc
libstorage/src/LvmLv.cc
Modified: trunk/storage/libstorage/bindings/ycp/LibStorage.i
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/bindings/ycp/LibStorage.i?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/bindings/ycp/LibStorage.i (original)
+++ trunk/storage/libstorage/bindings/ycp/LibStorage.i Tue Feb 3 18:31:48 2009
@@ -8,6 +8,8 @@
%{
#include "../../src/StorageInterface.h"
+#include "../../src/HumanString.h"
+#include "../../src/Graph.h"
%}
using namespace std;
@@ -38,4 +40,6 @@
specialize_sequence(storage::CommitInfo, TO_PACK, FROM_PACK, CHECK)
%include "../../src/StorageInterface.h"
+%include "../../src/HumanString.h"
+%include "../../src/Graph.h"
Modified: trunk/storage/libstorage/examples/SaveGraph.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/examples/SaveGraph.cc?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/examples/SaveGraph.cc (original)
+++ trunk/storage/libstorage/examples/SaveGraph.cc Tue Feb 3 18:31:48 2009
@@ -2,6 +2,7 @@
#include
#include
+#include
using namespace storage;
@@ -9,9 +10,9 @@
main (int argc, char** argv)
{
initDefaultLogger();
- StorageInterface* s = createStorageInterface (true, false, true);
+ StorageInterface* s = createStorageInterface(true, false, true);
- s->saveGraph("storage.dot");
+ saveGraph(s, "storage.dot");
exit(EXIT_SUCCESS);
}
Modified: trunk/storage/libstorage/src/AppUtil.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.cc?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AppUtil.cc (original)
+++ trunk/storage/libstorage/src/AppUtil.cc Tue Feb 3 18:31:48 2009
@@ -10,7 +10,6 @@
#include
#include
-#include <locale>
#include
#include
@@ -531,139 +530,6 @@
}
-int
-numSuffixes()
-{
- return 6;
-}
-
-
-string
-getSuffix(int i, bool classic, bool sloppy = false)
-{
- switch (i)
- {
- case 0:
- if (sloppy)
- return "";
- else
- /* Byte abbreviated */
- return classic ? "B" : _("B");
-
- case 1:
- if (sloppy)
- /* Kilo abbreviated */
- return classic ? "k" : _("k");
- else
- /* KiloByte abbreviated */
- return classic ? "kB" : _("kB");
-
- case 2:
- if (sloppy)
- /* Mega abbreviated */
- return classic ? "M" : _("M");
- else
- /* MegaByte abbreviated */
- return classic ? "MB" : _("MB");
-
- case 3:
- if (sloppy)
- /* Giga abbreviated */
- return classic ? "G" : _("G");
- else
- /* GigaByte abbreviated */
- return classic ? "GB" : _("GB");
-
- case 4:
- if (sloppy)
- /* Tera abbreviated */
- return classic ? "T" : _("T");
- else
- /* TeraByte abbreviated */
- return classic ? "TB" : _("TB");
-
- case 5:
- if (sloppy)
- /* Peta abbreviated */
- return classic ? "P" : _("P");
- else
- /* PetaByte abbreviated */
- return classic ? "PB" : _("PB");
- }
-
- return string("error");
-}
-
-
-string
-byteToHumanString(unsigned long long size, bool classic, int precision, bool omit_zeroes)
-{
- const locale loc = classic ? locale::classic() : locale();
-
- double f = size;
- int i = 0;
-
- while (f >= 1024.0 && i + 1 < numSuffixes())
- {
- f /= 1024.0;
- i++;
- }
-
- if (omit_zeroes && (f == (unsigned long long)(f)))
- {
- precision = 0;
- }
-
- ostringstream s;
- s.imbue(loc);
- s.setf(ios::fixed);
- s.precision(precision);
-
- s << f << ' ' << getSuffix(i, classic);
-
- return s.str();
-}
-
-
-bool
-humanStringToByte(const string& str, bool classic, unsigned long long& size)
-{
- const locale loc = classic ? locale::classic() : locale();
-
- const string str_trimmed = boost::trim_copy(str, loc);
-
- double f = 1.0;
-
- for (int i = 0; i < numSuffixes(); i++)
- {
- for (int j = 0; j < (classic ? 1 : 2); j++)
- {
- string suffix = getSuffix(i, classic, j != 0);
- if (boost::iends_with(str_trimmed, suffix, loc))
- {
- string number = str_trimmed.substr(0, str_trimmed.size() - suffix.size());
-
- istringstream s(boost::trim_copy(number, loc));
- s.imbue(loc);
-
- double g;
- s >> g;
-
- if (!s.fail() && s.eof() && g >= 0.0)
- {
- size = g * f;
- return true;
- }
- }
- }
-
- f *= 1024.0;
- }
-
- return false;
-}
-
-
const string app_ws = " \t\n";
}
Modified: trunk/storage/libstorage/src/AppUtil.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.h?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AppUtil.h (original)
+++ trunk/storage/libstorage/src/AppUtil.h Tue Feb 3 18:31:48 2009
@@ -100,12 +100,6 @@
string sformat(const char* format, ...);
-string byteToHumanString(unsigned long long size, bool classic, int precision,
- bool omit_zeroes);
-
-bool humanStringToByte(const string& str, bool classic, unsigned long long& size);
-
-
inline const char* _(const char* msgid)
{
return dgettext("storage", msgid);
Modified: trunk/storage/libstorage/src/Graph.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Graph.cc?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Graph.cc (original)
+++ trunk/storage/libstorage/src/Graph.cc Tue Feb 3 18:31:48 2009
@@ -6,9 +6,10 @@
#include <string>
#include <fstream>
#include <array>
+#include
#include "config.h"
-#include "y2storage/Storage.h"
+#include "y2storage/Graph.h"
using namespace std;
@@ -66,151 +67,152 @@
s << " [" << edge.attributes << "]";
return s << ";";
}
-}
-
-
-int
-Storage::saveGraph(const string& filename)
-{
- list<Node> nodes;
- list<Edge> edges;
- deque<ContainerInfo> containers;
- getContainers(containers);
- for (deque<ContainerInfo>::iterator i1 = containers.begin();
- i1 != containers.end(); ++i1)
+ int
+ saveGraph(StorageInterface* s, const string& filename)
{
- switch (i1->type)
- {
- case DISK: {
-
- Node disk_node("device:" + i1->device, RANK_DISK, i1->device);
- nodes.push_back(disk_node);
+ list<Node> nodes;
+ list<Edge> edges;
- if (!i1->usedByDevice.empty())
- {
- edges.push_back(Edge(disk_node.id, "device:" + i1->usedByDevice));
- }
-
- deque<PartitionInfo> partitions;
- getPartitionInfo(i1->name, partitions);
- for (deque<PartitionInfo>::iterator i2 = partitions.begin();
- i2 != partitions.end(); ++i2)
- {
- if (i2->partitionType == EXTENDED)
- continue;
- Node partition_node("device:" + i2->v.device, RANK_PARTITION, i2->v.device);
- nodes.push_back(partition_node);
+ deque<ContainerInfo> containers;
+ s->getContainers(containers);
+ for (deque<ContainerInfo>::iterator i1 = containers.begin();
+ i1 != containers.end(); ++i1)
+ {
+ switch (i1->type)
+ {
+ case DISK: {
- edges.push_back(Edge(disk_node.id, partition_node.id));
+ Node disk_node("device:" + i1->device, RANK_DISK, i1->device);
+ nodes.push_back(disk_node);
- if (!i2->v.usedByDevice.empty())
+ if (!i1->usedByDevice.empty())
{
- edges.push_back(Edge(partition_node.id, "device:" + i2->v.usedByDevice, "color=green"));
+ edges.push_back(Edge(disk_node.id, "device:" + i1->usedByDevice));
}
- if (!i2->v.mount.empty())
+ deque<PartitionInfo> partitions;
+ s->getPartitionInfo(i1->name, partitions);
+ for (deque<PartitionInfo>::iterator i2 = partitions.begin();
+ i2 != partitions.end(); ++i2)
{
- Node mountpoint_node("mountpoint:" + i2->v.mount, RANK_MOUNTPOINT, i2->v.mount);
- nodes.push_back(mountpoint_node);
+ if (i2->partitionType == EXTENDED)
+ continue;
- edges.push_back(Edge(partition_node.id, mountpoint_node.id, "color=blue"));
- }
- }
+ Node partition_node("device:" + i2->v.device, RANK_PARTITION, i2->v.device);
+ nodes.push_back(partition_node);
+
+ edges.push_back(Edge(disk_node.id, partition_node.id));
- } break;
+ if (!i2->v.usedByDevice.empty())
+ {
+ edges.push_back(Edge(partition_node.id, "device:" + i2->v.usedByDevice, "color=green"));
+ }
+
+ if (!i2->v.mount.empty())
+ {
+ Node mountpoint_node("mountpoint:" + i2->v.mount, RANK_MOUNTPOINT, i2->v.mount);
+ nodes.push_back(mountpoint_node);
- case LVM: {
+ edges.push_back(Edge(partition_node.id, mountpoint_node.id, "color=blue"));
+ }
+ }
- Node vg_node("device:" + i1->device, RANK_LVMVG, i1->device);
- nodes.push_back(vg_node);
+ } break;
- deque<LvmLvInfo> lvs;
- getLvmLvInfo(i1->name, lvs);
- for (deque<LvmLvInfo>::iterator i2 = lvs.begin();
- i2 != lvs.end(); ++i2)
- {
- Node lv_node("device:" + i2->v.device, RANK_LVMLV, i2->v.device);
- nodes.push_back(lv_node);
+ case LVM: {
- edges.push_back(Edge(vg_node.id, lv_node.id));
+ Node vg_node("device:" + i1->device, RANK_LVMVG, i1->device);
+ nodes.push_back(vg_node);
- if (!i2->v.mount.empty())
+ deque<LvmLvInfo> lvs;
+ s->getLvmLvInfo(i1->name, lvs);
+ for (deque<LvmLvInfo>::iterator i2 = lvs.begin();
+ i2 != lvs.end(); ++i2)
{
- Node mountpoint_node("mountpoint:" + i2->v.mount, RANK_MOUNTPOINT, i2->v.mount);
- nodes.push_back(mountpoint_node);
+ Node lv_node("device:" + i2->v.device, RANK_LVMLV, i2->v.device);
+ nodes.push_back(lv_node);
- edges.push_back(Edge(lv_node.id, mountpoint_node.id));
- }
- }
+ edges.push_back(Edge(vg_node.id, lv_node.id));
+
+ if (!i2->v.mount.empty())
+ {
+ Node mountpoint_node("mountpoint:" + i2->v.mount, RANK_MOUNTPOINT, i2->v.mount);
+ nodes.push_back(mountpoint_node);
- } break;
+ edges.push_back(Edge(lv_node.id, mountpoint_node.id));
+ }
+ }
- case MD: {
+ } break;
- deque<MdInfo> mds;
- getMdInfo(mds);
+ case MD: {
- for (deque<MdInfo>::iterator i2 = mds.begin(); i2 != mds.end(); ++i2)
- {
- Node md_node("device:" + i2->v.device, RANK_MD, i2->v.device, "color=red, fillcolor=yellow");
- nodes.push_back(md_node);
+ deque<MdInfo> mds;
+ s->getMdInfo(mds);
- if (!i2->v.usedByDevice.empty())
+ for (deque<MdInfo>::iterator i2 = mds.begin(); i2 != mds.end(); ++i2)
{
- edges.push_back(Edge(md_node.id, "device:" + i2->v.usedByDevice));
- }
+ Node md_node("device:" + i2->v.device, RANK_MD, i2->v.device, "color=red, fillcolor=yellow");
+ nodes.push_back(md_node);
- if (!i2->v.mount.empty())
- {
- Node mountpoint_node("mountpoint:" + i2->v.mount, RANK_MOUNTPOINT, i2->v.mount);
- nodes.push_back(mountpoint_node);
+ if (!i2->v.usedByDevice.empty())
+ {
+ edges.push_back(Edge(md_node.id, "device:" + i2->v.usedByDevice));
+ }
+
+ if (!i2->v.mount.empty())
+ {
+ Node mountpoint_node("mountpoint:" + i2->v.mount, RANK_MOUNTPOINT, i2->v.mount);
+ nodes.push_back(mountpoint_node);
- edges.push_back(Edge(md_node.id, mountpoint_node.id));
+ edges.push_back(Edge(md_node.id, mountpoint_node.id));
+ }
}
- }
- } break;
+ } break;
+ }
}
- }
- ofstream out(filename.c_str());
+ ofstream out(filename.c_str());
- out << "// generated by YaST (" << PACKAGE_STRING << ")" << endl;
+ out << "// generated by YaST (" << PACKAGE_STRING << ")" << endl;
- out << "digraph storage" << endl;
- out << "{" << endl;
- out << " node [shape=rectangle, style=filled, fontname=Helvetica];" << endl;
- out << endl;
+ out << "digraph storage" << endl;
+ out << "{" << endl;
+ out << " node [shape=rectangle, style=filled, fontname=Helvetica];" << endl;
+ out << endl;
- for (list<Node>::const_iterator node = nodes.begin(); node != nodes.end(); ++node)
- out << " " << (*node) << endl;
+ for (list<Node>::const_iterator node = nodes.begin(); node != nodes.end(); ++node)
+ out << " " << (*node) << endl;
- out << endl;
+ out << endl;
- for (Ranks::const_iterator rank = ranks.begin(); rank != ranks.end(); ++rank)
- {
- list<string> ids;
- for (list<Node>::const_iterator node = nodes.begin(); node != nodes.end(); ++node)
- if (node->rank == *rank)
- ids.push_back(dotQuote(node->id));
+ for (Ranks::const_iterator rank = ranks.begin(); rank != ranks.end(); ++rank)
+ {
+ list<string> ids;
+ for (list<Node>::const_iterator node = nodes.begin(); node != nodes.end(); ++node)
+ if (node->rank == *rank)
+ ids.push_back(dotQuote(node->id));
- if (!ids.empty())
- out << " { rank=same; " << boost::join(ids, " ") << " };" << endl;
- }
- out << endl;
+ if (!ids.empty())
+ out << " { rank=same; " << boost::join(ids, " ") << " };" << endl;
+ }
+ out << endl;
+
+ for (list<Edge>::const_iterator edge = edges.begin(); edge != edges.end(); ++edge)
+ out << " " << (*edge) << endl;
- for (list<Edge>::const_iterator edge = edges.begin(); edge != edges.end(); ++edge)
- out << " " << (*edge) << endl;
+ out << "}" << endl;
- out << "}" << endl;
+ out.close();
- out.close();
+ return 0;
+ }
- return 0;
}
Added: trunk/storage/libstorage/src/Graph.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Graph.h?rev=55218&view=auto
==============================================================================
--- trunk/storage/libstorage/src/Graph.h (added)
+++ trunk/storage/libstorage/src/Graph.h Tue Feb 3 18:31:48 2009
@@ -0,0 +1,25 @@
+#ifndef GRAPH_H
+#define GRAPH_H
+
+
+#include <string>
+
+
+#include "StorageInterface.h"
+
+
+namespace storage
+{
+
+ /**
+ * Saves a graph of the storage devices as a DOT file for graphviz.
+ *
+ * @param filename filename of graph
+ * @return zero if all is ok, negative number to indicate an error
+ */
+ int saveGraph(StorageInterface* s, const std::string& filename);
+
+}
+
+
+#endif
Added: trunk/storage/libstorage/src/HumanString.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/HumanString.cc?rev=55218&view=auto
==============================================================================
--- trunk/storage/libstorage/src/HumanString.cc (added)
+++ trunk/storage/libstorage/src/HumanString.cc Tue Feb 3 18:31:48 2009
@@ -0,0 +1,155 @@
+/*
+ * Author: Arvin Schnell
+ */
+
+/*
+ Textdomain "storage"
+*/
+
+
+#include <locale>
+#include
+
+#include "AppUtil.h"
+#include "HumanString.h"
+
+
+using namespace std;
+
+
+namespace storage
+{
+
+ int
+ numSuffixes()
+ {
+ return 6;
+ }
+
+
+ string
+ getSuffix(int i, bool classic, bool sloppy = false)
+ {
+ switch (i)
+ {
+ case 0:
+ if (sloppy)
+ return "";
+ else
+ /* Byte abbreviated */
+ return classic ? "B" : _("B");
+
+ case 1:
+ if (sloppy)
+ /* Kilo abbreviated */
+ return classic ? "k" : _("k");
+ else
+ /* KiloByte abbreviated */
+ return classic ? "kB" : _("kB");
+
+ case 2:
+ if (sloppy)
+ /* Mega abbreviated */
+ return classic ? "M" : _("M");
+ else
+ /* MegaByte abbreviated */
+ return classic ? "MB" : _("MB");
+
+ case 3:
+ if (sloppy)
+ /* Giga abbreviated */
+ return classic ? "G" : _("G");
+ else
+ /* GigaByte abbreviated */
+ return classic ? "GB" : _("GB");
+
+ case 4:
+ if (sloppy)
+ /* Tera abbreviated */
+ return classic ? "T" : _("T");
+ else
+ /* TeraByte abbreviated */
+ return classic ? "TB" : _("TB");
+
+ case 5:
+ if (sloppy)
+ /* Peta abbreviated */
+ return classic ? "P" : _("P");
+ else
+ /* PetaByte abbreviated */
+ return classic ? "PB" : _("PB");
+ }
+
+ return string("error");
+ }
+
+
+ string
+ byteToHumanString(unsigned long long size, bool classic, int precision, bool omit_zeroes)
+ {
+ const locale loc = classic ? locale::classic() : locale();
+
+ double f = size;
+ int i = 0;
+
+ while (f >= 1024.0 && i + 1 < numSuffixes())
+ {
+ f /= 1024.0;
+ i++;
+ }
+
+ if (omit_zeroes && (f == (unsigned long long)(f)))
+ {
+ precision = 0;
+ }
+
+ ostringstream s;
+ s.imbue(loc);
+ s.setf(ios::fixed);
+ s.precision(precision);
+
+ s << f << ' ' << getSuffix(i, classic);
+
+ return s.str();
+ }
+
+
+ bool
+ humanStringToByte(const string& str, bool classic, unsigned long long& size)
+ {
+ const locale loc = classic ? locale::classic() : locale();
+
+ const string str_trimmed = boost::trim_copy(str, loc);
+
+ double f = 1.0;
+
+ for (int i = 0; i < numSuffixes(); i++)
+ {
+ for (int j = 0; j < (classic ? 1 : 2); j++)
+ {
+ string suffix = getSuffix(i, classic, j != 0);
+ if (boost::iends_with(str_trimmed, suffix, loc))
+ {
+ string number = str_trimmed.substr(0, str_trimmed.size() - suffix.size());
+
+ istringstream s(boost::trim_copy(number, loc));
+ s.imbue(loc);
+
+ double g;
+ s >> g;
+
+ if (!s.fail() && s.eof() && g >= 0.0)
+ {
+ size = g * f;
+ return true;
+ }
+ }
+ }
+
+ f *= 1024.0;
+ }
+
+ return false;
+ }
+
+}
Added: trunk/storage/libstorage/src/HumanString.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/HumanString.h?rev=55218&view=auto
==============================================================================
--- trunk/storage/libstorage/src/HumanString.h (added)
+++ trunk/storage/libstorage/src/HumanString.h Tue Feb 3 18:31:48 2009
@@ -0,0 +1,40 @@
+#ifndef HUMAN_STRING_H
+#define HUMAN_STRING_H
+
+
+#include <string>
+
+
+namespace storage
+{
+
+ /**
+ * Return a pretty description of a size with required precision
+ * and using B, kB, MB, GB, TB or PB as unit as appropriate.
+ *
+ * @param size size in bytes
+ * @param classic use classic locale
+ * @param precision number of fraction digits in output
+ * @param omit_zeroes if true omit trailing zeroes for exact values
+ * @return formatted string
+ */
+ std::string byteToHumanString(unsigned long long size, bool classic, int precision,
+ bool omit_zeroes);
+
+ /**
+ * Converts a size description using B, kB, MB, GB, TB or PB into an integer.
+ *
+ * @param str size string
+ * @param classic use classic locale
+ * @param size size in bytes
+ * @return true on successful conversion
+ *
+ * The conversion is always case-insensitive. With classic set to
+ * false the conversion is also sloppy concerning omission of 'B'.
+ */
+ bool humanStringToByte(const std::string& str, bool classic, unsigned long long& size);
+
+}
+
+
+#endif
Modified: trunk/storage/libstorage/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Makefile.am?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Makefile.am (original)
+++ trunk/storage/libstorage/src/Makefile.am Tue Feb 3 18:31:48 2009
@@ -46,7 +46,8 @@
Md.cc Md.h \
Loop.cc Loop.h \
Nfs.cc Nfs.h \
- Graph.cc \
+ HumanString.cc HumanString.h \
+ Graph.cc Graph.h \
SystemCmd.cc SystemCmd.h \
OutputProcessor.cc OutputProcessor.h \
Regex.cc Regex.h \
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Tue Feb 3 18:31:48 2009
@@ -5875,19 +5875,6 @@
}
-string Storage::byteToHumanString(unsigned long long size, bool classic, int precision,
- bool omit_zeroes) const
-{
- return storage::byteToHumanString(size, classic, precision, omit_zeroes);
-}
-
-
-bool Storage::humanStringToByte(const string& str, bool classic, unsigned long long& size) const
-{
- return storage::humanStringToByte(str, classic, size);
-}
-
-
namespace storage
{
std::ostream& operator<< (std::ostream& s, Storage &v )
Modified: trunk/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.h?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.h (original)
+++ trunk/storage/libstorage/src/Storage.h Tue Feb 3 18:31:48 2009
@@ -471,10 +471,6 @@
bool checkDmMapsTo( const string& dev );
void updateDmEmptyPeMap();
void dumpObjectList();
- int saveGraph(const string& filename);
-
- string byteToHumanString(unsigned long long size, bool classic, int precision, bool omit_zeroes) const;
- bool humanStringToByte(const string& str, bool classic, unsigned long long& size) const;
void setCallbackProgressBar( storage::CallbackProgressBar pfnc )
{ progress_bar_cb=pfnc; }
Modified: trunk/storage/libstorage/src/StorageInterface.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/StorageInterface.h?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/src/StorageInterface.h (original)
+++ trunk/storage/libstorage/src/StorageInterface.h Tue Feb 3 18:31:48 2009
@@ -2118,14 +2118,6 @@
virtual void dumpObjectList() = 0;
/**
- * Saves a graph of the storage devices as DOT file for graphviz.
- *
- * @param filename filename of graph
- * @return zero if all is ok, negative number to indicate an error
- */
- virtual int saveGraph(const string& filename) = 0;
-
- /**
* Split volume device name up into container name and a volume
* name. For Containers where this is appropriate (e.g. disks,
* MD, loop) also a volume number is provided.
@@ -2136,32 +2128,6 @@
*/
virtual int getContVolInfo( const string& dev, ContVolInfo& info) = 0;
- /**
- * Return a pretty description of a size with required precision
- * and using B, kB, MB, GB, TB or PB as unit as appropriate.
- *
- * @param size size in bytes
- * @param classic use classic locale
- * @param precision number of fraction digits in output
- * @param omit_zeroes if true omit trailing zeroes for exact values
- * @return formatted string
- */
- virtual string byteToHumanString(unsigned long long size, bool classic, int precision,
- bool omit_zeroes) const = 0;
-
- /**
- * Converts a size description using B, kB, MB, GB, TB or PB into an integer.
- *
- * @param str size string
- * @param classic use classic locale
- * @param size size in bytes
- * @return true on successful conversion
- *
- * The conversion is always case-insensitive. With classic set to
- * false the conversion is also sloppy concerning omission of 'B'.
- */
- virtual bool humanStringToByte(const string& str, bool classic, unsigned long long&
- size) const = 0;
};
Modified: trunk/storage/libstorage/src/Volume.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Volume.cc?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Volume.cc (original)
+++ trunk/storage/libstorage/src/Volume.cc Tue Feb 3 18:31:48 2009
@@ -20,6 +20,7 @@
#include "y2storage/OutputProcessor.h"
#include "y2storage/EtcFstab.h"
#include "y2storage/StorageDefines.h"
+#include "y2storage/HumanString.h"
using namespace std;
using namespace storage;
Modified: trunk/storage/libstorage/testsuite/humanstring1.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/humanstring1.cc?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite/humanstring1.cc (original)
+++ trunk/storage/libstorage/testsuite/humanstring1.cc Tue Feb 3 18:31:48 2009
@@ -2,7 +2,7 @@
#include <iostream>
#include <locale>
-#include
+#include
using namespace std;
using namespace storage;
@@ -12,23 +12,18 @@
// during package build.
-StorageInterface* s = 0;
-
-
void
test(const char* loc, unsigned long long size, bool classic,
int precision, bool omit_zeroes)
{
locale::global(locale(loc));
- cout << s->byteToHumanString(size, classic, precision, omit_zeroes) << endl;
+ cout << byteToHumanString(size, classic, precision, omit_zeroes) << endl;
}
int
main()
{
- s = createStorageInterface(true, true, false);
-
test("en_GB.UTF-8", 1024, true, 2, true);
test("en_GB.UTF-8", 1024, true, 2, false);
@@ -41,6 +36,4 @@
test("en_GB.UTF-8", 1000*1024, false, 2, false);
test("de_DE.UTF-8", 1000*1024, false, 2, false);
test("fr_FR.UTF-8", 1000*1024, false, 2, false);
-
- delete s;
}
Modified: trunk/storage/libstorage/testsuite/humanstring2.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/testsuite/humanstring2.cc?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/libstorage/testsuite/humanstring2.cc (original)
+++ trunk/storage/libstorage/testsuite/humanstring2.cc Tue Feb 3 18:31:48 2009
@@ -2,7 +2,7 @@
#include <iostream>
#include <locale>
-#include
+#include
using namespace std;
using namespace storage;
@@ -12,9 +12,6 @@
// during package build.
-StorageInterface* s = 0;
-
-
void
test(const char* loc, const char* str, bool classic)
{
@@ -22,7 +19,7 @@
unsigned long long size = 0;
- if (s->humanStringToByte(str, classic, size))
+ if (humanStringToByte(str, classic, size))
cout << "parse ok " << size << endl;
else
cout << "parse error" << endl;
@@ -32,8 +29,6 @@
int
main()
{
- s = createStorageInterface(true, true, false);
-
test("en_GB.UTF-8", "42", true); // FAILS: classic=true needs a suffix
test("en_GB.UTF-8", "42B", true);
test("en_GB.UTF-8", "42 b", true);
@@ -68,6 +63,4 @@
test("en_US.UTF-8", "5 G B", false); // FAILS
test("de_DE.UTF-8", "12.34 kB", false); // FAILS
test("fr_FR.UTF-8", "12 34 GB", false); // FAILS
-
- delete s;
}
Modified: trunk/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Storage.ycp?rev=55218&r1=55217&r2=55218&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Tue Feb 3 18:31:48 2009
@@ -359,32 +359,32 @@
global string ByteToHumanString(integer bytes)
{
- return LibStorage::StorageInterface::byteToHumanString(sint, bytes, false, 2, false);
+ return LibStorage::byteToHumanString(bytes, false, 2, false);
}
global string KByteToHumanString(integer kbytes)
{
- return LibStorage::StorageInterface::byteToHumanString(sint, kbytes * 1024, false, 2, false);
+ return LibStorage::byteToHumanString(kbytes * 1024, false, 2, false);
}
global string ByteToHumanStringWithPrecision(integer bytes, integer precision, boolean omit_zeroes)
{
- return LibStorage::StorageInterface::byteToHumanString(sint, bytes, false, precision, omit_zeroes);
+ return LibStorage::byteToHumanString(bytes, false, precision, omit_zeroes);
}
global string KByteToHumanStringWithPrecision(integer kbytes, integer precision, boolean omit_zeroes)
{
- return LibStorage::StorageInterface::byteToHumanString(sint, kbytes * 1024, false, precision, omit_zeroes);
+ return LibStorage::byteToHumanString(kbytes * 1024, false, precision, omit_zeroes);
}
global boolean HumanStringToByte(string str, integer& bytes)
{
integer i = 0; bytes = i; // bnc #408829 and #408891
- boolean ret = LibStorage::StorageInterface::humanStringToByte(sint, str, false, bytes);
+ boolean ret = LibStorage::humanStringToByte(str, false, bytes);
y2milestone("HumanStringToByte ret:%1 str:%2 bytes:%3", ret, str, bytes);
return ret;
}
@@ -393,7 +393,7 @@
global boolean HumanStringToKByte(string str, integer& kbytes)
{
integer bytes = 0; // bnc #408829
- boolean ret = LibStorage::StorageInterface::humanStringToByte(sint, str, false, bytes);
+ boolean ret = LibStorage::humanStringToByte(str, false, bytes);
kbytes = bytes / 1024;
y2milestone("HumanStringToKByte ret:%1 str:%2 kbytes:%3", ret, str, kbytes);
return ret;
@@ -6271,7 +6271,7 @@
integer StrToByte(string str)
{
integer bytes = 0;
- if (!LibStorage::StorageInterface::humanStringToByte(sint, str, true, bytes))
+ if (!LibStorage::humanStringToByte(str, true, bytes))
y2error("cannot parse %1", str);
return bytes;
}
@@ -6463,7 +6463,7 @@
global integer SaveGraph(string filename)
{
- integer ret = LibStorage::StorageInterface::saveGraph(sint, filename);
+ integer ret = LibStorage::saveGraph(sint, filename);
return ret;
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org