summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2011-10-23 09:03:12 +0000
committerJon A. Cruz <jon@joncruz.org>2011-10-23 09:03:12 +0000
commitf12861c744aff474afdaa457781008cbb995113f (patch)
tree5118f67c2bd189a9a7514efad6791d0335688502 /src
parentDocumentation update pass. (diff)
downloadinkscape-f12861c744aff474afdaa457781008cbb995113f.tar.gz
inkscape-f12861c744aff474afdaa457781008cbb995113f.zip
Cleanup constructors and initialization. Removed unused macro.
(bzr r10693)
Diffstat (limited to 'src')
-rw-r--r--src/version.cpp23
-rw-r--r--src/version.h82
2 files changed, 57 insertions, 48 deletions
diff --git a/src/version.cpp b/src/version.cpp
index edaa600db..1baf9d8d9 100644
--- a/src/version.cpp
+++ b/src/version.cpp
@@ -1,10 +1,9 @@
-#define __VERSION_C__
-
/*
* Versions
*
* Authors:
* MenTaLguY <mental@rydia.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2003 MenTaLguY
*
@@ -21,31 +20,31 @@ gboolean sp_version_from_string(const gchar *string, Inkscape::Version *version)
return FALSE;
}
- version->major = 0;
- version->minor = 0;
+ version->_major = 0;
+ version->_minor = 0;
return sscanf((const char *)string, "%u.%u",
- &version->major, &version->minor) ||
- sscanf((const char *)string, "%u", &version->major);
+ &version->_major, &version->_minor) ||
+ sscanf((const char *)string, "%u", &version->_major);
}
gchar *sp_version_to_string(Inkscape::Version version)
{
- return g_strdup_printf("%u.%u", version.major, version.minor);
+ return g_strdup_printf("%u.%u", version._major, version._minor);
}
gboolean sp_version_inside_range(Inkscape::Version version,
unsigned major_min, unsigned minor_min,
unsigned major_max, unsigned minor_max)
{
- if ( version.major < major_min || version.major > major_max ) {
+ if ( version._major < major_min || version._major > major_max ) {
return FALSE;
- } else if ( version.major == major_min &&
- version.minor <= minor_min )
+ } else if ( version._major == major_min &&
+ version._minor <= minor_min )
{
return FALSE;
- } else if ( version.major == major_max &&
- version.minor >= minor_max )
+ } else if ( version._major == major_max &&
+ version._minor >= minor_max )
{
return FALSE;
} else {
diff --git a/src/version.h b/src/version.h
index faa8c38b2..d90d27772 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,6 +1,7 @@
/*
* Authors:
* MenTaLguY <mental@rydia.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2003 MenTaLguY
*
@@ -16,45 +17,54 @@
namespace Inkscape {
-struct Version {
- Version() {
- major = 0;
- minor = 0;
- }
- Version(unsigned mj, unsigned mn) {
- // somebody pollutes our namespace with major() and minor()
- // macros, so we can't use new-style initializers
- major = mj;
- minor = mn;
- }
-
- unsigned major;
- unsigned minor;
-
- bool operator>(Version const &other) const {
- return major > other.major ||
- ( major == other.major && minor > other.minor );
- }
- bool operator==(Version const &other) const {
- return major == other.major && minor == other.minor;
- }
- bool operator!=(Version const &other) const {
- return major != other.major || minor != other.minor;
- }
- bool operator<(Version const &other) const {
- return major < other.major ||
- ( major == other.major && minor < other.minor );
- }
+class Version {
+public:
+
+ Version() : _major(0), _minor(0) {}
+
+ // Note: somebody pollutes our namespace with major() and minor()
+ Version(unsigned mj, unsigned mn) : _major(mj), _minor(mn) {}
+
+ bool operator>(Version const &other) const {
+ return _major > other._major ||
+ ( _major == other._major && _minor > other._minor );
+ }
+
+ bool operator==(Version const &other) const {
+ return _major == other._major && _minor == other._minor;
+ }
+
+ bool operator!=(Version const &other) const {
+ return _major != other._major || _minor != other._minor;
+ }
+
+ bool operator<(Version const &other) const {
+ return _major < other._major ||
+ ( _major == other._major && _minor < other._minor );
+ }
+
+ unsigned int _major;
+ unsigned int _minor;
};
}
-#define SP_VERSION_IS_ZERO (v) (!(v).major && !(v).minor)
+gboolean sp_version_from_string(const gchar *string, Inkscape::Version *version);
-gboolean sp_version_from_string (const gchar *string, Inkscape::Version *version);
-gchar *sp_version_to_string (Inkscape::Version version);
-gboolean sp_version_inside_range (Inkscape::Version version,
- unsigned major_min, unsigned minor_min,
- unsigned major_max, unsigned minor_max);
+gchar *sp_version_to_string(Inkscape::Version version);
-#endif
+gboolean sp_version_inside_range(Inkscape::Version version,
+ unsigned major_min, unsigned minor_min,
+ unsigned major_max, unsigned minor_max);
+
+#endif // SEEN_INKSCAPE_VERSION_H
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:75
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :