add FT::numeric to be applied on string types
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <type_traits>
|
||||
#include "textstream/textstream.h"
|
||||
#include "date/date.h"
|
||||
#include "morm_types.h"
|
||||
@@ -635,6 +636,49 @@ protected:
|
||||
void esc(const char * val, bool has_known_length, size_t len, pt::TextStream & stream, const FT & field_type);
|
||||
|
||||
bool is_empty_field(const wchar_t * value);
|
||||
|
||||
|
||||
|
||||
template<typename CharType>
|
||||
void esc_normal_string(CharType * val, bool has_known_length, size_t len, pt::TextStream & stream, const FT & field_type)
|
||||
{
|
||||
for(size_t i = 0 ; has_known_length ? (i < len) : val[i] != 0 ; ++i)
|
||||
{
|
||||
esc(val[i], stream, field_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename CharType>
|
||||
void esc_numeric_string(CharType * val, bool has_known_length, size_t len, pt::TextStream & stream, const FT & field_type)
|
||||
{
|
||||
bool was_comma = false;
|
||||
bool was_something_printed = false;
|
||||
|
||||
for(size_t i = 0 ; has_known_length ? (i < len) : val[i] != 0 ; ++i)
|
||||
{
|
||||
typename std::remove_const<CharType>::type c = val[i];
|
||||
|
||||
if( c == ',' )
|
||||
c = '.';
|
||||
|
||||
if( (c=='.' && !was_comma) || (c>='0' && c<='9') )
|
||||
{
|
||||
esc(c, stream, field_type);
|
||||
was_something_printed = true;
|
||||
|
||||
if( c == '.' )
|
||||
was_comma = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( !was_something_printed )
|
||||
{
|
||||
esc(static_cast<CharType>('0'), stream, field_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user