ReactOS 0.4.15-dev-7924-g5949c20
num_get.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18#include "stlport_prefix.h"
19
20#include <locale>
21#include <istream>
22#include <algorithm>
23
26
27// __valid_grouping compares two strings, one representing the
28// group sizes encountered when reading an integer, and the other
29// representing the valid group sizes as returned by the numpunct
30// grouping() member function. Both are interpreted right-to-left.
31// The grouping string is treated as if it were extended indefinitely
32// with its last value. For a grouping to be valid, each term in
33// the first string must be equal to the corresponding term in the
34// second, except for the last, which must be less than or equal.
35
36// boris : this takes reversed first string !
37bool _STLP_CALL
38__valid_grouping(const char * first1, const char * last1,
39 const char * first2, const char * last2) {
40 if (first1 == last1 || first2 == last2) return true;
41
42 --last1; --last2;
43
44 while (first1 != last1) {
45 if (*last1 != *first2)
46 return false;
47 --last1;
48 if (first2 != last2) ++first2;
49 }
50
51 return *last1 <= *first2;
52}
53
54_STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned __index) {
55 static const unsigned char __val_table[128] = {
56 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
57 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
58 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
59 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
60 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
61 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
62 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
63 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
64 };
65
66 return __val_table[__index];
67}
68
70{ return "+-0xX"; }
71
72// index is actually a char
73
74#if !defined (_STLP_NO_WCHAR_T)
75
76// Similar, except return the character itself instead of the numeric
77// value. Used for floating-point input.
78bool _STLP_CALL __get_fdigit(wchar_t& c, const wchar_t* digits) {
79 const wchar_t* p = find(digits, digits + 10, c);
80 if (p != digits + 10) {
81 c = (char)('0' + (p - digits));
82 return true;
83 }
84 else
85 return false;
86}
87
88bool _STLP_CALL __get_fdigit_or_sep(wchar_t& c, wchar_t sep,
89 const wchar_t * digits) {
90 if (c == sep) {
91 c = (char)',';
92 return true;
93 }
94 else
95 return __get_fdigit(c, digits);
96}
97
98#endif
99
101
102#if !defined(_STLP_NO_FORCE_INSTANTIATE)
103//----------------------------------------------------------------------
104// Force instantiation of num_get<>
106// template class num_get<char, const char*>;
108
109# if !defined (_STLP_NO_WCHAR_T)
112// template class num_get<wchar_t, const wchar_t*>;
113# endif
114#endif
115
117
118// Local Variables:
119// mode:C++
120// End:
#define _STLP_CALL
Definition: _bc.h:131
static TAGID TAGID find
Definition: db.cpp:155
unsigned char
Definition: typeof.h:29
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define _STLP_DECLSPEC
Definition: features.h:982
#define _STLP_MOVE_TO_PRIV_NAMESPACE
Definition: features.h:524
const GLubyte * c
Definition: glext.h:8905
GLfloat GLfloat p
Definition: glext.h:8902
static const int digits[]
Definition: decode.c:71
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE bool _STLP_CALL __valid_grouping(const char *first1, const char *last1, const char *first2, const char *last2)
Definition: num_get.cpp:38
_STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned __index)
Definition: num_get.cpp:54
_STLP_DECLSPEC const char *_STLP_CALL __narrow_atoms()
Definition: num_get.cpp:69
bool _STLP_CALL __get_fdigit_or_sep(wchar_t &c, wchar_t sep, const wchar_t *digits)
Definition: num_get.cpp:88
bool _STLP_CALL __get_fdigit(wchar_t &c, const wchar_t *digits)
Definition: num_get.cpp:78