summaryrefslogtreecommitdiff
path: root/src/mongo/platform/strtoll.h
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@10gen.com>2012-09-21 14:52:49 -0400
committerAndy Schwerin <schwerin@10gen.com>2012-09-25 15:05:32 -0400
commit801992d49afe770bc2f240735028e161da11c532 (patch)
tree0a1b85c8f7758d6c55a1c04811732011fae34c82 /src/mongo/platform/strtoll.h
parent3aa13e9159d839760b54419fd54636cd11ae5e8b (diff)
downloadmongo-801992d49afe770bc2f240735028e161da11c532.tar.gz
parseNumberFromString* functions
A uniform interface for parsing numbers out of strings, with implementations for the standard integer types. Extension to double should be straightforward. Tests included.
Diffstat (limited to 'src/mongo/platform/strtoll.h')
-rw-r--r--src/mongo/platform/strtoll.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mongo/platform/strtoll.h b/src/mongo/platform/strtoll.h
new file mode 100644
index 00000000000..6464022c8c6
--- /dev/null
+++ b/src/mongo/platform/strtoll.h
@@ -0,0 +1,29 @@
+/**
+ * Copyright (C) 2012 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <cstdlib>
+
+#ifdef _WIN32
+static inline long long strtoll(const char* nptr, char** endptr, int base) {
+ return _strtoi64(nptr, endptr, base);
+}
+
+static inline unsigned long long strtoull(const char* nptr, char** endptr, int base) {
+ return _strtoui64(nptr, endptr, base);
+}
+#endif // defined(_WIN32)