0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

set totalsize in bsonelement() if eoo element

This commit is contained in:
dwight 2011-05-11 10:28:28 -04:00
parent e0f23a5a16
commit ebbc72f17c
4 changed files with 70 additions and 5 deletions

View File

@ -372,24 +372,28 @@ namespace mongo {
// @param maxLen don't scan more than maxLen bytes
explicit BSONElement(const char *d, int maxLen) : data(d) {
fieldNameSize_ = -1;
if ( eoo() )
if ( eoo() ) {
totalSize = 1;
fieldNameSize_ = 0;
}
else {
totalSize = -1;
fieldNameSize_ = -1;
if ( maxLen != -1 ) {
int size = (int) strnlen( fieldName(), maxLen - 1 );
massert( 10333 , "Invalid field name", size != -1 );
fieldNameSize_ = size + 1;
}
}
totalSize = -1;
}
explicit BSONElement(const char *d) : data(d) {
fieldNameSize_ = -1;
if ( eoo() )
fieldNameSize_ = 0;
totalSize = -1;
if ( eoo() ) {
fieldNameSize_ = 0;
totalSize = 1;
}
}
string _asCode() const;

View File

@ -95,6 +95,9 @@ namespace JsobjTests {
public:
void run() {
ASSERT_EQUALS( 1, BSONElement().size() );
BSONObj x;
ASSERT_EQUALS( 1, x.firstElement().size() );
}
};

View File

@ -196,6 +196,19 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\boostw\boost_1_34_1\boost\config\auto_link.hpp" />
<ClInclude Include="..\bson\bson-inl.h" />
<ClInclude Include="..\bson\bson.h" />
<ClInclude Include="..\bson\bsonelement.h" />
<ClInclude Include="..\bson\bsonmisc.h" />
<ClInclude Include="..\bson\bsonobj.h" />
<ClInclude Include="..\bson\bsonobjbuilder.h" />
<ClInclude Include="..\bson\bsonobjiterator.h" />
<ClInclude Include="..\bson\bsontypes.h" />
<ClInclude Include="..\bson\bson_db.h" />
<ClInclude Include="..\bson\inline_decls.h" />
<ClInclude Include="..\bson\oid.h" />
<ClInclude Include="..\bson\ordering.h" />
<ClInclude Include="..\bson\stringdata.h" />
<ClInclude Include="..\db\dur.h" />
<ClInclude Include="..\db\durop.h" />
<ClInclude Include="..\db\dur_journal.h" />

View File

@ -53,6 +53,12 @@
<Filter Include="dur">
<UniqueIdentifier>{c296d097-0d46-46ee-9097-f2df659d9596}</UniqueIdentifier>
</Filter>
<Filter Include="db\NewFilter1">
<UniqueIdentifier>{ff8969fe-1912-42d5-86c4-f7077a7e5a24}</UniqueIdentifier>
</Filter>
<Filter Include="bson">
<UniqueIdentifier>{e6652333-c77f-420c-af8e-72d55bc095fe}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\boostw\boost_1_34_1\boost\config\auto_link.hpp">
@ -250,6 +256,45 @@
<ClInclude Include="..\util\checksum.h">
<Filter>util</Filter>
</ClInclude>
<ClInclude Include="..\bson\bson.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\bson_db.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\bsonelement.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\bson-inl.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\bsonmisc.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\bsonobj.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\bsonobjbuilder.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\bsonobjiterator.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\bsontypes.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\inline_decls.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\oid.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\ordering.h">
<Filter>bson</Filter>
</ClInclude>
<ClInclude Include="..\bson\stringdata.h">
<Filter>bson</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Library Include="..\..\js\js64r.lib">