summaryrefslogtreecommitdiffstats
path: root/src/svg/itos.cpp
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2006-01-16 02:36:01 +0000
committermental <mental@users.sourceforge.net>2006-01-16 02:36:01 +0000
commit179fa413b047bede6e32109e2ce82437c5fb8d34 (patch)
treea5a6ac2c1708bd02288fbd8edb2ff500ff2e0916 /src/svg/itos.cpp
downloadinkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.tar.gz
inkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.zip
moving trunk for module inkscape
(bzr r1)
Diffstat (limited to 'src/svg/itos.cpp')
-rw-r--r--src/svg/itos.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/svg/itos.cpp b/src/svg/itos.cpp
new file mode 100644
index 000000000..9b1232130
--- /dev/null
+++ b/src/svg/itos.cpp
@@ -0,0 +1,77 @@
+/////////////////////////////////////////////////////////////////////////
+// ftoa.cpp
+//
+// Copyright (c) 1996-2003 Bryce W. Harrington [bryce at osdl dot org]
+//
+//-----------------------------------------------------------------------
+// License: This code may be used by anyone for any purpose
+// so long as the copyright notices and this license
+// statement remains attached.
+//-----------------------------------------------------------------------
+//
+// This routine converts an integer into a string
+//
+/////////////////////////////////////////////////////////////////////////
+
+// Standard include files
+#include <string> // for string
+
+using namespace std;
+
+string itos(int n)
+{
+ int sign;
+ string s;
+
+ if ((sign = n) < 0) // record sign
+ n = -n; // make n positive
+ do { // generate digits in reverse order
+ s += (char(n % 10) + '0'); // get next digit
+ } while ((n/=10) > 0); // delete it
+
+ if (sign < 0)
+ s += '-';
+
+ reverse(s.begin(), s.end()); // This is what the code should look like
+ // if the string class is compatible with
+ // the standard C++ string class
+#ifdef DUMB_OS_LIKE_WINDOWS
+ // In Windows, we'll use this hack...
+ for (int i=0, j=s.GetLength()-1; i<j; i++, j--)
+ {
+ char c = s[i];
+// s[i] = s[j];
+// s[j] = c;
+ s.SetAt(i, s[j]);
+ s.SetAt(j, c);
+ }
+#endif
+
+ return s;
+}
+
+string ultos(unsigned long n)
+{
+ string s;
+
+ do { // generate digits in reverse order
+ s += (char(n % 10) + '0'); // get next digit
+ } while ((n/=10) > 0); // delete it
+
+ reverse(s.begin(), s.end()); // This is what the code should look like
+ // if the string class is compatible with
+ // the standard C++ string class
+#ifdef DUMB_OS_LIKE_WINDOWS
+ // In Windows, we'll use this hack...
+ for (int i=0, j=s.GetLength()-1; i<j; i++, j--)
+ {
+ char c = s[i];
+// s[i] = s[j];
+// s[j] = c;
+ s.SetAt(i, s[j]);
+ s.SetAt(j, c);
+ }
+#endif
+
+ return s;
+}