summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/InputUtil.cpp
blob: 52027a56ac8fab032a62f47a37e9fea2d4d0a261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#include <IceUtil/InputUtil.h>
#include <stdlib.h>

using namespace std;
using namespace IceUtil;

namespace IceUtilInternal
{

Int64
strToInt64(const char* s, char** endptr, int base)
{
#if defined(_WIN32) && defined(_MSC_VER)
    return _strtoi64(s, endptr, base);
#elif defined(ICE_64) && !defined(_WIN32)
    return strtol(s, endptr, base);
#else
    return strtoll(s, endptr, base);
#endif
}

bool
stringToInt64(const string& s, Int64& result)
{
    const char* start = s.c_str();
    char* end = 0;
    errno = 0;
    result = strToInt64(start, &end, 0);
    return (errno == 0 && start != end);
}

}