bsonelement.h | bsonelement.h | |||
---|---|---|---|---|
skipping to change at line 20 | skipping to change at line 20 | |||
* | * | |||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli ed. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli ed. | |||
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | |||
* limitations under the License. | * limitations under the License. | |||
*/ | */ | |||
#pragma once | #pragma once | |||
#include <boost/cstdint.hpp> | ||||
#include <string.h> // strlen | #include <string.h> // strlen | |||
#include <string> | #include <string> | |||
#include <vector> | #include <vector> | |||
#include "mongo/bson/bsontypes.h" | #include "mongo/bson/bsontypes.h" | |||
#include "mongo/bson/oid.h" | #include "mongo/bson/oid.h" | |||
#include "mongo/platform/float_utils.h" | #include "mongo/platform/float_utils.h" | |||
namespace mongo { | namespace mongo { | |||
class OpTime; | class OpTime; | |||
skipping to change at line 241 | skipping to change at line 242 | |||
/** Size (length) of a string element. | /** Size (length) of a string element. | |||
You must assure of type String first. | You must assure of type String first. | |||
@return string size including terminating null | @return string size including terminating null | |||
*/ | */ | |||
int valuestrsize() const { | int valuestrsize() const { | |||
return *reinterpret_cast< const int* >( value() ); | return *reinterpret_cast< const int* >( value() ); | |||
} | } | |||
// for objects the size *includes* the size of the size field | // for objects the size *includes* the size of the size field | |||
int objsize() const { | size_t objsize() const { | |||
return *reinterpret_cast< const int* >( value() ); | return static_cast< const size_t >( *reinterpret_cast< const ui | |||
nt32_t* >( value() ) ); | ||||
} | } | |||
/** Get a string's value. Also gives you start of the real data fo r an embedded object. | /** Get a string's value. Also gives you start of the real data fo r an embedded object. | |||
You must assure data is of an appropriate type first -- see als o valuestrsafe(). | You must assure data is of an appropriate type first -- see als o valuestrsafe(). | |||
*/ | */ | |||
const char * valuestr() const { | const char * valuestr() const { | |||
return value() + 4; | return value() + 4; | |||
} | } | |||
/** Get the string value of the element. If not a string returns " ". */ | /** Get the string value of the element. If not a string returns " ". */ | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 4 lines changed or added | |||
curop.h | curop.h | |||
---|---|---|---|---|
skipping to change at line 103 | skipping to change at line 103 | |||
} | } | |||
void reset( int sz = 0 ) { | void reset( int sz = 0 ) { | |||
_lock.lock(); | _lock.lock(); | |||
_reset( sz ); | _reset( sz ); | |||
_lock.unlock(); | _lock.unlock(); | |||
} | } | |||
void set( const BSONObj& o ) { | void set( const BSONObj& o ) { | |||
scoped_spinlock lk(_lock); | scoped_spinlock lk(_lock); | |||
int sz = o.objsize(); | size_t sz = o.objsize(); | |||
if ( sz > (int) sizeof(_buf) ) { | if ( sz > sizeof(_buf) ) { | |||
_reset(TOO_BIG_SENTINEL); | _reset(TOO_BIG_SENTINEL); | |||
} | } | |||
else { | else { | |||
memcpy(_buf, o.objdata(), sz ); | memcpy(_buf, o.objdata(), sz ); | |||
} | } | |||
} | } | |||
int size() const { return *_size; } | int size() const { return *_size; } | |||
bool have() const { return size() > 0; } | bool have() const { return size() > 0; } | |||
End of changes. 1 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added | |||