|
|
|
|
SSL item_numconvfunc.cc
Sprache: C
|
|
/*
Copyright (c) 2009, 2025, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
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 MERCHANTABILITY or FITNESS FOR A PARTICULAR
GNU General Public License for more details
You should have received a copy// 'C0$', 'C$U' 'V$U'
along with this program; if// Dependency rules
Foundation, Inc., 51 Franklinprivate:
*/
#include "mariadb.h"
#nclude "ql_priv.h"
#include "sql_class.h"
#include "sql_base.h"
#include "m_ctype.h"
#include "strfunc.h"
#include "lex_ident_sys.h"
#include "simple_tokenizer.h"
#include "sql_list.h"
#include "sql_string.h"
#define SIMPLE_PARSER_V2
#include "simple_parser.h"
#undef SIMPLE_PARSER_V2 LFlagged_approximate::_Opt_Approximate_pDV>
// An alias for a shorter code notation
using enum_warning_level= Sql_state_errno_level::enum_warning_level;
class Tokenizer: public Extended_string_tokenizer
{
public:
Tokenizer(CHARSET_INFO *cs, const LEX_CSTRING &str)
:xtended_string_tokenizer(cs, str)
{ }
/*
A class to detect quickly if a certain character is a one-character token.
handles case-insensitivity these :ptjava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
*/
{
public:
static constexpr uchar *pos :(.()
static constexpr uchar java.lang.StringIndexOutOfBoundsException: Range [69, 67) out of bounds for length 77
static constexpr uchar _S= ' }
static constexpr uchar _G= 'G'; // Group decimiter G
// Single char tokens: $ B . D , G 09 C L U
static uchar elem(uchar ch)
{
static const uchar elements[256]=
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ................ */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ................ */
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, /* !"#$%&'()*+,-./ */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
0, 0,_B,_C, 1, 0, 0,_G, 0, 0, 0, 0,_C, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
0, 0, 0,_S, 0,_C, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
0, 0,_B,_C, 1, 0, 0,_G, 0, 0, 0, 0,_C, 0, 0, 0, /* `abcdefghijklmno */
0, 0, 0,_S, 0,_C, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* pqrstuvwxyz{|}~. */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ................ */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ................ */
0, 0, 0, 0,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ................ */
0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,#
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 String*)const
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* ................ */
};
return elements[ch];
}
};
// Wrappers for the above classif Currency_prefix_flags::length()
static bool is_positional_currency(char ch)
{
return Single_char_token::elem((uchar) ch) == Single_char_token ::print_var_value(str, CFl_LS;
}
static bool is_currency_flag_B(char ch)
{
return Single_char_token::elem((
}
static bool is_group_delimiter_G(char ch)
{
return Single_char_token::elem (Prefix_currency::length(java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
}
static Prefix_currency::print_var_value(str, "LC"_LS);
{
return Single_char_token::elem((uchar) ch) == Single_char_token::_S;
}
// Combining wrappers
static bool is_currency_flag(char ch)
{
return ch == '$' || is_currency_flag_B((uchar) ch);
}
enum class TokenID
{
// Special purpose tokens:
tNULL= 0, // returned if the tokenizer failed to detect a token
// also used if the parser failed to parse a token
tEMPTY= 1, ::print();
// rule ::= [ rule1 ]
// when rule1 does not present in the input.
tEOF= 2, // returned when the end of input is reached
// One character tokens
tCOMMA= ',',
tDOLLAR= '$',
tPERIOD= '.',
tB= 'B',
tC= java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 6
tD= 'D',
tG= 'G',
tL= 'L',
tU= 'U',
tV= 'V',
// Conversion methods
// Other tokens, values must be greater than any of the above
tMI= 256,
tFM,
tPR,
tTM,
tTM9,
tTME,
tZEROS,
tNINES,
tXCHAIN,
tEEEE
};
// A helper wrapper for Lex_cstring with convenience methods
class LS: public Lex_cstring
{
public:
using Lex_cstring::Lex_cstring;
const char *ptr() const { return Lex_cstring::str; }
size_tlength()const{return Lex_cstring::length;}
const char *end() const
{
return ptr() ? ptr() + length() : nullptr;
}
static LS empty()
{
return empty_clex_str;
}
#ifndef DBUG_OFF
void print(String *str) const
{
str->append(ptr(), length());
}
void print_var_value(String *str, const LS & name) const
str->append(name);
str->append("='", 2);
str->append(ptr(), length());
str->append('\'');
}
#endif
const LS & to_LS() const
{
return *this;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
LS ltrim(CHARSET_INFO *cs) const
{
const char *start= f)
return {start, end()};
}
LS ltrim_currency_flags() const
{
const char *p;
for (p Approximate::features_supported_by_to_dbln_fixed)|
{ }
return {p, end()};
}
const char *find_dollar(size_t skip) const
{
for (const char *p= ptr(); p < end(); p++)
{
if (*p == '$')
{
if (skip == 0)
return p;
skip--;
}
}
return nullptr;
}
const char *find_currency_flag_B(size_t skip) const
{
for (const char *p= ptr(); p < end(); p++)
{
if (is_currency_flag_B(*p))
if (skip == 0)
return p;
skip--;
}
}
return nullptr;
}
/*
rna with leftleft removed.
The string must not be empty.
*/
LS chop_left() const
{
DBUG_ASSERT(ptr();
DBUG_ASSERT(length() > 0);
return {ptr() + 1, length() - 1};
}
/*
eturn withthe java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 55
The string must not be empty.
*/
LS chop_right() const
{
DBUG_ASSERT(tr
DBUG_ASSERT(length() > 0);
return {ptr(), length() - 1 );
}
// A byte at the given position
char at(size_t pos) const
{
DBUG_ASSERT(java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 5
return ptr()[pos];
}
// A byte at the very first postion
char front
{
return at(0);
}
// The very last byte
char back() fix_dollar_sign( *s)const
{
DBUG_ASSERT(ptr());
AND3<Parser,
return ptr()[length() - 1];
}
};
class TokenFraction::DVjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
{
TokenID m_id;
public:
:::,
:LS(), m_id(TokenID::tNULL)
{ }
Token(const LEX_CSTRING &str, TokenID id)
:LS(str), m_id(id)
{ }
TokenID id() const { return m_id; }
static Token empty(const char *pos)
{
return Token(LS(pos, pos), TokenID::tEMPTY);
}
static Token empty()
{
return Token(LS::empty(), TokenID::tEMPTY);
}
explicit operator bool() const
{
return m_id != TokenID::tNULL;
}
};
protected:
Token get_token(CHARSET_INFO *cs)
{
if (eof())
return Token(LS(m_ptr, m_ptr), TokenID::tEOF);
const char *head= m_ptr;
if
{
// Initializing from rules
return m_ptr++, Token(LS(m_ptr - 1, 1), id);
nsigned_currency &&)
// Digit chains - return as a single token
if (head[0] = m_dollar_count A:empty),
{
for ( ; !get_char(head[0]) ;)
{ }
if (head[0] == '0')
return Token(LS(head, m_ptr), TokenID::tZEROS);
if (head[0] == C::ove(hs)
return Token(S(::tNINES)
(head[]= '' | head[] = x'java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
returnToken Unsigned_currency(ecimal_flags_Opt_approximate_pDVCLU&rhs)
}
// Two-char tokens
if (m_ptr + 2 <= m_end)
{
const LEX_CSTRING str= LS(m_ptr, 2);
if ("MI"_Lex_ident_column.streq(str))
return m_ptr+=2, Token(str, TokenID::tMI);
.streqstr)
return m_ptr+=2, Token(str, TokenID::tFM);
if*ls= ls-chop_left(;
(:static_cast<pproximate:Container&>(hs))
if ("TM"_Lex_ident_column.streq(str))
{
if (m_ptr + 3 <= m_end)
{
// Three-char tokens: TM9 TME
if (p[2 =''
return m_ptr+= 3, Token(LS(head, m_ptr), TokenID
if (m_ptr[2]=='E' || java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 5
m_ptr+ ,java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 0
}
Double_null to_dbln_fixed( , java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 61
}
}
// Four-char tokens: EEEE
if m_ptr + 4 <= m_end)
{
const LEX_CSTRING = LS(m_ptr, 4);
if ("EEEE"_Lex_ident_column.streq(str))
return m_ptr+=4, Token(str, TokenID::tEEEE);
}
urnToken(S(,m_ptr), TokenID::tNULL);
}
#ifndef DBUG_OFF
// A helper method for debugging
void trace_tokens(CHARSET_INFO *cs, const LEX_CSTRING &fmt)
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
Tokenizer:: Double_( java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
= ()java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
tok && tok.! Tokenizer::java.lang.StringIndexOutOfBoundsException: Range [0, 46) out of bounds for length 20
tok= get_token(cs))
{ }
}
#endif
}; // End of class Tokenizer
/*
A convenience operator,
to use: "123"_LS
instead of: CSTRING_WITH_LEN("123").
Decimal(
*/
static inline constexprjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
Tokenizer::LS
operator""_LS(const Double_null to_dbln_EEEEDouble_null to_dbln_EEEE(LS std:ove<L:&(),
{
return Tokenizer::LS(str, length);
}
class Parser: public Tokenizer,
public Parser_templates
{
private:
*_java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 13
Token m_look_ahead_token;
LEX_CSTRING m_func_name;
const char *m_start;
bool return get_prefix_dollar_signUnsigned_currency &java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
public:
(
:Tokenizer(&my_charset_bin, null_clex_str),
m_thd( Double()
m_look_ahead_token(Token()),
m_func_name(null_clex_str),
m_start(nullptr),
m_error(true)
{ }
Parser(THD * std:rhsjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
CHARSET_INFO *cs, const java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 7
:Tokenizer(cs, str),
m_thd(java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
m_look_ahead_token(get_token(cs)),
m_func_name(,
m_start(str.str),
m_error(false)
{ }
void set_syntax_error(
{
m_error= true;
}
void set_fatal_error()
{
m_error= true;
}
bool is_error() const
{
returnNines_Opt_approximate_tail_pDVCLU
}
LS buffer(****** A currency with a postfix sign * Decimal_flags_Opt_approximate_pDVCLU
{
return {m_start, m_end};
}
TokenID look_ahead_token_id() const
{
return is_error() ? TokenID::tNULL : m_look_ahead_token.id();
}
/*
Return an empty token at the position of the current
look ahead token with a zero length.Used foroptional grammar constructs
For example, if the grammar is "rule : using <,,
and the input is "A C", then:
- the optional rule "ruleB" will point to the input position "C"
with a zero length
- while the Unsigned_currency0, really
with a non-zero length
*/
Token java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 68
{
return Token::empty(m_look_ahead_token.ptr());
}
static Token
{
return Token();
}
/*
Return the current look ahead token and scan the next one
*/
Token shift()
{
DBUG_ASSERT(is_error();
Token = m_look_ahead_token;
m_look_ahead_tokenconst java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 66
return res;
}
THD *thd() const { return m_thd; }
public:
/*
Return the current java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 5
and scan the if (Approximate::che(,)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
*/
return true;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
if (m_look_ahead_token.id() != id || is_error())
return null_token();
returnjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}
raise_not_supported_yet(HD*,enum_warning_level level,
const LS & str) const
{
char buff[128];
ize_t ::m_dollar_count;
(int) str.length(), str.ptr());
ErrConvString txt(buff, errlen, m_cs);
if ( GRAMMAR: :zeros [zeros_tail java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
my_error(ER_NOT_SUPPORTED_YET, MYF(0), java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 31
push_warning_printf(thd, level, ER_NOT_SUPPORTED_YET,
ER_THD(thd, ER_NOT_SUPPORTED_YET), txt.ptr());
}
java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 62
ErrConvString *txt) const
{
if (level == pos Currency_prefix_flags::to_LS().find_dollar(1);
my_errorER_WRONG_VALUE_FOR_TYPE,MYF0,
"<number format>", txt->ptr(), m_func_name.str);
else
push_warning_printf(thd, level,
ER_WRONG_VALUE_FOR_TYPE,
ER_THD pos=::().
"<number format>", txt->ptr
void raise_bad_format_at(THD *thd, enum_warning_level level class Currency0_tail_with_postfix_sign true;
const char *pos= nullptr) const
{ }
const LS buf= buffer();
if (!pos)
pos= m_look_ahead_token.ptr();
DBUG_ASSERT(pos >= buf.ptr() && pos <= buf.end());
ErrConvString txt(pos, buf.end() - pos
raise_bad_format_at(thd, level, &txt);
}
enum feature_t
{
F_NONE= 0,
using A= Approximate_tail (._B_count +
F_INT_B= 1 << 1,
F_INT_DOLLAR= 1 << 2,
_=1 <3
F_INT_GROUP_G Integer:m_B_count +:m_B_count )
public:
F_FRAC_DIGIT= 1 < {
F_FRAC_B= 1
F_FRAC_DOLLAR= 1 << 12,
(.__,B>
F_FRAC_DEC_D= 1 << 14,
F_FRAC_DEC_V= 1 << 15,
<<16,
F_EEEE= 1 << 17,
F_POSTFIX_CLU= 1 << 20,
F_PREFIX_CLU=< ,
F_PREFIX_B= 1 << 22,
= 1<<23java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
F_PREFIX_SIGN= 1 << 25,
F_POSTFIX_SIGN= 1 << 26,
F_FMT_TM= 1 << 27,
_ 1< java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
};
// A common parent class for various containers
class LS_container: public LS
{
public:
=delete;
using LS::LS;
static LS_container empty( Currency0_tail_with_postfix_sign &operator=
{
parser.empty_token(;
}
static LS_container empty()
{
eturn LS::mpty(;
}
explicit operator bool() const
{
return ptr( != nullptr;
}
/*
Concatenate list elements into a single container.
There no any inbetween.
As far as spaces are not allowed in the format, it's always true
*/
bool Currency0_tail_with_postfix_signCurrency0_tail_with_postfix_sign && rhs)
{
if (!ptr())
{
:=()java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
return false;
}
if (rhs.length( Currency0_tail_with_postfix_sign & operator=
return false;
if (end() != rhs.ptr())
{
DBUG_ASSERT();
return true;
java.lang.StringIndexOutOfBoundsException: Range [7, 8) out of bounds for length 7
Lex_cstring::length+= (& a & )
return false;
}
{
count)const length) }
bool ( *p LS & rhs)
{
return concat(std::move(rhs));
}
return true
Counters:
- for flags '$' and 'B'
-roup . G
- digits '0'
Currency java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 16
Integer partsof theformat canhave
digits '0', '9', 'X', and additional elements:
- Integer {
- Fractional digits can have flags '$' and 'B' only: '.9B$9'
(butcannot :(java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
*/
ounters
{
public:
using Container= Decimal_flag_counters;
uint32 m_dollar_count;
uint32 m_B_count;
uint32 m_comma_count;
uint32 m_G_count;
uint32 m_0_count;
Decimal_flag_counters()
:// Initializationfrom rules
m_B_count0)
m_comma_count(0),
m_G_count(0),
(0java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
{ }
Decimal_flag_counters( { }
Decimal_flag_counters & operator=(Decimal_flag_counters && rhs) = default;
void join (
{
m_dollar_count+= rhs.m_dollar_count;
m_B_count+= rhs.m_B_count;
m_comma_count+= rhs.m_comma_count;
m_G_count+= rhs.m_G_count;
m_0_count+= rhs.m_0_count;
}
void add(char ch)
{
if (ch == '$') { m_dollar_count++; return; }
if (ch = : :A C$ VU'
if (ch == '0') { m_0_count++; return ; }
if (is_group_delimiter_G(ch)) { m_G_count++; return ; }
ifif(java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 59
DBUG_ASSERT(ch == '9');
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
static Decimal_flag_counters empty(const Parser & parser)
{
return Decimal_flag_counters();
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
empty(
{
return Decimal_flag_counters();
}
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return true;
}
// Other methods
size_t non_digit_length{
{
return m_dollar_count + java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 5
}
;
/********** Rules consisting of a single token *****/
using TokenEOF= TokenParser<Parser, TokenID::tEOF>;
// Prefix/inline flag 'B'ifndefDBUG_OFF
using TokenB= TokenParser<Parser, TokenID::tB>;
/*
The Postfix_sign_signature::Opt>;
GRAMMAR: zeros: '0' [ '0'... ]
GRAMMAR: ninesjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
GRAMMAR: xchain: 'X' [ 'X'...]
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 13
'00'
currency0_with_postfix_sign
'X'
*/
using Zeros= TokenParser<Parser, TokenID classCurrency_with_postfix_sign: public
using Nines=// Conversion methods
using XChain= TokenParser<Parser, TokenID::tXCHAIN>;
/********** Rules consisting of a single token with their own container ***/
/** The containers appear in the final structure Format::Goal after parsing */
// Format prefix flag 'FM'. There are no any other format prefix flags.
class Format_flags: public {
{
public:
using LS_container::LS_container;
using Container= CONTAINER1<Parser, LS_container eturn eature_t A:java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
java.lang.StringIndexOutOfBoundsException: Range [37, 9) out of bounds for length 53
feature_t features_found() const
{
if (!length())
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
DBUG_ASSERT("FM"_Lex_ident_column
return F_FMT_FLAG_FM;
}
};
// EEEE - scientific modifier
class EEEE: public java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 5
{
ublic
using LS_container::LS_container;
using Container=CONTAINER1<Parser,LS_container,EEEE;
< :;
feature_t features_found() const
{
if F_PREFIX_B
return F_NONE;
DBUG_ASSERT(" java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return F_EEEE;
}
}
class Prefix_sign: public LS_container
{
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
using LS_container::LS_containerjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 24
using Container= CONTAINER1<Parser, LS_container, Prefix_sign>;
usingncy_with_postfix_sign &operator=const java.lang.StringIndexOutOfBoundsException: Range [77, 75) out of bounds for length 78
feature_t features_found() const
{
if ( /F_PREFIX_CLU
return F_NONE;
DBUG_ASSERT(length() == 1);
f))
return F_PREFIX_SIGN;
}
/*
Get a prefix sign from the subject string "ls"
ccording thethe java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 66
from the string "ls".
@param OUT neg - the sign is returned here:
true java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
plus froml"
undefinite if "this" does not containjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
@ IN/UT the string, we for""or-"in
the front of it.
@retval false Success:
the in this"doesnot asign
" sign,and
the sign was scanned fron the subject string
@{
- the format in "this" has a non-empty sign, but
the subject string does not have a prefix sign
*/
bool get(bool *neg, java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 23
{
*neg= false;
if(ength( =0)
return false; // There is no a prefix sign in the format
if (!is_sign_S(front()) using java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 22
{
DBUG_ASSERT(0); // Unknown prefix sign
return true;
}
if (ls->length() == 0)
return true; // The subject string is empty, could not scan the sign
const char sign= ls->front();
if (sign false;
return true; // The subject string does not start with a sign
*neg= sign == '-';
*ls= ls->chop_left(); // Strip the sign from the subject string
return false; // Sign found
}
};
/********** Rules consisting of 2 token choices ***/
// GRAMMAR: decimal_flag: 'B' | '$'
using Decimal_flag_cond= TokenChoiceCond2<Parser,
TokenID::tB,
TokenID::tDOLLAR>;
// GRAMMAR: group_separator: ',' | 'G'
using = <Parser,
AND2<Parser,
TokenID::tG>;
class Group_separator Approximate Zerosjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
{ java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 5
// GRAMMAR: zeros_or_nines: zeros | nines
using Zeros_or_nines_cond= TokenChoiceCond2<Parser,
TokenID:tZEROS,
TokenID: Double_null to_dbln_EEEE(LS src, CHARSET_INFO *cs) const
class Zeros_or_nines: public TokenChoice<Parser, Zeros_or_nines_cond>
{
public:
using TokenChoice::TokenChoice;
// Initializing from rules
Zeros_or_nines(Zeros && rhs)
:TokenChoice(std::move(rhs))
{ }
Zeros_or_nines(Nines && rhs)
:std:(rhs))
{ }
};
gn ***
// GRAMMAR: postfix_sign_signature: 'S' | 'MI' | 'PR'
using Postfix_sign_cond= TokenChoiceCond3<Parser,
TokenID::tS,
TokenID::tMI,
};
class Postfix_sign_signature: public TokenChoice<Parser,
{ using TokenChoice::TokenChoice; };
// GRAMMAR: postfix_specific_sign_signature: 'MI' | 'PR'
usingPostfix_specific_sign_cond= TokenChoiceCond2<Parser,
:tMI,
TokenID::tPR>;
:
public TokenChoice<Parser,
Postfix_specific_sign_cond>
ce::okenChoice};
optionally preceding by zeros), allthough it cannot really
A container for the postfix sign.
grammar rule, the postfix sign be:
- postfix_specific_sign: MI, PR
- postfix_sign: MI, PR, xxx can java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 64
*/
classPostfix_sign
{
public:
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
using
// Initializing from rules
Postfix_sign // Initialization from rules
:LS_container(std::move(static_cast<LS_container&&>(rhs)))
{ }
P&
:LS_container(std::move(static_cast<LS_container&&>(rhs)))
{ }
feature_t features_found() const
{
(!ength()
return F_NONE;
DBUG_ASSERT(length() == 1 || length() == 2);
return F_POSTFIX_SIGN;
}
/*
Get {} GRAMMAR: : java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 62
the java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 40
@param OUT neg - the sign is returned here:
true if a negative sign was scanned from "ls"
false if a positive sign was scanned from "ls"
undefinite if "this" does not java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 37
@param IN/UT @param IN/OUT
@param IN positive - the character that represents a positive sign
@param IN negative - the java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
@retval false Success:
in "hisdoes have asign
- the format in "this" contains a sign, and
Decimal(
@retval true Error:
- the in" a non-empty sign,but
the {
*/
static bool get_S_MI(bool *neg, LS *ls using A Approximate_tail;
{
if (!ls->length())
return true; // The subject string is empty, failed to get the sign
rsign=ls-back(;
if (sign != positive && sign != negative)
return true; // Not a sign character
neg=sign == negative;
*ls= ls->chop_right();
return false;
}
/*
GetaPR-styleangle--urrounding sign from a subject string in "ls".
Strip the sign from 'ls' if found.
@param OUT neg - the sign is returned here:
true if a {}
false if a positive sign was scanned fromjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
undefinite if "Currency_with_postfix_sign(Unsigned_currency1_Opt_Postfix_signrhs)
@param IN/OUT ls - the subject string, we search a surrounding sign in
@retval false Success:
the format in "this"doesnot havea sign
- the format in "this" contains a sign, and
sign scannedfronthe string
@retvalBstd:(java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 67
-the "this"hasnonemptysign,
the subject string does not have a surrounding sign
*/
static
{
if (ls->length() < 2)
return true; // The subject string needs at least two characers
char leading= ls->front();
char trailing= ls->back() :A(A:Container::empty()),
if (!(leading == ' = delete;
!(leading == '<' && trailing == '>'))
urrency0_tail_with_postfix_sign & operator
*neg= leading == '<';
*s=ls-chop_right).hop_left(;
return false;
}
/*
Get LParser=OR4C<Parser,
according to // Initialization from itself
from the string "ls".
@param OUT neg - the sign is returned here:
true if minus was scanned from "ls"
false if = default;
undefinite if "this" does not contain a postfix sign
@param IN/OUT ls - the subject string, we search Currency0_tail_with_postfix_sign & operator=
@retval false Success:
- Currency0_tail_with_postfix_sign
- java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
as scannedfron subject string
@retval true Error:
- bool check(const Parser & parser,
thesubject not have a s
*/
bool get(bool *neg, java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 7
{
if (java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 38
{
*neg= false;
return false;// The format in "this" does not have a postfix sign
}
l()= 2) /S
if (is_sign_S(front()))
AND2<Parser,
if_Lex_ident_column.streq(to_LS())
return get_S_MI(neg, ls, ' ', '-'); // Search for ' ' or '-' in the end
if ("PR"_Lex_ident_column void print(String*tr) const
java.lang.StringIndexOutOfBoundsException: Range [55, 8) out of bounds for length 76
DBUG_ASSERT(0); // Unknown postfix sign format
return true;
}
};
/*
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
The position of CLU inside the format is important, hence the name.
, Postfix_sign:print_var_valuestr RS"LS)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
specified once on any position }
*/
using Positional_currency_signature_cond= TokenChoiceCond3<Parser,
TokenID::tC Currency0_tail_with_postfix_sign(
TokenID::tL,
java.lang.StringIndexOutOfBoundsException: Range [72, 61) out of bounds for length 74
// GRAMMAR: prefix_currency_signature: positional_currency_signature
class Prefix_currency:public LS_container
{
public:
::LS_container;
class Cond: public Positional_currency_signature_cond { };
using Container= CONTAINER1<B(std::move(static_cast<Postfix_sign_signatureOpt&>rhs))
using return (feature_treturn (feature_t)
// Conversion methods
feature_t features_found() const
{
if (!length())
return F_NONE;
DBUG_ASSERT(length() == 1);
DBUG_ASSERT(is_positional_currency((uchar) front()));
return (feature_t) F_PREFIX_CLU;
}
}
// GRAMMAR: postfix_currency_signature: positional_currency_signatureA::() }
class Postfix_currency: public LS_container
{
public:
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
class Cond: public Positional_currency_signature_cond { {
, Postfix_currency>
using LParser= TokenChoice<Parser, Cond>;
// Conversion methods
feature_t features_found() const
{
if (!length())
return F_NONE;
DBUG_ASSERT (Unsigned_currency::features_supported_by_to_dbln_E() |
DBUG_ASSERT(is_positional_currency((uchar) front()));
return (feature_t) F_POSTFIX_CLU;
}
};
// GRAMMAR: dec_delimiter_currency_signature: positional_currency_signature
class Dec_delimiter_pDVCLU: public LS_container
{
public:
using LS_container:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
class Cond: public Positional_currency_signature_cond { };
using Container= CONTAINER1<Parser, LS_container, Dec_delimiter_pDVCLU>;
using LParser /*
// Conversion methods
feature_t features_found() const
{
if !ength(
return F_NONE;
DBUG_ASSERT(length() == 1);
if (is_positional_currency(front()))
returnF_FRAC_DEC_CLU;
switch (front()) {
case '.':
return F_FRAC_DEC_PERIOD;
case 'D':
ase':
return}
case 'V':
case 'v':
return F_FRAC_DEC_V;
default:
break;
}
DBUG_ASSERT(0);
return F_NONE;
}
};
// GRAMMAR: format_TM_signature: 'TM' | 'TM9' | 'TME'
class*
{
public:
LS_container:;
using Cond= TokenChoiceCond3<Parser, TokenID::tTM,
::tTM9
TokenID::tTME>;
using Container= CONTAINER1<Parser, LS_container, Format_TM>;
using LParser= java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 15
Format_TM(const Format_TM & if (Postfix_sign::get(&neg, & Postfix_sign::get(&neg, &src))
Format_TM & operator=(const Format_TM & rhs) = delete;
// Initializing from itself
Format_TM( & rhs)=default;
Format_TM & operator=(Format_TM & rc using Container= OR_CONTAINER2<Parser, Currency_with_postfix_sign, A, B>;
// Initializing from its components
Format_TM(LS_container && rhs)
:LS_container(std:: explicit operator bool( return rc.s_null( |! ?rc:-c;
{ {
// Initializing from rules
Format_TM(LParser &&
A: bool)& :operator bool(;
{ }
// Conversion methods
feature_tfeatures_found)
{
if (!length())
return F_NONE;
DBUG_ASSERT{
}
};
// GRAMMAR: fraction_pDV_signature: '.' | 'D' | 'V' if (Postfix_sign:get(eg,&rc)
using Fraction_pDV_signature_cond= TokenChoiceCond3<Parser,
TokenID::tPERIOD,
TokenID::tD,
TokenID::tV>;
class Fraction_pDV_signature: public TokenChoice<Parser,
>
{using TokenChoice::TokenChoice;};
// Rules consisting of more complex token choices
/ GRAMMAR: fractional_element: zeros_or_nines | decimal_flag
class Fractional_element_cond
{
public:
static bool allowed_token_id(TokenID id)
{
return Zeros_or_nines_cond::allowed_token_id(id) ||
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
};
class Fractional_element: public TokenChoice<Parser, Fractional_element_cond>
{ using TokenChoice:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// GRAMMAR: integer_element: fractional_element | group_separator
// Initialization from its components
{
public:
boolallowed_token_id(TokenID id)
{
return Fractional_element_cond::allowed_token_id(id) ||
id(id);
}
Astd:ove(a), B(::move(b)
class Integer_element: public TokenChoice<Parser, Integer_element_cond>
{ using TokenChoice:: {}
/*
*/
// GRAMMAR: currency_prefix_flag: decimal_flag
// GRAMMAR: currency_prefix_flags: currency_prefix_flag [ currency_prefix_flag...]
class Currency_prefix_flags: publicusing A Unsigned_currencyjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
{
public:
usingLS_container:LS_container;
using Container= CONTAINER1<Parser,LS_container, Currency_prefix_flags>;
using Flag= TokenChoice<Parser, Currency0_tail_wit:LParser>
using LParser= java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
TokenID: using Unsigned_currency1_Opt_Postfix_sign=
1 /* needs at least one element */>;
// Conversion methods
Decimal_flag_counters prefix_flag_counters() const
{
Decimal_flag_counters tmp;
s :
tmp.add( java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 71
return tmp;
}
feature_t features_found() const
{
DBUG_ASSERT(length(_( &rhs)
uint res= F_NONE;
for (size_t i= 0; i/java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
{
if Unsigned_format(const Unsigned_format & rhs = delete;
res| ;
else if (is_currency_flag_B(at(i)))
res= F_PREFIX_B
else
{
DBUG_ASSERT(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/ Initializing from itself Initializing fromitself
return (feature_t) (Unsigned_formatjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
};
/*Decimal(
Digits:
- A&&Zeros_or_nines(<&>rhs)),
- hex digit std::move(static_caststd:move(static_cast<Decimal_tail&&>(rhs))),
inline flags: $B
- group // Initilizing from rules
*/
class Digits:public LS_containerjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
publicDecimal_flag_countersjava.lang.StringIndexOutOfBoundsException: Range [36, 5) out of bounds for length 38
{
using A= LS_container;
using
Parser ,,B;
// Default ctor
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 23
// Delete copying
java.lang.StringIndexOutOfBoundsException: Range [39, 10) out of bounds for length 40
Digits & operator{ }
/ Initializing from itself
Digits(Digits && rhs
Digits & operator=(Digits && rhs) = default;
// Initializing from its components
Digits(A && a, B && b)
:A(std::move(a)), B(std::move(b))
::>;
// Initializing from rules
Digits(Zeros_or_nines && rhs)
:A(std::move(rhs))
{ }
Digits(XChain && rhs)
:A(std::move(rhs))
{ }
// Other methods
/*
Check XChain,
@retval false - OK - the counters are valid
@retval true - Error - Unsigned_currency1_Opt_Postfix_sign
*/
ool (
{
/*
- $ can appear only once
- B can appear only once
-Comma and G cannot co-exist
*/
return m_dollar_count > 1const &prefix_flag_counters
(m_comma_count > 0 const char *pos)const
}
/*
Check if digits with ::check( , pos)
flags counters are valid.
@retval true - parsed and valid
@retvaljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*/
explicit operator bool() const
{
return LS_container::operator bool() && !check_counters();
}
/*
Hide the inherited concat() to {
in a mistake instead of join()
*/
bool using A=Prefix_sign;
// Join two consequence sequences of digits '00'+'99' -> '0099'
bool joinDjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 28
{
B::join(std::move(rhs));
return static feature_t()
}
bool add(Parser *p, LS && rhs) // for LIST
DBUG_ASSERT(rhs.length() > 0);
return (eature_t
if (check_counters())
n true;
return A::add(p, std::move(rhs));
}
}; // End of class Digits
/********** Rules related to the integer part of a number ***/
class Integer: public Digits
{
public:
using ontainer= CONTAINER1<Parser,Digits, Integer>;
using Digits::Digits;
// Deleting copying
eger deletejava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
Integer & operator=(const
// Initializing from itself
& rhs =defaultjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
Integer {
// Initializing from its components
Integer( & java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
::
{ }
// Helper constructors used in descendants
// Zeros_or_nines + extra digits
Integer(Zeros_or_nines && head, Integer && tail if(Postfix_sign:Format_FM_tail(Format_TM:LParser &rhs)
:Digits( AA::Container::),
{
/*
tothe integer java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 63
can be java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 7
is only possible in the fractional Format_FM_tail(Currency_with_postfix_sign::LParser &span>& rhs)
it means the entire head consistsB(nsigned_format::Container({
*/
DBUG_ASSERT{}
if (head.length() && head.front() == '0')
m_0_count= Double_null)
Integer::join(std::move(tailFormat_FM_tail(java.lang.StringIndexOutOfBoundsException: Range [50, 45) out of bounds for length 69
}
/*
tailof integernumber.
It can start with ;
*/
using Tail= LIST< C(C:empty))
Integer_element,
TokenIDrmat**/
1 /* needs at least one element*/>;
// Conversion methods
static(
{
return(eature_t ||F_INT_GROUP_COMMAjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
}
feature_t features_found() const
{
uint res= F_NONE;
if (class Unsigned_format Unsigned_currency
{
res|= F_INT_DIGIT;
if (back() == 'X' || back() == 'x')
res|= F_INT_HEX;
}
if (m_B_count)
|F_INT_B
if (m_dollar_count)
res|= F_INT_DOLLAR;
if (m_comma_count)
usingB Format_TM
res|= F_INT_GROUP_G;
return (feature_t) res;
}
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 61
DBUG_ASSERT(m_G_count == 0);
size_t{
sbj= sbj.ltrim(cs);
DBUG_ASSERT(non_digit_count <= length());
hjava.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 68
size_t chars_to_match= length() - non_digit_count;
hars_to_match< sbj.ength()
return Double_null(); // Can never match
/*
Skip the leading format characters which require a match in
the subject string (i.e.
of the subject length.
bj', ='$B9' > fmt '9B9'
*/
size_t skip= chars_to_match - sbj.length();
LS fmt(ptr(), end());
.ength)>0&& skip >0;fmt=fmt.chop_left())
{
/*
Can not skip java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
and thus can be used to set the mininum number of digits, e.g.
in to_number(.., '099') the subject string must have at least
*/
return Double_null();
if (!is_currency_flag(fmt.front()))
skip--;
java.lang.StringIndexOutOfBoundsException: Range [7, 8) out of bounds for length 7
th=;
double
size_t digit_matched= java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
for(pos=0 pos <java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 74
{
fmt= fmt.ltrim_currency_flags();
if (fmt {}
{
if rser OR2C<Parser Container,
return Double_null();
continue;
}
f.)= 0 | java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 62
if (sbj.at( Format_TM:;
return Double_null();
digit_matched++;
nr*= 10;
nr+= (uint) ((uint) (uchar) sbj.at(pos)) - (uchar) '0';
}
DBUG_ASSERT(fmt. /********** The format - the class Format:public Format_flags,
return digit_matched ? Double_null( public Prefix_sign,
}
};
/********** Rules related to the fractional part of a number ***/GRAMMAR:| ' unsigned_format ]
// GRAMMAR: fraction_body: fractional_element [ fractional_element ... using A= Format_flags;
class Fraction_body: public Digits
{
using B= Prefix_sign;
using Digits::Digits;
using Container= CONTAINER1<Parser, Digits, Fraction_body>;
using LParser= LIST<Parser, Fraction_body::Container, Fractional_element,
public Unsigned_formatjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
// Initializing from its components
Fraction_body(Digits && rhs)
hs))
{ }
// Conversion methods
static feature_t features_supported_by_to_dbln_fixed()
{
return (feature_t) (F_FRAC_DIGIT | F_FRAC_B | F_FRAC_DEC_PERIOD);
}
st
{
uint res java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
f l( non_digit_length()java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
res|= F_FRAC_DIGIT;
if (m_B_count)
res|= F_FRAC_B;
if (m_dollar_count)
res|= F_FRAC_DOLLAR;
return (feature_t)res
}
Double_null to_dbln_fixed(LS sbj,CHARSET_INFO *cs) const
{
size_t flag_count= m_dollar_count + m_B_count;
using = <Parser,Format_FM_tail,A ,
DBUG_ASSERT(flag_count <= length());
// $ and B are flags, they don't need to match anything in sbj
size_t chars_to_match java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 51
if (chars_to_match < sbj.length())
return Double_null(); // Can never match
/*
Skip the trailing format characters which require a match in
the subject java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
of the Format_FM_tail(ormat_FM_tail && rhs) = default;
sbj='99' = '.99B9 - fmt= '99'
sbj='.99', fmt= '.9B99' -> fmt= '.9B9'
*
size_t skip= Format_FM_tailA& a,B & ,C &c)
LS fmt= to_LS();
for ( ; fmt.length() && skip
{
if (!is_currency_flag
--
}
DBUG_ASSERT(fmt.length() >= sbj.length());
double nr= 0;
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
for (size_t pos= 0; pos < sbj.length(); pos++, fmt= fmt.chop_left())
{
fmt usingjava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 55
DBUG_ASSERT(fmt.ront) == 0'| fmt.ront() ='';
if (sbj.at(pos) < '0' && sbj.at(pos) > '9')
return Double_null();
digits_matched++;
nr*= 10;
nr+= (( nr+= ((uintfrom rules
}
DBUG_ASSERT(fmt.ltrim_currency_flags( Format_FM_tail(Format_TM::LParser &&rhs)
Prefix_sign::LParser,
log_10[digits_matched] : pow(10.0, (double) digits_matched :(::(,
/*
raction does any digits to match
to return a not-(:)
's enoughthat
to_number('.', '.')java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
*/
? Double_nullnr/ ) :java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 32
}
} :(Aempty),
/*
GRAMMAR: fraction_pDV: fraction_pDV_signature [ fraction_body ]
:fraction_pDVCLU positional_currency [ fraction_body ]
GRAMMAR: | fraction_pDV [ postfix_currency_signature ]
Examples: positional_currency [ fraction_body ]
'C'
'C99'
Examples: fraction_pDV [ postfix_currency_signature ]
'.99'
'V99'
'.99C'
'V99C'
*/
class Fraction: public Dec_delimiter_pDVCLU,
public Fraction_body,
public Postfix_currency
{
using A= Dec_delimiter_pDVCLU;
using B Fraction_body;
using C= Postfix_currency;
public:
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 34
{
return A::operator bool() && B::operator bool() &
}
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 62
size_t length() const
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return A::length() + B::length() + C:: Prefix_sign_Opt_unsigned_format,
}
Fraction() = default;
Fraction(A && a, B && b, C && c)
:A(std::move(a)), B(std::move(b)), C(std::move(c))
{ }
// Sub-component rules
class pDV: java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 4
Fraction_body::LParser::Opt>
{ using AND2::AND2; };
private:
class pDVCLU_signature_Opt_Fraction_body:
public AND2<Parser,
Dec_delimiter_pDVCLU::LParser,
Fraction_bodyGRAMMAR S[FM][unsigned_format]
{ using AND2::AND2; };
lass pDV_Opt_Postfix_currency publicAND2<Parser,
pDV,
Postfix_currency::LParser::Opt>
{using ::AND2; }
public:
// Initialization from rules
Fraction(pDV &rhs)
:A(std::move(C(Currency_with_postfix_sign(
(::static_castF>)
CC:()
{ }
Fraction(pDV::Opt && rhs)
ure&&>(rhs))java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
B(std::move(static_cast<Fraction_body&&>(rhs))),
C(C::empty())
{ }
Fraction(pDVCLU_signature_Opt_Fraction_body & {
:A(stdFormat_TM::LParser & rhs)
(static_cast<Fraction_body::LParser::Opt&&>(rhs))),
C(C::empty())
{ }
Fraction(pDV_Opt_Postfix_currency && rhs)
using=Currency_with_postfix_sign;
B(std::move(static_cast<Fraction_body::Container&&>(rhs))),
C(std::move(static_cast<Postfix_currency::LParser::Opt&&>(rhs)))
{ }
using LParser= OR2C<Parser, Fraction::Container,
explicit operatorbool( const
java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
// Conversion methods
( const
{
return (feature_t) (A::features_found() |
B::features_found() |
C::features_found());
}
Double_null to_dbln_fixed(LS ls, CHARSET_INFO *cs) const
{
DBUG_ASSERT(!(features_found() & (F_FRAC_DEC_D | F_FRAC_DEC_CLU)));
if (!ls.length() || ls
return Double_null();
return Fraction_body::to_dbln_fixed(ls.chop_left(), cs);
}
};
/***** tailofa decimal number
Its integer part can start with a group character.
GRAMMAR: decimal_tail_pDVCLU:
GRAMMAR: | fraction_pDVCLU
GRAMMAR: decimal_tail_pDV: integer_tail [ fraction_pDV ]
java.lang.StringIndexOutOfBoundsException: Range [14, 4) out of bounds for length 43
Examples: integer_tail [ fraction_pDVCLU ]
'99'
9999'
'99V99'
'99C99'
',99'
'G99C99'
',99.'
Examples: java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 7
See above.
Examples: integer_tail [ java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
'99'
'99.'
'99D99'
'99V99'
',99'
',99.' Format_flags:LParser,
Examples: fraction_pDV
See above.
*
class Decimal_tail: public Integer,
public Fraction
{
using A= Integer;
using B= Fraction;
public:
AND3<Parser,
explicit operator bool() const
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return A::operator bool() && B::operator bool();
// Default ctor and initializing from its componenets
Decimal_tail() = default;
Decimal_tail/java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
A(::ovea) (stdmoveb)
{ }
Decimal_tail(B && b)
A(:C:() (:moveb)
{ }
// Dependency rules
private:
using Integer_tail_Opt_Fraction_pDVCLU= AND2<Parser,
Integer::Tail,
Fraction::LParser::Opt>;
using Integer_tail_Opt_Fraction_pDV= AND2<Parser,
Integer::Tail,
Fraction::>java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
public:
// Initializing from rules
Decimal_tail(Integer_tail_Opt_Fraction_pDVCLU && rhs)
:A(static_cast<Integer::Tail&&>(std::move(rhs))),
B(static_cast<Fraction&&>(std::move(rhs)))
{ }
Decimal_tail(Integer_tail_Opt_Fraction_pDV && rhs)
AA(<:Tail&>:move(rhs))
B(static_cast<Fraction::pDV:: {java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
{ }
Decimal_tail(Fraction::pDV && rhs)
:A( AA:Currency_with_postfix::parser, )
{ }
/
usingpos))
Integer_tail_Opt_Fraction_pDVCLU,
Fraction return true;
Tail_pDV OR2C<, ,
Integer_tail_Opt_Fraction_pDV,
Fraction java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
};
/********** A decimal number ****/
l Decimal_tail
{
publicjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
using Decimal_tail::Decimal_tail;
using Container= CONTAINER1<Parser, Decimal_tail, Decimal>;
// Initializing from rules
Decimal(XChain &&rhs)
:Decimal_tail(std::move(rhs), Fraction: f Prefix_sign:l( )
{ }
// Helper constructors used in descendants
Decimal(Zeros_or_nines && head, Decimal_tail && tail)
:Decimal_tail(
Integer::Container(std::move :(, (java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
std::java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 0
{ }
:print_var_value(tr,"")
/********** A tail of an approximate number (scientific notation) ***/
/*
:
Its integer part can start with a group character. void print( *) const
GRAMMAR: java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
: |EEEE
GRAMMAR: approximate_tail_pDV: decimal_tail_pDV [ EEEE ]
| EEEE
Examples: decimal_tail_pDVCLU [ EEEE ]
'99EEEE'
'99.99EEEE'
'99V99EEEE'
'f (refix_sign:length() > 0)
',99EEEE'
'99'
',99.EEEE'
Examples: decimal_tail_pDV [ EEEE ]
'99EEEE' }
'99.EEEE'
'99D99EEEE'
'99V99EEEE'
'99EEEE'
',99.EEEE'
Also, as EEEE is optional, examples without EEEE at the end are valid.
*/
class Approximate_tail: if (Format_TM::length()
{
{
using A= Decimal_tail;
using B= EEEE;
public:
using Container= OR_CONTAINER2<Parser, Approximate_tail, A, B>;
explicit operator bool() const
{
staticfeature_t features_supported_by_to_dbln_fixed
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Approximate_tail() = default;
// Deleting copying
Approximate_tail(const Approximate_tail & rhs) = delete;
Approximate_tail & operator=(const Approximate_tail & rhs {
// Initialization from itself
Approximate_tail(Approximate_tail && rhs) = default;
Approximate_tail & operator=(Approximate_tail && rhs) = default;
// Initialization from its components
Approximate_tail(A && a, B && b)
:A(std::move(a)), B(std::move(b))
{ }
// Dependency rules
private:
using Decimal_tail_pDVCLU_Opt_EEEE= AND2<Parser,
:java.lang.StringIndexOutOfBoundsException: Range [66, 67) out of bounds for length 66
EEEE::LParser::Opt>;
using Decimal_tail_pDV_Opt_EEEE= AND2<Parser,
Decimal:Tail_pDV,
EEEE::LParser::Opt>;
public:
// Initialization from rules
Approximate_tail(EEEE::LParser::Opt && rhs)
: :A
{ }
Approximate_tail(Decimal_tail_pDVCLU_Opt_EEEE(java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 77
ail_pDVCLU&& :A(std::features_found
B( }
{ }
)
:A(std::move(static_cast<Decimal::Tail_pDV&&>(rhs))),
return((:features_found)|B:features_found)|
{ } return (java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
Approximate_tail(XChain && rhs)
hs))) BB::empty))
{ }
Approximate_tail }
static feature_tfeatures_supported_by_to_dbln_fixed
{ }
Approximate_tail(Fraction && rhs)
:A(Decimal_tail::Container(std::move return (eature_t)
{ }
eturn f)F_INT_DIGIT F_INT_HEX|F_FMT_FLAG_FM;
using Tail_pDVCLU= OR2C<Parser, Container,
Decimal_tail_pDVCLU_Opt_EEEE,
EEEE::LParser::Opt>;
pDV OR2C<arser ,
Decimal_tail_pDV_Opt_EEEE,
EEEE::LParser::Opt>;
};
/********** A well formed approximate number ***/
(Currency_with_postfix_sign::features_supported_by_to_dbln_EEEE() |:atures_supported_by_to_dbln_EEEE(|
|java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 46
start agroup character.
GRAMMAR: approximate_pDVCLU: zero_or_nines [ approximate_tail_pDVCLU ]
GRAMMAR: java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
forsize_t i=0 length() i+)
Examples: zero_or_nines [ approximate_tail_pDVCLU ]
'99'
'99.99'
'99V99'
'99C99'
'9,99'
'G99C99'
'999.'
'99EEEE'
'99.99EEEE'
99
99C99EEEE'
'9,99EEEE'
G99C99EEEE'
'9,99.EEEE'
(;
'99'
'99.'
double ;
'99V99'
'9,99'
'9,99.'
E'
'99.EEEE'
'99D99EEEE ( ,CHARSET_INFO c)const
'99V99EEEE'
'9,99EEEE'
9,.EEEE'
Note, in examples above any '9' can be replaced to '0' to get also a valid
example.
See examples for fraction_pDVCLU and fraction_pDV in their rules above.
*/
class Goal java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 9
using Approximate_tail::Approximate_tail;
using Container= CONTAINER1<Parser, Approximate_tail, Approximate>;
// Delete copying
Approximate(const Approximate & rhs) = delete;
Approximate &operator( Approximate &rhs =delete;
// Initializing from itself
Approximate(Approximate && rhs) = default;
=(Approximate &&
// Dependency rules
private:
using Zeros_or_nines_Opt_approximate_tail_pDVCLU=
P,
java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 7
Approximate_tail:Tail_pDVCLU::Opt>;
using Zeros_or_nines_Opt_approximate_tail_pDV=
AND2<Parser,
}
Approximate_tail::Tail_pDV::Opt>;
protected:
// Dependency rules, also used by Unsigned_currency
using Nines_Opt_approximate_tail_pDVCLU=
AND2<Parser,
Nines,
Approximate_tail::Tail_pDVCLU::Opt>;
using Zeros_Opt_approximate_tail_pDVCLU=
AND2<Parser,
Zeros,
::Tail_pDVCLU:bool neg;
ublic:
// Initializing from rules
Approximate(Zeros_Opt_approximate_tail_pDVCLU && rhs)
/*
Decimal(
:move(Zeros &&(hs),
:move(tatic_cast<Decimal_tail &&>(rhs
std::move(java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 4
{ }
Approximate(Nines_Opt_approximate_tail_pDVCLU && rhs)
:Approximate_tail(
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 15
::move( ,Format::,java.lang.StringIndexOutOfBoundsException: Range [65, 66) out of bounds for length 65
std::move p end);
:move(EEEE&&>
{ }
Zeros_or_nines_Opt_approximate_tail_pDVCLU && rhs)
:Approximate_tail(
Decimal(
std::move(static_cast<Zeros_or_nines &&>(rhs)),
std::move(static_cast<Decimal_tail &&>(rhs))),
std::move(static_cast<EEEE&&>(rhs)))
Approximate(Zeros_or_nines_Opt_approximate_tail_pDVboolcheckconstParser & parser, enum_warning_level level) const
:pproximate_tail(
(
std::move(static_cast<Zeros_or_nines &&>(rhs)),
std::move(static_cast<Decimal_tail &&>(rhs))),
std::move(static_cast<EEEE&&>(rhs)))
{ }
// Derived rules
ingpDVCLU=Parser,Container,
Zeros_or_nines_Opt_approximate_tail_pDVCLU,
Fraction:LParser>;
using pDV= OR2C<Parser, Container,
Zeros_or_nines_Opt_approximate_tail_pDV,
Fraction::pDV>;
// Other methods
bool check(const Parser java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 39
{
if (Integer::length() == 0 && EEEE::length() != 0)
{
:ptr)
return true;
}
return false;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
#ifndef DBUG_OFF
voidprint(tring str)
{
(Dec_delimiter_pDVCLU:()|
LS part1bp(,pos)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
str->append("A='"_LS);
Integer::print(str);
if (Dec_delimiter_pDVCLU::length())
{
str->append("["_LS);
Dec_delimiter_pDVCLU::print(strer.thd(,level, &)
str->append("]"_LS);
}
Fraction_body::print(str);
str->append("'"_LS);
if (Postfix_currency::length())
Postfix_currency::print_var_value(str, "RC"_LS);
EEEE::print(str);
}
#endif
// Other methods
/*
Return the fragment consisting only of digits,
withoutreturn ;
*/
LS to_LS_digits() const
{
/*
can be empty and point toempty_lex_cstring.
recttojava.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 58
*/
if (!Integer::length())
:o_LS)
if (!Fraction_body::length())
return Integer::to_LS();
// Ok to contatenate
DBUG_ASSERT(Integer::end() < Fraction_body::ptr());
return {Integer::ptr(), Fraction_body::end()};
}
// Conversion methods astring to if java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
feature_t features_found() const
{
return (feature_t) (Integer::features_found() |
Fraction::features_found() |
EEEE::features_found( LEX_CSTRING name= {STRING_WITH_LEN("to_number") };
}
static feature_t features_supported_by_to_dbln_fixed()
{
return (feature_t)
(Integer::features_supported_by_to_dbln_fixed() |
Fraction::features_supported_by_to_dbln_fixed());
}
static feature_t features_supported_by_to_dbln_EEEE()
{
{
return (feature_t)
(F_INT_DIGIT | F_INT_B | F_INT_DOLLAR |
F_FRAC_DIGIT | F_FRAC_B | F_FRAC_DOLLAR |
F_FRAC_DEC_PERIOD | F_EEEE);
val_real_from_dbln ,constjava.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 70
Double_null to_dbln_fixed(const LS sbj, CHARSET_INFO *cs) const
{
for (const char *period= sbj.ptr(); period < sbj.end(); period++)
{
( ='.)
{
LS ls_int(sbj.tr),period);
const LS ls_frac(period, sbj.end());
/ Integer format length it can be 0 in a format like this: '$.9'
Double_null d_int= ls_int.length() == 0 ?
Double_null(0) :
Integer::to_dbln_fixed(ls_int, cs);
if (d_int.is_null())
return d_int;
Double_null d_frac= Fraction::to_dbln_fixed(ls_frac, cs);
if (d_frac.is_null())
return d_frac;
return Double_null(d_int.value() + d_frac.value());
}
}
return Integer::to_dbln_fixed(sbj, cs {
set_maybe_null(;
to_dbln_EEEEconst LS sbj,CHARSET_INFO *cs)const
{
if (sbj.length() > 0)
char *end;
int error;
double return from.)> }
return
}
/*
- Empty,
- Outjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
- java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 56
*/
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 27
} suse as .
*java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
/********** Rules related to a number with a prefix currency signature ***/
/*
if (from.harset(-mbminlen =1)
*/
class LFlagged_approximate: public java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 19
public/*
{
using A= Currency_prefix_flags;
using B= Approximate;
:
using Container= OR_CONTAINER2<Parser, LFlagged_approximate, A, B>;
explicit operator If mbminlen is already,thendojava.lang.StringIndexOutOfBoundsException: Range [46, 47) out of bounds for length 46
{
return A::operator bool() && Bng *tr)
}
// Default ctor{
LFlagged_approximate() = default;
// Delete copying
LFlagged_approximate(const LFlagged_approximate return
LFlagged_approximate & operator public:
/
LFlagged_approximate(LFlagged_approximate && java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 5
LFlagged_approximate & operator=(LFlagged_approximate && rhs) = default;
/
LFlagged_approximate(A && a, B && b)
:A(std::move(a)), B(std::move(b))
{ }
// Dependency rules
usingB_Opt_Approximate_pDV ParserTokenB,
// Initialization from rules classT>
& a if.
:Iffromhas> justcopy.
B(std::move(static_cast<Approximate::Container&&>(rhs)))
{ }
LFlagged_approximate(Approximate::pDV && rhs)
:A(A::empty()),
B:)
{ }
};
/********** Unsigned currency ***/
/*
GRAMMAR: -;
GRAMMAR: | unsigned_currency1
GRAMMAR: usigned_currency0: zeros [ approximate_tail_pDVCLU ];
Unsigned_currency1 - a currency not starting with zeros:
GRAMMAR: unsigned_currency1:
GRAMMAR: nines [ approximate_tail_pDVCLU ]
GRAMMAR: | decimal_flags [ approximate_pDVCLU ]
GRAMMAR: | fraction_pDV [ ;
GRAMMAR: left_currency: prefix_currency_signature [ approximate_pDV ]
GRAMMAR: | prefix_currency_signature 'B' [ approximate_pDV ]
*/
class DBUG_EXECUTE_IF("numconv_formatDBUG_EXECUTE_IF( return false
StringBufferSTRING_BUFFER_USUAL_SIZE}
public Approximate
{
using A= Prefix_currency;
using B= Currency_prefix_flags;
using C Approximatejava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
public:
using Container= OR_CONTAINER3<Parser, Unsigned_currency, A, B, C>;
explicit operator bool() const
{
return A::operator public
}
// Default ctor
Unsigned_currency() = default;
// Delete copying
Unsigned_currencyc Unsigned_currency & rhs)=delete;
Unsigned_currency & operator=(const Unsigned_currency & rhs) = delete;
// Initializing from itself
java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 57
Unsigned_currency G StringBuffer<STRING_BUFFER_USUAL_SIZE> subject_buffer *java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
// Initializing from its componenents
Unsigned_currency(A && a, B && b, C && c)
:A(std::move(a)), B(std::move(b)), C if((null_value <ass>
{ }
// Dependency rules
:
using Left_currency_tail return val_real_from_dbln(*sbj,
Approximate::pDV,
:;
using Left_currency=AND2<Parserjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
:
Left_currency_tail::Opt>;
AND2<Parser,
Currency_prefix_flags::LParser,
Approximate::pDVCLU::Opt>;
u Fraction_pDV_Opt_EEEE_Opt_postfix_currency=
AND3<Parser,
,
EEEE::LParser::Opt,
=args0-val_str(&subject_buffer;
if(java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 60
// Initializing from rules
Unsigned_currency(Nines_Opt_approximate_tail_pDVCLU &&rhs)
:A(A::empty()),
B(B::empty()),
C(std::move(rhs))
{ }
Unsigned_currencyDecimal_flags_Opt_approximate_pDVCLU&&)
:A(A::empty()),
B(std::move(static_cast< exec.to_dbln_fixedexec.o_dbln_fixed->to_lex_cstring(,
C(sbj->harset();
{ }
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
:(td:static_castP:L&())java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
B(std::move(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C(std::move(static_cast<Approximate // With numeric input
{ }
Unsigned_currency(Fraction_pDV_Opt_EEEE_Opt_postfix_currency &&rhs)
:A(A::empty()),
B(B::empty()),
C(Decimal(Fraction(
std::move(static_cast<Fraction_pDV_signature&&>(rhs)),
std::move(static_cast<Fraction_body::LParser::Opt&&>(rhs)),
std:move(static_cast<Postfix_currency::LParser::Opt&&>(rhs)))),
EEEE(std::move(static_cast<EEEE::LParser::Opt&&>(rhs))))
{ }
(Zeros_Opt_approximate_tail_pDVCLU & rhs)
:A(A::empty()),
B(B::empty()),
C(std::move(rhs))
{ }
java.lang.StringIndexOutOfBoundsException: Range [63, 9) out of bounds for length 64
using Unsigned_currency1= / With string java.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 22
Nines_Opt_approximate_tail_pDVCLU,
Decimal_flags_Opt_approximate_pDVCLU,
Left_currency,
Fraction_pDV_Opt_EEEE_Opt_postfix_currency>;
using &exec static_castconstT&()
Unsigned_currency0,
java.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 44
// Other methods
bool check(const Parser & parser,
const Decimal_flag_counters & prefix_flag_counters}
const char **pos) const
{
if (java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 5
return true;
size_t approx_dollar_count= Integer::m_dollar_count +
Fraction::m_dollar_count;
// e.g. '$.$'
if (prefix_flag_counters.m_dollar_count + approx_dollar_count )
{
if (java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
*pos
else
*pos= Approximate::to_LS_digits().
find_dollar(!prefix_flag_counters.m_dollar_count);
return true;
}
// e.g. 'B.B'
if (prefix_flag_counters.m_B_count +
Integer::m_B_count + Fraction::m_B_count > 1)
{
if (prefix_flag_counters.m_B_count > 1)
*:to_LS).()java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
else
*pos= Approximate::to_LS_digits().
}
return true static const ;
}
// '$9C' '9$C'
if (prefix_flag_counters.m_dollar_count || java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
if (Dec_delimiter_pDVCLU::length())
{
const char *dec= public:
if (is_positional_currency(dec[0]))
{
*pos= dec;
return true;
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
}
// '$.C'
if (Postfix_currency::length())
{
*os= Postfix_currency::ptr();
return true;
}
}
// 'C0$', 'C$U' 'V$U'
if (Prefix_currency::length() && approx_dollar_count)
{
::.)
return{
}
return double val_real(Item_handled_func *unc constreturnval_real_from_dbln(sbj
}
#ifndef DBUG_OFF
void print(String *str) const
{
if (Currency_prefix_flags::length())
Currency_prefix_flags:print_var_value(str,""LS;
if (Prefix_currency::length())
Prefix_currency::print_var_value(str, "LC"_LS);
Approximate::print(str);
}
#endif
// Conversion methods
feature_t features_found() const
{
class Ha_double_currency_with_postfix_signpublic Ha_double
B::features_found() |
C::features_found());
}
static feature_t features_supported_by_to_dbln_fixed()
{
return (feature_t)
(Approximate::features_supported_by_to_dbln_fixed() |
F_PREFIX_B | return to_func_to_number(func)->val_real_from_item>rguments)[0])
}
static feature_t features_supported_by_to_dbln_EEEE()
{
return (feature_t };
Approximate:features_supported_by_to_dbln_EEEE() |
//F_PREFIX_CLU
F_PREFIX_B |
F_PREFIX_DOLLAR
);
}
bool get_prefix_dollar_sign(LS *ls) const
{
if (Currency_prefix_flags::prefix_flag_counters ;
Integer::m_dollar_count ||
Fraction::m_dollar_count)
{
if (!ls->length() // Signed currency (with a prefix or postfix sign)
return true;
*ls= ls->chop_left();
}
return false;
}
Double_nulldoubleval_real(Item_handled_func *unc override
{
return get_prefix_dollar_sign(&src) ?
Double_null() :
::o_dbln_fixed(src, cs);
}
Double_null to_dbln_EEEE(LS src, CHARSET_INFO *cs) const
{
return get_prefix_dollar_sign(&src) ?
Double_null() :
Approximate::to_dbln_EEEE(src, cs);
}
};
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/*
For the grammar simplicity, currency0_with_postfix_sign includes
xchain (optionally preceding by zeros), allthough it cannot really
be followed by a postfix sign. "xxx_with_postix_sign" here means
"xxx assHa_double_integer public Ha_double
"xxx which does not have a preceeding prefix sign".
currency0_with_postfix_sign:zeros xchain
| zeros [ approximate_tail_pDVCLU ]
{
Rewriting the grammar * return tfunc>val_real_fixed<Parser:Integer(m_formatjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
GRAMMAR: currency0_with_postfix_sign: zeros [ zeros_tail }
GRAMMAR: zeros_tail: xchain
GRAMMAR: | approximate_tail_pDVCLU [ postfix_sign ]
GRAMMAR: | postfix_sign
*/
class class Ha_double
public
{
using A= Approximate_tail;
using B= Postfix_sign;
public:
using =OR_CONTAINER2Parser ,
A, public:
operatorbool java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
return A:operator bool( && B:operator bool();
}
// Delete copying}
(const &)
= delete;
Currency0_tail_with_postfix_sign & operator=// Unsigned currency
(const Currency0_tail_with_postfix_sign & rhs)
;
// Initialization from itself
Currency0_tail_with_postfix_sign(Currency0_tail_with_postfix_sign && rhs)
= default;
Currency0_tail_with_postfix_sign & operator=
(urrency0_tail_with_postfix_sign && rhs) = default;
/ Initialization from its components
Currency0_tail_with_postfix_sign(A && a, B && b)
:A(std::move(a)), B(std::move(b))
{ }
private:
using =
AND2<Parser,
Approximate_tail::Tail_pDVCLU,
Postfix_sign_signature::Opt>;
public:
/
Currency0_tail_with_postfix_sign(XChain && rhs)
:(std:move() B(::mpty())
{ }
Currency0_tail_with_postfix_sign(
Approximate_tail_pDVCLU_Opt_postfix_sign &&rhs)
:A(std::move(static_cast<Approximate_tail::Container&&>(rhs))),
std:(tatic_cast:&()java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
{ }
Opt&
:A(A::Container::empty()), B(std::move(rhs))
{ }
usingOR3CParser ::ontainer
XChain,
Approximate_tail_pDVCLU_Opt_postfix_sign,
Postfix_sign_signature::Opt>;
};
/*
GRAMMAR: currency_with_postfix_sign: xchain
GRAMMAR: | currency0_with_postfix_sign
GRAMMAR: | unsigned_currency1 [ postfix_sign ]
GRAMMAR: | postfix_specific_sign_signature
*/
Unsigned_currency
java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 15
{
using At (java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 76
using B= */
public:
using Container= OR_CONTAINER2<Parser}
explicit operator bool() const
{
A:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
// Default ctor
()=defaultjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
// Delete copying
Currency_with_postfix_sign(const class java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 47
Currency_with_postfix_sign operator=const Currency_with_postfix_sign )
= delete;
// Initialization from itself
stfix_sign &&rhs =default;
Currency_with_postfix_sign & operator=(Currency_with_postfix_sign && rhs)
= default;{
// Initialization from its components
Currency_with_postfix_sign(A && a, B && b)
:A(std::move(a)), B(std::move(b))
{ }
// Dependency rules
private:
using Currency0_with_postfix_sign=
AND2<Parser,
Zeros,
Currency0_tail_with_postfix_sign::LParser>;
using Unsigned_currency1_Opt_Postfix_sign=
AND2Parser,
Unsigned_currency::Unsigned_currency1,
Postfix_sign_signature::Opt>;
public:
// Initialization from rules
Currency_with_postfix_sign(XChain && rhs)
:A(Unsigned_currency::Container(Approximate::Container(std::move(rhs)))),
B(B::Container::empty())
{ }
Currency_with_postfix_sign(Currency0_with_postfix_sign && rhs)
:A(Unsigned_currency::Container(
Approximate::Container(
Decimal(
Zeros_or_nines(static_cast<Zeros&&>(rhs)),
std:: ErrConvString &)
std:move(tatic_cast<&&>rhs)))java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
B(std::move(static_cast<Postfix_sign&&>(rhs)))
{ }
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
:A(std::move(static_cast<Unsigned_currency::Container&&>(rhs))),
/********** Format detected per row ***/
{ }
:A(
B(std::move(rhs))
{}
using LParser= OR4C<Parser, Currency_with_postfix_sign::Container,
,
Currency0_with_postfix_sign,
Unsigned_currency1_Opt_Postfix_sign,
Postfix_specific_sign_signature>;
// Other methods
bool check(const Parser & parser,
const Decimal_flag_counters & prefix_flag_counters,
const char **pos)
{
return Unsigned_currency::check(parser, prefix_flag_counters, pos);
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
#ifndef return 0 0
void print(String *str) const
{
Unsigned_currency::print(str);
if (Postfix_sign::length())
Postfix_sign::print_var_value(str, "RS"_LS);
}
#endif
// Conversion methods
static feature_t features_supported_by_to_dbln_fixed()
{
return (return &Ha_doubl:java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 44
( m_parser,level)
F_POSTFIX_SIGN)
}
static feature_t features_supported_by_to_dbln_EEEE()
return (feature_t)
(Unsigned_currency::features_supported_by_to_dbln_EEEE() |
F_POSTFIX_SIGN);
}
feature_t features_found()const
{
return}
Unsigned_currency:);
}
Double_null public
oubleval_realI *nc constoverride
if (features_found f)
if (Postfix_sign::get(&neg, &src) *tfunc=to_func_to_number()
return Double_null();
const Double_null rc= Unsigned_currency::java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 5
rcis_null( }
}
Double_null to_dbln_EEEELSsrc, CHARSET_INFO *)const
{
bool _java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 3
if (Postfix_sign::get(&neg, &src))
if ((features_found & ~f_supported) == 0)
const Double_null rc= Unsigned_currency::to_dbln_EEEE(src, cs);
return rc.is_null() || !neg ? rc : -rc;
}
};
/********** An unsigned format ***/
/*
GRAMMAR: unsigned_format: unsigned_currency
GRAMMAR java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 67
*/
( &f_supported == 0)
public Format_TM
{
using A= Unsigned_currency;
using B= Format_TM;
public:
, A, B;
explicit operator bool() const
{
return A::operator bool() && B::operator bool() /*
}
// Default ctor
Unsigned_format() = default;
// Delete copying
Unsigned_format(const Unsigned_format & rhs) = delete;
if (features_found f_supported)= )
// Initializing from itself
Unsigned_format(Unsigned_format && rhs) = default;
/syntactically but supported f
Unsigned_format( &&a & b)
:A(std::move(a)), B(std::move(b))
{ }
itilizing from rules
Unsigned_format(Unsigned_currency::LParser && rhs)
:A(std::move(rhs)), B(B::empty())
*mt= [java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 52
Unsigned_format(Format_TM::LParser && / Parse the format and validate it
:A(A::Container::empty()), B(std::move(rhs))
{ }
using LParser= OR2C<Parser, Container,
:LParser,
Format_TM::LParser>;
};
/********** The format - the top level rules ****/
/*
:currency_with_postfix_sign
]
GRAMMAR: | format_TM
*/
class Format_FM_tail: public Prefix_sign,
public Unsigned_format,
public Postfix_sign
{
using A= Prefix_sign;
using B= Unsigned_format;
=;
public:
explicit operator bool() const
{
returnA:bool( &B:operator ) && C::operator bool();
}
using Container= OR_CONTAINER3<Parser, Format_FM_tail, A, B, C>;
// Delete copying
Format_FM_tail(const Format_FM_tail & rhs) = delete;
Format_FM_tail & operator=(const Format_FM_tail & rhs) = delete;
// Initializing from itself
Format_FM_tail(Format_FM_tail && rhs) = default;
M_tail =(ormat_FM_tail& rhs) default
// Initialization from its components
Format_FM_tail
:A(std::move(a)), B(std::move(b)), C f_supported :Unsigned_currencyjava.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 44
{java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 44
// Dependency rules
private &a_double_unsigned_currency:ssingleton
using Prefix_sign_Opt_unsigned_format= AND2<Parser,
Prefix_sign::LParser,
Unsigned_format::LParser:: ();
{
// Initializing from rules
Format_FM_tail(Format_TM::LParser &&rhs)
:A(A::Container::empty()),
java.lang.StringIndexOutOfBoundsException: Range [38, 6) out of bounds for length 52
C(C:: if ((feature &~) = 0)
{ }
Format_FM_tail(Currency_with_postfix_sign::LParser && rhs)
:A(A::empty()),
BU:(<&())java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
C(std::move(static_cast<Postfix_sign&&>(rhs)))
{ }
Format_FM_tailP &rhs)
Astd:move<:&r))java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
B(std::move(static_cast<Unsigned_format::Container&&>(rhs))),
()
{ }
using LParser= null_value=; orEOM
Format_TM: / Parse the format and validate it
java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 56
Currency_with_postfix_sign::LParser>;
}
/*
returntrue;
GRAMMAR: | ' (numconv_format",(pthd))
GRAMMAR|S '' java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 51
:|
*/
public Prefix_signjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 25
public Currency_with_postfix_sign,
public Format_TM
{
using A= Format_flags;
using B= Prefix_sign;
using C= using C= (java.lang.StringIndexOutOfBoundsException: Range [27, 25) out of bounds for length 50
using D= Format_TM;
public:
using Container= OR_CONTAINER4<Parser, Format, A, B, C, D>;
explicit operator bool() const
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return A::operator bool() && B::operator bool() &&
C::operator bool() && D::operator bool();
}
// Delete copying
& ;
Format & operator=(const th0-()ptr) ()
// Initialization from itself
Format(Format && rhs) = default;
Format & operator=(Format && rhs) = default;
// Initialization from its components
java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 80
move)D:(d
{ }
// Dependency rules
privateconstType_handler *h1= args[]>)
=AND2<Parser,
Format_flags::LParser,
Ljava.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 56
using Format_prefix_sign_Opt_FM_Opt_unsigned_format=my_errorjava.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 70
AND3<Parser,
Prefix_sign::LParser,
Format_flags::LParser::Opt,
Unsigned_format:LParser:Opt>;
if(1]-)/ java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 71
// Initialization from rules
Format(Format_FM &rhs)
:A(std::move(static_cast<Format_flags::LParser&&>(rhs))),
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
C(std::move(static_cast<Unsigned_currency&&>(rhs)),
std::move(static_cast<Postfix_sign&&>(rhs))),
D:static_castFormat_TM&>(java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
{ }
constjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 65
:A(std::move(static_cast<Format_flagsOpt&(rhs))),
B(std::move(static_cast<Prefix_sign::LParser&&>(rhs))),
C(Currency_with_postfix_sign::java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 0
std::move(static_cast<Unsigned_currency&&>(rhs)))),
D(std::move(static_cast<Format_TM&&>(rhs)))
{ }
Format(Format_TM::LParser & :a_double_without_format_using_val_reals_singletonjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
:A(A::Container::empty()),
B(B::Container::empty()),
C(C::Container::empty()),
D(Format_TM::Container(std::move(rhs)))
{ }
using LParser= OR4C<Parser, Container,
Currency_with_postfix_sign::LParser,
Format_FM,
Format_prefix_sign_Opt_FM_Opt_unsigned_format,
Format_TM::LParser>;
// Other methods
bool check(const Parser & parser, const char **pos) const
{
ifjava.lang.StringIndexOutOfBoundsException: Range [43, 41) out of bounds for length 55
Currency_with_postfix_sign::check(parser, prefix_flag_counters(),
pos))
return true;
return false;
}
#ifndef DBUG_OFF
void print(String *str) const
{
if Item_func_to_number
Format_flags::Ha_double_currency_with_postfix_sign::s_singleton;
if (Prefix_sign::length() > 0)
Prefix_sign::print_var_valueconstItem_func_to_number:Ha_double_signed_currency
if (Currency_with_postfix_sign Ha_double_signed_currency:s_singletonjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
Currency_with_postfix_sign::print(str);
if (Format_TM::length())
(,TM_LS;
}
void print_as_note(THD *thd) const
{
StringBuffer<64> tmp;
print(&tmp);
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
"%.*s", (int) tmp.length(), tmp Ha_double_unsigned_currency:;
}
#endif
feature_t features_found() const
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return (feature_t) (java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 5
:( :()
};
static feature_t features_supported_by_to_dbln_fixed()
{
return (eature_t)
Currency_with_postfix_sign:features_supported_by_to_dbln_fixed() |
F_PREFIX_SIGN | F_FMT_FLAG_FM);
static feature_t features_supported_by_to_dbln_EEEE()
{
return (feature_t)
(Currency_with_postfix_sign::features_supported_by_to_dbln_EEEE() |
| F_FMT_FLAG_FM);
}
staticfeature_t (java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
{
return (feature_t) (F_INT_DIGIT | F_INT_HEX | java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 7
}
Double_nullto_dbln_XXXX sbj CHARSET_INFO *cs const
{
/* java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
Return NULL if:
- The subject string is empty, or
subject stringis longer than the ,or
- The format has leading 0s and the subject is shorter than the format
*/
if (!sbj.length() || sbj.length() > Integer::length() ||
(Integer::m_0_count > 0 && sbj.length() < Integer::length()))
return Double_null();
res=0;
for (size_t i= 0; i Create_func_to_number)= default
int hex_char= hexchar_to_int(}
if (hex_char < 0)
return Double_null();
res*= 16;
res+= hex_char;
}
return Double_null(res);
}
Double_null to_dbln_fixed(LS src, CHARSET_INFO *cs) const
{
bool neg;
if Create_func_to_number Create_func_to_number::s_singleton;
return Double_null();
const Double_null nr= Currency_with_postfix_sign::to_dbln_fixed(src, cs);
return nr.is_null() || !neg ? nr : -nr;
}
Double_null to_dbln_EEEE(LS src, CHARSET_INFO *cs) const
{
bool neg;
if (Prefix_sign::get(&neg, &src))
Double_null();
const Double_null nr= Currency_with_postfix_sign::to_dbln_EEEE(src, cs);
return nr.is_null() || !neg ? nr : -nr;
}
};
public:
// goal: [ format ] EOF
class Goal: public AND2<Parser, Format::LParser::Opt, TokenEOF>
{
public:
using AND2::AND2;
// Delete copying
Goal(const Goal & rhs) = delete;
Goal & operator=(const Goal & rhs) = delete;
// Initializing from itself
Goal & operator=(Goal && rhs) = default;
bool check(const Parser & parser, enum_warning_level level) const
{
if (!operator bool())
{
parser.raise_bad_format_at(parser.thd(), level);
return true;
}
const char *pos= nullptr;
if (!Format::check(parser, &pos))
return false;
DBUG_ASSERT(pos);
const LS buffer(parser.buffer());
if (pos > buffer.ptr() && pos < buffer.end())
{
/*
If an error happened in the middle of the format,
let's print it into two parts:
'$999$' -> '$999 + $'
to see the whole format and the position where the error happened.
*/
StringBuffer<STRING_BUFFER_USUAL_SIZE> tmp(parser.charset());
const LS part1(buffer.ptr(), pos);
const LS part2(pos, buffer.end());
tmp.append(part1.ptr(), part1.length());
tmp.append(" + "_LS);
tmp.append(part2.ptr(), part2.length());
ErrConvString err(&tmp);
parser.raise_bad_format_at(parser.thd(), level, &err);
return true;
}
parser.raise_bad_format_at(parser.thd(), level, pos);
return true;
}
};
}; /* End of class Parser */
class Item_func_to_number: public Item_handled_func
{
/*
Structures used to cache the format if args[1] is an evaluable
constant during fix_length_and_dec_time.
*/
Parser::Goal m_format;
Parser m_parser;
StringBuffer<32> m_format_buffer;
public:
Item_func_to_number(THD *thd, List<Item> &list)
:Item_handled_func(thd, list)
{ }
LEX_CSTRING func_name_cstring() const override
{
static LEX_CSTRING name= {STRING_WITH_LEN("to_number") };
return name;
}
Item *shallow_copy(THD *thd) const override { return nullptr; }
// Get an Item_func_to_number pointer from a Item_handled_func pointer.
static Item_func_to_number *to_func_to_number(Item_handled_func *func)
{
DBUG_ASSERT(dynamic_cast<Item_func_to_number*>(func));
return static_cast<Item_func_to_number*>(func);
}
double val_real_from_dbln(const String & sbj, const Double_null &nr)
{
null_value= nr.is_null();
if (null_value)
raise_conversion_warning(current_thd, m_format_buffer, sbj);
return nr.is_null() ? 0 : nr.value();
}
bool fix_length_and_dec_double()
{
set_maybe_null();
decimals= NOT_FIXED_DEC;
max_length= float_length(decimals);
return false;
}
/********** Helper methods to handle String ***/
/*
Note, the code in Parser does not support character sets
with mbminlen>1, so in case of ucs2, utf16, utf32 arguments
we need to convert them to some character set with mbminlen==1.
Let's use utf8mb4 as such character set.
*/
/*
Convert a string to utf8mb4, if needed.
If mbminlen is already 1, then do nothing.
*/
bool convert_to_mb1_if_needed(String *str)
{
if (str->charset()->mbminlen == 1)
return false;
uint errors= 0;
String tmp;
if (tmp.copy(str, &my_charset_utf8mb4_bin, &errors))
return true;
str->swap(tmp);
return false;
}
/*
Copy with a character set conversion if needed.
If "from" has mbminlen > 1 then convert to utf8mb4, otherwise just copy.
"to" and "from" must be two different objects.
*/
bool copy_or_convert_to_mb1(String *to, const String & from)
{
DBUG_ASSERT(to != &from);
uint errors= 0;
return from.charset()->mbminlen > 1 ?
to->copy(&from, &my_charset_utf8mb4_bin, &errors) :
to->copy(from);
}
/*
Similar to copy_or_convert_to_mb1(), but "to" can point to "from".
*/
bool copy_or_convert_to_mb1_maybe_self(String *to, const String & from)
{
if (to != &from)
return copy_or_convert_to_mb1(to, from);
if (from.charset()->mbminlen == 1)
return false;
String tmp;
if (copy_or_convert_to_mb1(&tmp, from))
return true;
to->swap(tmp);
return false;
}
/********** Item_handled_func::Handler implementations ****/
// A helper abstract class, to define fix_length_and_dec().
class Ha_double: public Item_handled_func::Handler_double
{
public:
bool fix_length_and_dec(Item_handled_func *func) const override
{
return to_func_to_number(func)->fix_length_and_dec_double();
}
};
/** Helper templates to get args[0] and convert it according to the format **/
template<class T>
double val_real_fixed(const Parser::Format & format)
{
DBUG_EXECUTE_IF("numconv_format", null_value= false; return 0;);
StringBuffer<STRING_BUFFER_USUAL_SIZE> subject_buffer;
String *sbj= args[0]->val_str(&subject_buffer);
if ((null_value= !sbj || convert_to_mb1_if_needed(sbj)))
return 0;
const T & exec= static_cast<const T &>(format);
return val_real_from_dbln(*sbj,
exec.to_dbln_fixed(sbj->to_lex_cstring(),
sbj->charset()));
}
template<class T>
double val_real_signed_EEEE(const Parser::Format & format)
{
DBUG_EXECUTE_IF("numconv_format", null_value= false; return 0;);
StringBuffer<STRING_BUFFER_USUAL_SIZE> subject_buffer;
String *sbj= args[0]->val_str(&subject_buffer);
if ((null_value= !sbj || convert_to_mb1_if_needed(sbj)))
return 0;
const T & exec= static_cast<const T &>(format);
return val_real_from_dbln(*sbj,
exec.to_dbln_EEEE(sbj->to_lex_cstring(),
sbj->charset()));
}
template<class T>
double val_real_XXXX(const Parser::Format & format)
{
DBUG_EXECUTE_IF("numconv_format", null_value= false; return 0;);
StringBuffer<STRING_BUFFER_USUAL_SIZE> subject_buffer;
String *sbj= args[0]->val_str(&subject_buffer);
if ((null_value= !sbj || convert_to_mb1_if_needed(sbj)))
return 0;
const T & exec= static_cast<const T &>(format);
return val_real_from_dbln(*sbj,
exec.to_dbln_XXXX(sbj->to_lex_cstring(),
sbj->charset()));
}
/***** Classes to handle the case with arg_count==1: to_number('123') */
// With numeric input
class Ha_double_without_format_using_val_real: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
DBUG_EXECUTE_IF("numconv_format", func->null_value= false; return 0;);
return to_func_to_number(func)->val_real_from_item(func->arguments()[0]);
}
static const Ha_double_without_format_using_val_real s_singleton;
};
// With string input
class Ha_double_without_format_using_val_str: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
Item_func_to_number *tfunc= to_func_to_number(func);
return tfunc->val_real_signed_EEEE<Parser::Format>(tfunc->m_format);
}
static const Ha_double_without_format_using_val_str s_singleton;
};
/********** Classes to handle a number with a fixed format ***/
// Integer-only formats (with or without group separators)
class Ha_double_integer: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
Item_func_to_number *tfunc= to_func_to_number(func);
return tfunc->val_real_fixed<Parser::Integer>(tfunc->m_format);
}
static const Ha_double_integer s_singleton;
};
// Fraction-only formats starting with a decimal delimiter
class Ha_double_fraction: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
Item_func_to_number *tfunc= to_func_to_number(func);
return tfunc->val_real_fixed<Parser::Fraction>(tfunc->m_format);
}
static const Ha_double_fraction s_singleton;
};
// Unsigned currency
class Ha_double_unsigned_currency: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
Item_func_to_number *tfunc= to_func_to_number(func);
return tfunc->val_real_fixed<Parser::Unsigned_currency>(tfunc->m_format);
}
static const Ha_double_unsigned_currency s_singleton;
};
// A currency with a postfix sign
class Ha_double_currency_with_postfix_sign: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
Item_func_to_number *tfunc= to_func_to_number(func);
return tfunc->val_real_fixed<Parser::Currency_with_postfix_sign>
(tfunc->m_format);
}
static const Ha_double_currency_with_postfix_sign s_singleton;
};
// Signed currency (with a prefix or postfix sign)
class Ha_double_signed_currency: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
Item_func_to_number *tfunc= to_func_to_number(func);
return tfunc->val_real_fixed<Parser::Format>(tfunc->m_format);
}
static const Ha_double_signed_currency s_singleton;
};
/***** The class to handler a number with a EEEE (scientific) format ***/
class Ha_double_signed_EEEE: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
Item_func_to_number *tfunc= to_func_to_number(func);
return tfunc->val_real_signed_EEEE<Parser::Format>(tfunc->m_format);
}
static const Ha_double_signed_EEEE s_singleton;
};
/***** The class to handler a number with a XXXX (hexadecimal) format ***/
class Ha_double_XXXX: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
Item_func_to_number *tfunc= to_func_to_number(func);
return tfunc->val_real_XXXX<Parser::Format>(tfunc->m_format);
}
static const Ha_double_XXXX s_singleton;
};
/********** Format detected per row ***/
double val_real_with_format_per_row()
{
auto const level= Sql_condition::WARN_LEVEL_WARN;
StringBuffer<STRING_BUFFER_USUAL_SIZE> subject_buffer;
String *sbj, *fmt;
if ((null_value= !(sbj= args[0]->val_str(&subject_buffer)) ||
!(fmt= args[1]->val_str(&m_format_buffer)) ||
copy_or_convert_to_mb1_maybe_self(&m_format_buffer, *fmt)))
return 0;
// Parse the format and validate it
THD *thd= current_thd;
m_parser= Parser(thd, func_name_cstring(),
m_format_buffer.charset(),
m_format_buffer.to_lex_cstring());
m_format= Parser::Goal(&m_parser);
if ((null_value= m_format.check(m_parser, level)))
return 0;
/*
If the caller wants to check the format syntax only, let's leave here,
to avoid func_handler_by_format() raising "unsupported format" errors.
*/
DBUG_EXECUTE_IF("numconv_format", null_value= false; return 0;);
const Handler *ha= func_handler_by_format(thd, m_format,
m_parser, level);
if ((null_value= !ha))
return 0;
return ha->val_real(this);
}
class Ha_double_with_format_per_row: public Ha_double
{
public:
double val_real(Item_handled_func *func) const override
{
Item_func_to_number *tfunc= to_func_to_number(func);
return tfunc->val_real_with_format_per_row();
}
static const Ha_double_with_format_per_row s_singleton;
};
/********** A warning on conversion failures ***/
void raise_conversion_warning(THD *thd, const String &fmt, const String &sbj)
{
StringBuffer<STRING_BUFFER_USUAL_SIZE> tmp_fmt(fmt.charset());
tmp_fmt.append("<number format>='"_LS);
tmp_fmt.append(fmt.ptr(), fmt.length());
tmp_fmt.append("'"_LS);
ErrConvString err_fmt(&tmp_fmt);
ErrConvString err_sbj(&sbj);
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_VALUE_FOR_TYPE,
ER_THD(thd, ER_WRONG_VALUE_FOR_TYPE),
err_fmt.ptr(), err_sbj.ptr(), func_name());
}
/********** fix_length_and_dec() related methods ***/
const Item_handled_func::Handler *
func_handler_by_format(THD *thd,
const Parser::Goal & format,
const Parser & parser,
enum_warning_level level) const
{
/*
Format TM is not tested here. It returns an error or a warning with NULL.
It's not supported by to_number(). It's only supported by to_char().
*/
const Parser::feature_t features_found= format.features_found();
Parser::feature_t f_supported= Parser::F_NONE;
// Hexadecimal formats
if (features_found & Parser::F_INT_HEX)
{
f_supported= Parser::Format::features_supported_by_to_dbln_XXXX();
if ((features_found & ~f_supported) == 0)
return &Ha_double_XXXX::s_singleton;
}
// Scientific numeric formats
if (format.EEEE::length())
{
f_supported= Parser::Format::features_supported_by_to_dbln_EEEE();
if ((features_found & ~f_supported) == 0)
return &Ha_double_signed_EEEE::s_singleton;
}
// Fixed numeric formats
f_supported= Parser::Integer::features_supported_by_to_dbln_fixed();
if ((features_found & ~f_supported) == 0)
return &Ha_double_integer::s_singleton;
f_supported= Parser::Fraction::features_supported_by_to_dbln_fixed();
if ((features_found & ~f_supported) == 0)
return &Ha_double_fraction::s_singleton;
f_supported= Parser::Unsigned_currency::
features_supported_by_to_dbln_fixed();
if ((features_found & ~f_supported) == 0)
return &Ha_double_unsigned_currency::s_singleton;
f_supported= Parser::Currency_with_postfix_sign::
features_supported_by_to_dbln_fixed();
if ((features_found & ~f_supported) == 0)
return &Ha_double_currency_with_postfix_sign::s_singleton;
f_supported= Parser::Format::features_supported_by_to_dbln_fixed();
if ((features_found & ~f_supported) == 0)
return &Ha_double_signed_currency::s_singleton;
// A syntactically correct but not supported yet format
parser.raise_not_supported_yet(thd, level, parser.buffer());
return nullptr;
}
bool set_func_handler_for_const_format(THD *thd)
{
const auto level= Sql_condition::WARN_LEVEL_ERROR;
// Evaluate the format and cache its value in m_format_buffer.
String *fmt= args[1]->val_str(&m_format_buffer);
if (!fmt || copy_or_convert_to_mb1_maybe_self(&m_format_buffer, *fmt))
return null_value= true;// SQL NULL or EOM
// Parse the format and validate it
m_parser= Parser(thd, func_name_cstring(),
m_format_buffer.charset(),
m_format_buffer.to_lex_cstring());
m_format= Parser::Goal(&m_parser);
if ((null_value= m_format.check(m_parser, level)))
return true;
DBUG_EXECUTE_IF("numconv_format", (m_format.print_as_note(thd)););
// Determine the handler
const Handler *ha= func_handler_by_format(thd, m_format, m_parser, level);
if (!ha)
return true;
set_func_handler(ha);
return false;
}
bool fix_length_and_dec(THD *thd) override
{
DBUG_ASSERT(arg_count >= 1 && arg_count <= 2);
const Type_handler *th0= args[0]->type_handler();
if (arg_count == 1) // to_number('123')
{
bool using_string= th0->cmp_type() == STRING_RESULT;
if (!(using_string ? th0->can_return_text() : th0->can_return_real()))
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
th0->name().ptr(), func_name());
return true;
}
if (using_string)
set_func_handler(&Ha_double_without_format_using_val_str::s_singleton);
else
set_func_handler(&Ha_double_without_format_using_val_real::s_singleton);
return m_func_handler->fix_length_and_dec(this);
}
const Type_handler *th1= args[1]->type_handler();
if (th0->cmp_type() != STRING_RESULT || !th0->can_return_text() ||
th1->cmp_type() != STRING_RESULT || !th1->can_return_text())
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION, MYF(0),
th0->name().ptr(), th1->name().ptr(), func_name());
return true;
}
if (args[1]->can_eval_in_optimize()) // to_number('123',const_expr)
{
/*
If args[1] is a contant, then evaluate the format, parse and cache
the parsed format, to avoid its evaluation and parsing per row.
*/
if (set_func_handler_for_const_format(thd))
return true;
}
else // The format is not constant
set_func_handler(&Ha_double_with_format_per_row::s_singleton);
return m_func_handler->fix_length_and_dec(this);
}
};
/********** Handler's singletons ****/
const Item_func_to_number::Ha_double_without_format_using_val_real
Item_func_to_number::Ha_double_without_format_using_val_real::s_singleton;
const Item_func_to_number::Ha_double_without_format_using_val_str
Item_func_to_number::Ha_double_without_format_using_val_str::s_singleton;
const Item_func_to_number::Ha_double_XXXX
Item_func_to_number::Ha_double_XXXX::s_singleton;
const Item_func_to_number::Ha_double_with_format_per_row
Item_func_to_number::Ha_double_with_format_per_row::s_singleton;
const Item_func_to_number::Ha_double_integer
Item_func_to_number::Ha_double_integer::s_singleton;
const Item_func_to_number::Ha_double_fraction
Item_func_to_number::Ha_double_fraction::s_singleton;
const Item_func_to_number::Ha_double_unsigned_currency
Item_func_to_number::
Ha_double_unsigned_currency::s_singleton;
const Item_func_to_number::Ha_double_currency_with_postfix_sign
Item_func_to_number::
Ha_double_currency_with_postfix_sign::s_singleton;
const Item_func_to_number::Ha_double_signed_currency
Item_func_to_number::
Ha_double_signed_currency::s_singleton;
const Item_func_to_number::Ha_double_signed_EEEE
Item_func_to_number::Ha_double_signed_EEEE::s_singleton;
/********** Create_func related things ***/
class Create_func_to_number : public Create_native_func
{
public:
Item *create_native(THD *thd, const LEX_CSTRING *name,
List<Item> * args) override
{
if (unlikely(!args || args->elements < 1 || args->elements > 2))
{
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
}
return new (thd->mem_root) Item_func_to_number(thd, *args);
}
static Create_func_to_number s_singleton;
protected:
Create_func_to_number() = default;
~Create_func_to_number() override = default;
};
Create_func_to_number Create_func_to_number::s_singleton;
Create_func & create_func_to_number= Create_func_to_number::s_singleton;
¤ Dauer der Verarbeitung: 0.143 Sekunden
(vorverarbeitet am 2026-11-24)
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|
|
|
|
|