summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-08-05 08:18:42 +0000
committerbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-08-05 08:18:42 +0000
commit9cec79b48dc122a3e2b6027bce15761abc8b6d66 (patch)
tree6dcbd5bc38dc3a1194a31af55c032ce3b0dc49a6
parent271874538fb0a7be3c5c632795bda3e63583f5cd (diff)
downloadATCD-9cec79b48dc122a3e2b6027bce15761abc8b6d66.tar.gz
ChangeLogTag:Sat Aug 5 01:13:01 2000 Darrell Brunsch <brunsch@uci.edu>
-rw-r--r--ChangeLog14
-rw-r--r--ChangeLogs/ChangeLog-02a14
-rw-r--r--ChangeLogs/ChangeLog-03a14
-rw-r--r--ace/OS_String.cpp101
-rw-r--r--ace/OS_String.h7
-rw-r--r--ace/OS_String.inl20
-rw-r--r--ace/config-win32-common.h1
7 files changed, 171 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c3726442b3d..73eb3a14537 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Sat Aug 5 01:13:01 2000 Darrell Brunsch <brunsch@uci.edu>
+
+ * ace/OS_String.cpp:
+ * ace/OS_String.h:
+ * ace/OS_String.inl:
+
+ Added itoa, which takes in a value, string, and radix. It then
+ populates the string with the representation of the value in that
+ radix.
+
+ * ace/config-win32-common.h:
+
+ Turned on ACE_HAS_ITOA.
+
Fri Aug 4 15:53:27 2000 Carlos O'Ryan <coryan@uci.edu>
* ace/TP_Reactor.h:
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index c3726442b3d..73eb3a14537 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,17 @@
+Sat Aug 5 01:13:01 2000 Darrell Brunsch <brunsch@uci.edu>
+
+ * ace/OS_String.cpp:
+ * ace/OS_String.h:
+ * ace/OS_String.inl:
+
+ Added itoa, which takes in a value, string, and radix. It then
+ populates the string with the representation of the value in that
+ radix.
+
+ * ace/config-win32-common.h:
+
+ Turned on ACE_HAS_ITOA.
+
Fri Aug 4 15:53:27 2000 Carlos O'Ryan <coryan@uci.edu>
* ace/TP_Reactor.h:
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index c3726442b3d..73eb3a14537 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,17 @@
+Sat Aug 5 01:13:01 2000 Darrell Brunsch <brunsch@uci.edu>
+
+ * ace/OS_String.cpp:
+ * ace/OS_String.h:
+ * ace/OS_String.inl:
+
+ Added itoa, which takes in a value, string, and radix. It then
+ populates the string with the representation of the value in that
+ radix.
+
+ * ace/config-win32-common.h:
+
+ Turned on ACE_HAS_ITOA.
+
Fri Aug 4 15:53:27 2000 Carlos O'Ryan <coryan@uci.edu>
* ace/TP_Reactor.h:
diff --git a/ace/OS_String.cpp b/ace/OS_String.cpp
index ab2f2b5065c..5abe7659432 100644
--- a/ace/OS_String.cpp
+++ b/ace/OS_String.cpp
@@ -399,3 +399,104 @@ ACE_OS_String::memchr_emulation (const void *s, int c, size_t len)
return 0;
}
+char *
+ACE_OS_String::itoa_emulation (int value, char *string, int radix)
+{
+ char *e = string;
+ char *b = string;
+
+ // Short circuit if 0
+
+ if (value == 0)
+ {
+ string[0] = '0';
+ string[1] = 0;
+ return string;
+ }
+
+ // If negative and base 10, print a - and then do the
+ // number.
+
+ if (value < 0 && radix == 10)
+ {
+ string[0] = '-';
+ b++;
+ }
+
+ // Convert to base <radix>, but in reverse order
+
+ while (value != 0)
+ {
+ int mod = value % radix;
+ value = value / radix;
+
+ *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10;
+ }
+
+ *e-- = 0;
+
+ // Now reverse the string to get the correct result
+
+ while (e > b)
+ {
+ char temp = *e;
+ *e = *b;
+ *b = temp;
+ ++b;
+ --e;
+ }
+
+ return string;
+}
+
+#if defined (ACE_HAS_WCHAR)
+wchar_t *
+ACE_OS_String::itoa_emulation (int value, wchar_t *string, int radix)
+{
+ wchar_t *e = string;
+ wchar_t *b = string;
+
+ // Short circuit if 0
+
+ if (value == 0)
+ {
+ string[0] = '0';
+ string[1] = 0;
+ return string;
+ }
+
+ // If negative and base 10, print a - and then do the
+ // number.
+
+ if (value < 0 && radix == 10)
+ {
+ string[0] = '-';
+ b++;
+ }
+
+ // Convert to base <radix>, but in reverse order
+
+ while (value != 0)
+ {
+ int mod = value % radix;
+ value = value / radix;
+
+ *e++ = (mod < 10) ? '0' + mod : 'a' + mod - 10;
+ }
+
+ *e-- = 0;
+
+ // Now reverse the string to get the correct result
+
+ while (e > b)
+ {
+ wchar_t temp = *e;
+ *e = *b;
+ *b = temp;
+ ++b;
+ --e;
+ }
+
+ return string;
+}
+#endif /* ACE_HAS_WCHAR */
diff --git a/ace/OS_String.h b/ace/OS_String.h
index 11087d94c36..e55ad295912 100644
--- a/ace/OS_String.h
+++ b/ace/OS_String.h
@@ -154,6 +154,11 @@ public:
static int ace_isspace (const ACE_TCHAR s);
static int ace_isprint (const ACE_TCHAR s);
+ static char *itoa (int value, char *string, int radix);
+#if defined (ACE_HAS_WCHAR)
+ static wchar_t *itoa (int value, wchar_t *string, int radix);
+#endif /* ACE_HAS_WCHAR */
+
private:
// = These are emulation or platform specific versions of methods.
static const void *memchr_emulation (const void *s, int c, size_t len);
@@ -166,6 +171,7 @@ private:
static int strcasecmp_emulation (const char *s, const char *t);
static int strncasecmp_emulation (const char *s, const char *t, size_t len);
static char *strtok_r_emulation (char *s, const char *tokens, char **lasts);
+ static char *itoa_emulation (int value, char *string, int radix);
#if defined (ACE_HAS_WCHAR)
static wchar_t *strrchr_emulation (wchar_t *s, wint_t c);
@@ -174,6 +180,7 @@ private:
static int strncasecmp_emulation (const wchar_t *s,
const wchar_t *t,
size_t len);
+ static wchar_t *itoa_emulation (int value, wchar_t *string, int radix);
#endif /* ACE_HAS_WCHAR */
};
diff --git a/ace/OS_String.inl b/ace/OS_String.inl
index 9e527c4b614..1f8c24ff2a9 100644
--- a/ace/OS_String.inl
+++ b/ace/OS_String.inl
@@ -650,3 +650,23 @@ ACE_OS_String::ace_isprint (const ACE_TCHAR s)
return isprint (s);
#endif /* ACE_HAS_WINCE */
}
+
+ACE_INLINE char *
+ACE_OS_String::itoa (int value, char *string, int radix)
+{
+#if defined (ACE_HAS_ITOA)
+ return ::_itoa (value, string, radix);
+#else
+ return ACE_OS_String::itoa_emulation (value, string, radix);
+#endif /* ACE_HAS_ITOA */
+}
+
+ACE_INLINE wchar_t *
+ACE_OS_String::itoa (int value, wchar_t *string, int radix)
+{
+#if defined (ACE_HAS_ITOA)
+ return ::_itow (value, string, radix);
+#else
+ return ACE_OS_String::itoa_emulation (value, string, radix);
+#endif /* ACE_HAS_ITOA */
+}
diff --git a/ace/config-win32-common.h b/ace/config-win32-common.h
index a2b7e295f95..ef0723eb146 100644
--- a/ace/config-win32-common.h
+++ b/ace/config-win32-common.h
@@ -194,6 +194,7 @@
#define ACE_HAS_MSG
#define ACE_HAS_DIRENT
#define ACE_HAS_SOCKADDR_MSG_NAME
+#define ACE_HAS_ITOA
#define ACE_LACKS_GETPGID
#define ACE_LACKS_GETPPID
#define ACE_LACKS_SETPGID