diff options
author | UbitUmarov | 2018-11-30 23:13:21 +0000 |
---|---|---|
committer | UbitUmarov | 2018-11-30 23:13:21 +0000 |
commit | 60bc64a90f70dda1ad232c5f073ad7989ccb299c (patch) | |
tree | 1268cccf97913889738c815811f8741758e17922 /OpenSim/Framework/LLSDxmlEncode.cs | |
parent | move http range parser to util (diff) | |
download | opensim-SC-60bc64a90f70dda1ad232c5f073ad7989ccb299c.zip opensim-SC-60bc64a90f70dda1ad232c5f073ad7989ccb299c.tar.gz opensim-SC-60bc64a90f70dda1ad232c5f073ad7989ccb299c.tar.bz2 opensim-SC-60bc64a90f70dda1ad232c5f073ad7989ccb299c.tar.xz |
LLSDxmlencode uint and ulong
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/LLSDxmlEncode.cs | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/OpenSim/Framework/LLSDxmlEncode.cs b/OpenSim/Framework/LLSDxmlEncode.cs index ed0993d..102955d 100644 --- a/OpenSim/Framework/LLSDxmlEncode.cs +++ b/OpenSim/Framework/LLSDxmlEncode.cs | |||
@@ -147,11 +147,21 @@ namespace OpenSim.Framework | |||
147 | else | 147 | else |
148 | { | 148 | { |
149 | sb.Append("<integer>"); | 149 | sb.Append("<integer>"); |
150 | sb.Append(e.ToString()); | 150 | sb.Append(e.ToString()); |
151 | sb.Append("</integer>"); | 151 | sb.Append("</integer>"); |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | public static void AddElem(uint e, StringBuilder sb) | ||
156 | { | ||
157 | AddElem(uintToByteArray(e), sb); | ||
158 | } | ||
159 | |||
160 | public static void AddElem(ulong e, StringBuilder sb) | ||
161 | { | ||
162 | AddElem(ulongToByteArray(e), sb); | ||
163 | } | ||
164 | |||
155 | public static void AddElem(float e, StringBuilder sb) | 165 | public static void AddElem(float e, StringBuilder sb) |
156 | { | 166 | { |
157 | if(e == 0) | 167 | if(e == 0) |
@@ -266,7 +276,7 @@ namespace OpenSim.Framework | |||
266 | else | 276 | else |
267 | { | 277 | { |
268 | sb.Append("<real>"); | 278 | sb.Append("<real>"); |
269 | sb.Append(e.ToString(CultureInfo.InvariantCulture)); | 279 | sb.Append(e.ToString(CultureInfo.InvariantCulture)); |
270 | sb.Append("</real>"); | 280 | sb.Append("</real>"); |
271 | } | 281 | } |
272 | } | 282 | } |
@@ -414,7 +424,7 @@ namespace OpenSim.Framework | |||
414 | else | 424 | else |
415 | { | 425 | { |
416 | sb.Append("<integer>"); | 426 | sb.Append("<integer>"); |
417 | sb.Append(e.ToString()); | 427 | sb.Append(e.ToString()); |
418 | sb.Append("</integer>"); | 428 | sb.Append("</integer>"); |
419 | } | 429 | } |
420 | } | 430 | } |
@@ -430,7 +440,7 @@ namespace OpenSim.Framework | |||
430 | else | 440 | else |
431 | { | 441 | { |
432 | sb.Append("<binary>"); // encode64 is default | 442 | sb.Append("<binary>"); // encode64 is default |
433 | sb.Append(Convert.ToBase64String(e,Base64FormattingOptions.None)); | 443 | sb.Append(Convert.ToBase64String(e,Base64FormattingOptions.None)); |
434 | sb.Append("</binary>"); | 444 | sb.Append("</binary>"); |
435 | } | 445 | } |
436 | } | 446 | } |
@@ -446,11 +456,21 @@ namespace OpenSim.Framework | |||
446 | else | 456 | else |
447 | { | 457 | { |
448 | sb.Append("<integer>"); | 458 | sb.Append("<integer>"); |
449 | sb.Append(e.ToString()); | 459 | sb.Append(e.ToString()); |
450 | sb.Append("</integer>"); | 460 | sb.Append("</integer>"); |
451 | } | 461 | } |
452 | } | 462 | } |
453 | 463 | ||
464 | public static void AddElem(string name, uint e, StringBuilder sb) | ||
465 | { | ||
466 | AddElem(name, uintToByteArray(e), sb); | ||
467 | } | ||
468 | |||
469 | public static void AddElem(string name, ulong e, StringBuilder sb) | ||
470 | { | ||
471 | AddElem(name, ulongToByteArray(e), sb); | ||
472 | } | ||
473 | |||
454 | public static void AddElem(string name, float e, StringBuilder sb) | 474 | public static void AddElem(string name, float e, StringBuilder sb) |
455 | { | 475 | { |
456 | sb.Append("<key>"); | 476 | sb.Append("<key>"); |
@@ -579,7 +599,7 @@ namespace OpenSim.Framework | |||
579 | else | 599 | else |
580 | { | 600 | { |
581 | sb.Append("<real>"); | 601 | sb.Append("<real>"); |
582 | sb.Append(e.ToString(CultureInfo.InvariantCulture)); | 602 | sb.Append(e.ToString(CultureInfo.InvariantCulture)); |
583 | sb.Append("</real>"); | 603 | sb.Append("</real>"); |
584 | } | 604 | } |
585 | } | 605 | } |
@@ -611,7 +631,7 @@ namespace OpenSim.Framework | |||
611 | else | 631 | else |
612 | { | 632 | { |
613 | sb.Append("<string>"); | 633 | sb.Append("<string>"); |
614 | EscapeToXML(e.ToString(), sb); | 634 | EscapeToXML(e, sb); |
615 | sb.Append("</string>"); | 635 | sb.Append("</string>"); |
616 | } | 636 | } |
617 | } | 637 | } |
@@ -627,7 +647,7 @@ namespace OpenSim.Framework | |||
627 | else | 647 | else |
628 | { | 648 | { |
629 | sb.Append("<string>"); | 649 | sb.Append("<string>"); |
630 | sb.Append(e); | 650 | sb.Append(e); |
631 | sb.Append("</string>"); | 651 | sb.Append("</string>"); |
632 | } | 652 | } |
633 | } | 653 | } |
@@ -720,6 +740,32 @@ namespace OpenSim.Framework | |||
720 | break; | 740 | break; |
721 | } | 741 | } |
722 | } | 742 | } |
723 | } | 743 | } |
744 | |||
745 | public static byte[] ulongToByteArray(ulong uLongValue) | ||
746 | { | ||
747 | return new byte[8] | ||
748 | { | ||
749 | (byte)((uLongValue >> 56) & 0xff), | ||
750 | (byte)((uLongValue >> 48) & 0xff), | ||
751 | (byte)((uLongValue >> 40) & 0xff), | ||
752 | (byte)((uLongValue >> 32) & 0xff), | ||
753 | (byte)((uLongValue >> 24) & 0xff), | ||
754 | (byte)((uLongValue >> 16) & 0xff), | ||
755 | (byte)((uLongValue >> 8) & 0xff), | ||
756 | (byte)(uLongValue & 0xff) | ||
757 | }; | ||
758 | } | ||
759 | |||
760 | public static byte[] uintToByteArray(uint value) | ||
761 | { | ||
762 | return new byte[4] | ||
763 | { | ||
764 | (byte)((value >> 24) & 0xff), | ||
765 | (byte)((value >> 16) & 0xff), | ||
766 | (byte)((value >> 8) & 0xff), | ||
767 | (byte)(value & 0xff) | ||
768 | }; | ||
769 | } | ||
724 | } | 770 | } |
725 | } | 771 | } |