diff options
author | Andy Schwerin <schwerin@10gen.com> | 2012-09-21 14:52:49 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@10gen.com> | 2012-09-25 15:05:32 -0400 |
commit | 801992d49afe770bc2f240735028e161da11c532 (patch) | |
tree | 0a1b85c8f7758d6c55a1c04811732011fae34c82 /src/mongo/platform | |
parent | 3aa13e9159d839760b54419fd54636cd11ae5e8b (diff) | |
download | mongo-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')
-rw-r--r-- | src/mongo/platform/strtoll.h | 29 |
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) |