Remove ustring

This commit is contained in:
roblabla 2015-05-23 10:27:35 +00:00
parent 2b1a0f86cd
commit 3815201792
2 changed files with 4 additions and 15 deletions

View File

@ -32,7 +32,7 @@
"fields": [
{
"name": "response",
"type": "ustring"
"type": "string"
}
]
},
@ -231,7 +231,7 @@
"fields": [
{
"name": "message",
"type": "ustring"
"type": "string"
},
{
"name": "position",
@ -1741,7 +1741,7 @@
},
{
"name": "value",
"type": "ustring"
"type": "string"
},
{
"name": "isSigned",
@ -1751,7 +1751,7 @@
"name": "signature",
"type": "condition",
"typeArgs": {
"type": "ustring",
"type": "string",
"field": "isSigned",
"values": [
true

View File

@ -1,14 +1,11 @@
var assert = require('assert');
var STRING_MAX_LENGTH = 240;
var SRV_STRING_MAX_LENGTH = 32767;
var getField = require("../utils").getField;
module.exports = {
'varint': [readVarInt, writeVarInt, sizeOfVarInt],
'bool': [readBool, writeBool, 1],
'string': [readString, writeString, sizeOfString],
'ustring': [readString, writeString, sizeOfUString], // TODO : remove ustring
'buffer': [readBuffer, writeBuffer, sizeOfBuffer]
};
@ -81,7 +78,6 @@ function writeString(value, buffer, offset) {
function sizeOfString(value) {
var length = Buffer.byteLength(value, 'utf8');
assert.ok(length < STRING_MAX_LENGTH, "string greater than max length");
return sizeOfVarInt(length) + length;
}
@ -116,10 +112,3 @@ function writeBuffer(value, buffer, offset) {
function sizeOfBuffer(value) {
return value.length;
}
function sizeOfUString(value) {
var length = Buffer.byteLength(value, 'utf8');
assert.ok(length < SRV_STRING_MAX_LENGTH, "string greater than max length");
return sizeOfVarInt(length) + length;
}