Created
September 2, 2011 21:22
-
-
Save roxlu/1189963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool AMF3Serializer::WriteArray(IOBuffer &buffer, Variant &variant, bool writeType) { | |
WRITE_AMF3_TYPE(AMF3_ARRAY); | |
Variant v = variant; | |
uint32_t denseSize = v.MapDenseSize(); | |
for (uint32_t i = 0; i < denseSize; i++) { | |
v.RemoveAt(i); | |
} | |
if (!WriteU29(buffer, (denseSize << 1) | 0x01)) { | |
FATAL("Unable to write dense size"); | |
return false; | |
} | |
Variant key = ""; | |
FOR_MAP(v, string, Variant, i) { | |
key = MAP_KEY(i); | |
if (!WriteString(buffer, key, false)) { | |
FATAL("Unable to write key"); | |
return false; | |
} | |
if (!Write(buffer, MAP_VAL(i))) { | |
FATAL("Unable to write value"); | |
return false; | |
} | |
} | |
key = ""; | |
if (!WriteString(buffer, key, false)) { | |
FATAL("Unable to write key"); | |
return false; | |
} | |
for (uint32_t i = 0; i < denseSize; i++) { | |
if (!Write(buffer, variant[i])) { | |
FATAL("Unable to write value"); | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment