small tweak to proto stuff
This commit is contained in:
1 parent
1ce9410565
commit
e20fb7df90
4 files changed
+35
-18
No files matched your search
@@ -43,7 +43,7 @@ namespace Protobuf
|
||||
|
||||
|
||||
|
||||
function encodeFilters(message as dynamic) as string
|
||||
function encodeFilters(message as dynamic, asByteArray = false as boolean) as dynamic
|
||||
buffer = CreateObject("roByteArray")
|
||||
writer = new Protobuf.BinaryWriter()
|
||||
writer.SetBuffer(buffer)
|
||||
@@ -104,10 +104,14 @@ namespace Protobuf
|
||||
value = message["features_vr180"]
|
||||
encoder.EncodeBool(26, value)
|
||||
end if
|
||||
return buffer.ToBase64String().EncodeUriComponent()
|
||||
if asByteArray
|
||||
return buffer
|
||||
else
|
||||
return buffer.ToBase64String().EncodeUriComponent()
|
||||
end if
|
||||
end function
|
||||
|
||||
function encodeSearchFilter(message as dynamic) as string
|
||||
function encodeSearchFilter(message as dynamic, asByteArray = false as boolean) as dynamic
|
||||
buffer = CreateObject("roByteArray")
|
||||
writer = new Protobuf.BinaryWriter()
|
||||
writer.SetBuffer(buffer)
|
||||
@@ -118,9 +122,13 @@ namespace Protobuf
|
||||
end if
|
||||
if message.DoesExist("filters")
|
||||
value = message["filters"]
|
||||
encoder.EncodeMessage(2, Protobuf.Generated.misc.encodeFilters(value))
|
||||
encoder.EncodeMessage(2, Protobuf.Generated.misc.encodeFilters(value, true))
|
||||
end if
|
||||
if asByteArray
|
||||
return buffer
|
||||
else
|
||||
return buffer.ToBase64String().EncodeUriComponent()
|
||||
end if
|
||||
return buffer.ToBase64String().EncodeUriComponent()
|
||||
end function
|
||||
|
||||
|
||||
|
||||
@@ -48,10 +48,12 @@ namespace Protobuf
|
||||
strBuffer = CreateObject("roByteArray")
|
||||
strBuffer.FromAsciiString(value)
|
||||
m.WriteVarInt(strBuffer.Count())
|
||||
for i = 0 to strBuffer.Count() - 1
|
||||
m.buffer[m.position + i] = strBuffer[i]
|
||||
end for
|
||||
m.position += strBuffer.Count()
|
||||
m.WriteByteArrayRaw(strBuffer, 0, strBuffer.Count())
|
||||
end function
|
||||
|
||||
function WriteProtoByteArray(value as dynamic) as void
|
||||
m.WriteVarInt(value.Count())
|
||||
m.WriteByteArrayRaw(value, 0, value.Count())
|
||||
end function
|
||||
|
||||
function WriteBool(value as dynamic) as void
|
||||
@@ -61,6 +63,14 @@ namespace Protobuf
|
||||
m.WriteByte(0)
|
||||
end if
|
||||
end function
|
||||
|
||||
function WriteByteArrayRaw(buffer as dynamic, index as dynamic, size as dynamic) as void
|
||||
position = m.position
|
||||
for i = 0 to size - 1
|
||||
m.buffer[position + i] = buffer[index + i]
|
||||
end for
|
||||
m.position += size
|
||||
end function
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -39,12 +39,7 @@ namespace Protobuf
|
||||
|
||||
function EncodeMessage(tag as integer, value as dynamic) as void
|
||||
m.writer.WriteByte((tag << 3) or 2)
|
||||
buffer = CreateObject("roByteArray")
|
||||
buffer.FromBase64String(value.DecodeUriComponent())
|
||||
m.writer.WriteVarInt(buffer.Count())
|
||||
for i = 0 to buffer.Count() - 1
|
||||
m.writer.WriteByte(buffer[i])
|
||||
end for
|
||||
m.writer.WriteProtoByteArray(value)
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
Reference in new issue
Block a user