diff options
author | Antonin Kral <a.kral@bobek.cz> | 2010-08-18 09:23:15 +0200 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2010-08-18 09:23:15 +0200 |
commit | 3b9581e84e19723087b31b79674801b6c06ae533 (patch) | |
tree | 5568dbd7199b1ce64ace1cec26b590c1431e872d /bson/util/builder.h | |
parent | d7ec8115ec4b160ed74c1a8a06a1c171d76370ac (diff) | |
download | mongodb-3b9581e84e19723087b31b79674801b6c06ae533.tar.gz |
Imported Upstream version 1.6.1
Diffstat (limited to 'bson/util/builder.h')
-rw-r--r-- | bson/util/builder.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/bson/util/builder.h b/bson/util/builder.h index 75a1ad8..9d9eda2 100644 --- a/bson/util/builder.h +++ b/bson/util/builder.h @@ -164,6 +164,7 @@ namespace mongo { #define SBNUM(val,maxSize,macro) \ int prev = _buf.l; \ int z = sprintf( _buf.grow(maxSize) , macro , (val) ); \ + assert( z >= 0 ); \ _buf.l = prev + z; \ return *this; @@ -197,6 +198,17 @@ namespace mongo { } #undef SBNUM + void appendDoubleNice( double x ){ + int prev = _buf.l; + char * start = _buf.grow( 32 ); + int z = sprintf( start , "%.16g" , x ); + assert( z >= 0 ); + _buf.l = prev + z; + if( strchr(start, '.') == 0 && strchr(start, 'E') == 0 && strchr(start, 'N') == 0 ){ + write( ".0" , 2 ); + } + } + void write( const char* buf, int len){ memcpy( _buf.grow( len ) , buf , len ); } |