LLSDxmlencode uint and ulong

0.9.1.0-post-fixes
UbitUmarov 2018-11-30 23:13:21 +00:00
parent b783244a50
commit 60bc64a90f
1 changed files with 55 additions and 9 deletions

View File

@ -152,6 +152,16 @@ namespace OpenSim.Framework
}
}
public static void AddElem(uint e, StringBuilder sb)
{
AddElem(uintToByteArray(e), sb);
}
public static void AddElem(ulong e, StringBuilder sb)
{
AddElem(ulongToByteArray(e), sb);
}
public static void AddElem(float e, StringBuilder sb)
{
if(e == 0)
@ -451,6 +461,16 @@ namespace OpenSim.Framework
}
}
public static void AddElem(string name, uint e, StringBuilder sb)
{
AddElem(name, uintToByteArray(e), sb);
}
public static void AddElem(string name, ulong e, StringBuilder sb)
{
AddElem(name, ulongToByteArray(e), sb);
}
public static void AddElem(string name, float e, StringBuilder sb)
{
sb.Append("<key>");
@ -611,7 +631,7 @@ namespace OpenSim.Framework
else
{
sb.Append("<string>");
EscapeToXML(e.ToString(), sb);
EscapeToXML(e, sb);
sb.Append("</string>");
}
}
@ -720,6 +740,32 @@ namespace OpenSim.Framework
break;
}
}
}
}
public static byte[] ulongToByteArray(ulong uLongValue)
{
return new byte[8]
{
(byte)((uLongValue >> 56) & 0xff),
(byte)((uLongValue >> 48) & 0xff),
(byte)((uLongValue >> 40) & 0xff),
(byte)((uLongValue >> 32) & 0xff),
(byte)((uLongValue >> 24) & 0xff),
(byte)((uLongValue >> 16) & 0xff),
(byte)((uLongValue >> 8) & 0xff),
(byte)(uLongValue & 0xff)
};
}
public static byte[] uintToByteArray(uint value)
{
return new byte[4]
{
(byte)((value >> 24) & 0xff),
(byte)((value >> 16) & 0xff),
(byte)((value >> 8) & 0xff),
(byte)(value & 0xff)
};
}
}
}