pi_msgpack.txt 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. *pi_msgpack.txt* msgpack utilities
  2. Author: Nikolay Pavlov <kp-pav@yandex.ru>
  3. Copyright: (c) 2015 by Nikolay Pavlov
  4. The Apache license applies to the files in this package, including
  5. runtime/autoload/msgpack.vim, runtime/doc/pi_msgpack.txt and
  6. test/functional/plugin/msgpack_spec.lua. Like anything else that's free,
  7. msgpack.vim and its associated files are provided *as is* and comes with no
  8. warranty of any kind, either expressed or implied. No guarantees of
  9. merchantability. No guarantees of suitability for any purpose. By using this
  10. plugin, you agree that in no event will the copyright holder be liable for any
  11. damages resulting from the use of this software. Use at your own risk!
  12. ==============================================================================
  13. 1. Contents *msgpack.vim-contents*
  14. 1. Contents..............................: |msgpack.vim-contents|
  15. 2. Msgpack.vim introduction..............: |msgpack.vim-intro|
  16. 3. Msgpack.vim manual....................: |msgpack.vim-manual|
  17. Function arguments....................: |msgpack.vim-arguments|
  18. msgpack#is_int function...............: |msgpack#is_int()|
  19. msgpack#is_uint function..............: |msgpack#is_uint()|
  20. msgpack#strftime function.............: |msgpack#strftime()|
  21. msgpack#strptime function.............: |msgpack#strptime()|
  22. msgpack#int_dict_to_str function......: |msgpack#int_dict_to_str()|
  23. msgpack#special_type function.........: |msgpack#special_type()|
  24. msgpack#type function.................: |msgpack#type()|
  25. msgpack#deepcopy function.............: |msgpack#deepcopy()|
  26. msgpack#string function...............: |msgpack#string()|
  27. msgpack#eval function.................: |msgpack#eval()|
  28. msgpack#equal function................: |msgpack#equal()|
  29. ==============================================================================
  30. 2. Msgpack.vim introduction *msgpack.vim-intro*
  31. This plugin contains utility functions to be used in conjunction with
  32. |msgpackdump()| and |msgpackparse()| functions.
  33. ==============================================================================
  34. 3. Msgpack.vim manual *msgpack.vim-manual*
  35. FUNCTION ARGUMENTS *msgpack.vim-arguments*
  36. Disambiguation of arguments described below. Note: if e.g. function is listed
  37. as accepting |{msgpack-integer}| (or anything else) it means that function
  38. does not check whether argument matches its description.
  39. *{msgpack-value}* Either |msgpack-special-dict| or a regular value, but
  40. not function reference.
  41. *{msgpack-integer}* Any value for which |msgpack#type()| will return
  42. "integer".
  43. *{msgpack-special-int}* |msgpack-special-dict| representing integer.
  44. msgpack#is_int({msgpack-value}) *msgpack#is_int()*
  45. Returns 1 if given {msgpack-value} is integer value, 0 otherwise.
  46. msgpack#is_uint({msgpack-value}) *msgpack#is_uint()*
  47. Returns 1 if given {msgpack-value} is integer value greater or equal
  48. to zero, 0 otherwise.
  49. *msgpack#strftime*
  50. msgpack#strftime({format}, {msgpack-integer}) *msgpack#strftime()*
  51. Same as |strftime()|, but second argument may be
  52. |msgpack-special-dict|. Requires |Python| to really work with
  53. |msgpack-special-dict|s.
  54. *msgpack#strptime*
  55. msgpack#strptime({format}, {time}) *msgpack#strptime()*
  56. Reverse of |msgpack#strftime()|: for any time and format
  57. |msgpack#equal|( |msgpack#strptime|(format, |msgpack#strftime|(format,
  58. time)), time) be true. Requires ||Python|, without it only supports
  59. non-|msgpack-special-dict| nonnegative times and format equal to
  60. `%Y-%m-%dT%H:%M:%S`.
  61. msgpack#int_dict_to_str({msgpack-special-int}) *msgpack#int_dict_to_str()*
  62. Function which converts |msgpack-special-dict| integer value to
  63. a hexadecimal value like 0x1234567890ABCDEF (always returns exactly 16
  64. hexadecimal digits).
  65. msgpack#special_type({msgpack-value}) *msgpack#special_type()*
  66. Returns zero if {msgpack-value} is not |msgpack-special-dict|. If it
  67. is it returns name of the key in |v:msgpack_types| which represents
  68. {msgpack-value} type.
  69. msgpack#type({msgpack-value}) *msgpack#type()*
  70. Returns name of the key in |v:msgpack_types| that represents
  71. {msgpack-value} type. Never returns zero: this function returns
  72. msgpack type which will be dumped by |msgpackdump()| should it receive
  73. a list with single {msgpack-value} as input.
  74. msgpack#deepcopy({msgpack-value}) *msgpack#deepcopy()*
  75. Like |deepcopy()|, but works correctly with |msgpack-special-dict|
  76. values. Plain |deepcopy()| will destroy all types in
  77. |msgpack-special-dict| values because it will copy _TYPE key values,
  78. while they should be preserved.
  79. msgpack#string({msgpack-value}) *msgpack#string()*
  80. Like |string()|, but saves information about msgpack types. Values
  81. dumped by msgpack#string may be read back by |msgpack#eval()|.
  82. Returns is the following:
  83. - Dictionaries are dumped as "{key1: value1, key2: value2}". Note:
  84. msgpack allows any values in keys, so with some
  85. |msgpack-special-dict| values |msgpack#string()| may produce even
  86. "{{1: 2}: 3, [4]: 5}".
  87. - Lists are dumped as "[value1, value2]".
  88. - Strings are dumped as
  89. 1. `"abc"`: binary string.
  90. 2. `="abc"`: string.
  91. 3. `+(10)"ext"`: extension strings (10 may be replaced with any
  92. 8-bit signed integer).
  93. Inside strings the following escape sequences may be present: "\0"
  94. (represents NUL byte), "\n" (represents line feed) and "\""
  95. (represents double quote).
  96. - Floating-point and integer values are dumped using |string()| or
  97. |msgpack#int_dict_to_str()|.
  98. - Booleans are dumped as "TRUE" or "FALSE".
  99. - Nil values are dumped as "NIL".
  100. msgpack#eval({string}, {dict}) *msgpack#eval()*
  101. Transforms string created by |msgpack#string()| into a value suitable
  102. for |msgpackdump()|. Second argument allows adding special values
  103. that start with head characters (|/\h|) and contain only word
  104. characters (|/\w|). Built-in special values are "TRUE", "FALSE",
  105. "NIL", "nan" and "inf" and they cannot be overridden. Map values are
  106. always evaluated to |msgpack-special-dict| values, as well as
  107. hexadecimal digits. When evaluating maps order of keys is preserved.
  108. Note that in addition to regular integer representations that may be
  109. obtained using |msgpack#string()| msgpack#eval() also supports C-style
  110. “character” integer constants like `'/'` (equivalent to
  111. `char2nr('/')`: `47`). This also allows `'\0'` (number is decimal).
  112. *msgpack#equal*
  113. msgpack#equal({msgpack-value}, {msgpack-value}) *msgpack#equal()*
  114. Returns 1 if given values are equal, 0 otherwise. When comparing
  115. msgpack map values order of keys is ignored. Comparing
  116. |msgpack-special-dict| with equivalent non-special-dict value
  117. evaluates to 1.
  118. ==============================================================================
  119. vim:tw=78:ts=8:ft=help:fdm=marker