zeroc-ice 3.6.5 → 3.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (777) hide show
  1. checksums.yaml +5 -5
  2. data/ICE_LICENSE +17 -17
  3. data/LICENSE +12 -12
  4. data/bin/slice2rb +1 -6
  5. data/ext/Communicator.cpp +223 -61
  6. data/ext/Communicator.h +1 -6
  7. data/ext/Config.h +23 -7
  8. data/ext/Connection.cpp +108 -76
  9. data/ext/Connection.h +4 -6
  10. data/ext/Endpoint.cpp +16 -54
  11. data/ext/Endpoint.h +1 -6
  12. data/ext/ImplicitContext.cpp +1 -10
  13. data/ext/ImplicitContext.h +1 -6
  14. data/ext/Init.cpp +4 -6
  15. data/ext/Logger.cpp +1 -6
  16. data/ext/Logger.h +1 -6
  17. data/ext/Operation.cpp +38 -54
  18. data/ext/Operation.h +1 -6
  19. data/ext/Properties.cpp +3 -8
  20. data/ext/Properties.h +1 -6
  21. data/ext/Proxy.cpp +111 -70
  22. data/ext/Proxy.h +1 -6
  23. data/ext/Slice.cpp +5 -20
  24. data/ext/Slice.h +1 -6
  25. data/ext/Types.cpp +313 -224
  26. data/ext/Types.h +118 -71
  27. data/ext/Util.cpp +69 -36
  28. data/ext/Util.h +117 -42
  29. data/ext/ValueFactoryManager.cpp +440 -0
  30. data/ext/ValueFactoryManager.h +95 -0
  31. data/ext/extconf.rb +52 -48
  32. data/ext/ice/cpp/include/Ice/Application.h +275 -105
  33. data/ext/ice/cpp/include/Ice/AsyncResult.h +124 -337
  34. data/ext/ice/cpp/include/Ice/AsyncResultF.h +4 -7
  35. data/ext/ice/cpp/include/Ice/BatchRequestInterceptor.h +39 -16
  36. data/ext/ice/cpp/include/Ice/BatchRequestQueueF.h +1 -6
  37. data/ext/ice/cpp/include/Ice/Buffer.h +10 -15
  38. data/ext/ice/cpp/include/Ice/CommunicatorAsync.h +56 -17
  39. data/ext/ice/cpp/include/Ice/Comparable.h +205 -0
  40. data/ext/ice/cpp/include/Ice/Config.h +16 -39
  41. data/ext/ice/cpp/include/Ice/ConnectionAsync.h +203 -16
  42. data/ext/ice/cpp/include/Ice/ConnectionIF.h +7 -6
  43. data/ext/ice/cpp/include/Ice/ConsoleUtil.h +23 -0
  44. data/ext/ice/cpp/include/Ice/DefaultValueFactory.h +57 -0
  45. data/ext/ice/cpp/include/Ice/DispatchInterceptor.h +20 -12
  46. data/ext/ice/cpp/include/Ice/Dispatcher.h +35 -19
  47. data/ext/ice/cpp/include/Ice/DynamicLibrary.h +7 -10
  48. data/ext/ice/cpp/include/Ice/DynamicLibraryF.h +1 -6
  49. data/ext/ice/cpp/include/Ice/Exception.h +110 -63
  50. data/ext/ice/cpp/include/Ice/ExceptionHelpers.h +74 -0
  51. data/ext/ice/cpp/include/Ice/FactoryTable.h +22 -18
  52. data/ext/ice/cpp/include/Ice/FactoryTableInit.h +28 -31
  53. data/ext/ice/cpp/include/Ice/Format.h +17 -18
  54. data/ext/ice/cpp/include/Ice/Functional.h +38 -38
  55. data/ext/ice/cpp/include/Ice/GCObject.h +9 -10
  56. data/ext/ice/cpp/include/Ice/Handle.h +6 -16
  57. data/ext/ice/cpp/include/Ice/Ice.h +9 -10
  58. data/ext/ice/cpp/include/Ice/IconvStringConverter.h +377 -0
  59. data/ext/ice/cpp/include/Ice/Incoming.h +132 -38
  60. data/ext/ice/cpp/include/Ice/IncomingAsync.h +109 -31
  61. data/ext/ice/cpp/include/Ice/IncomingAsyncF.h +7 -6
  62. data/ext/ice/cpp/include/Ice/Initialize.h +872 -60
  63. data/ext/ice/cpp/include/Ice/InputStream.h +1514 -0
  64. data/ext/ice/cpp/include/Ice/InstanceF.h +1 -7
  65. data/ext/ice/cpp/include/Ice/InterfaceByValue.h +57 -0
  66. data/ext/ice/cpp/include/Ice/LocalObject.h +13 -14
  67. data/ext/ice/cpp/include/Ice/LocalObjectF.h +1 -6
  68. data/ext/ice/cpp/include/Ice/LoggerUtil.h +56 -24
  69. data/ext/ice/cpp/include/Ice/MetricsAdminI.h +124 -71
  70. data/ext/ice/cpp/include/Ice/MetricsFunctional.h +25 -10
  71. data/ext/ice/cpp/include/Ice/MetricsObserverI.h +116 -32
  72. data/ext/ice/cpp/include/Ice/NativePropertiesAdmin.h +61 -30
  73. data/ext/ice/cpp/include/Ice/Object.h +413 -78
  74. data/ext/ice/cpp/include/Ice/ObjectF.h +12 -8
  75. data/ext/ice/cpp/include/Ice/ObserverHelper.h +18 -13
  76. data/ext/ice/cpp/include/Ice/Optional.h +1114 -0
  77. data/ext/ice/cpp/include/Ice/OutgoingAsync.h +684 -89
  78. data/ext/ice/cpp/include/Ice/OutgoingAsyncF.h +12 -11
  79. data/ext/ice/cpp/include/Ice/OutputStream.h +1092 -0
  80. data/ext/ice/cpp/include/Ice/Protocol.h +49 -17
  81. data/ext/ice/cpp/include/Ice/Proxy.h +3438 -745
  82. data/ext/ice/cpp/include/Ice/ProxyF.h +13 -38
  83. data/ext/ice/cpp/include/Ice/ProxyFactoryF.h +1 -6
  84. data/ext/ice/cpp/include/Ice/ProxyHandle.h +43 -55
  85. data/ext/ice/cpp/include/Ice/ReferenceF.h +1 -6
  86. data/ext/ice/cpp/include/Ice/RegisterPlugins.h +84 -12
  87. data/ext/ice/cpp/include/Ice/RequestHandlerF.h +10 -9
  88. data/ext/ice/cpp/include/Ice/ResponseHandlerF.h +6 -6
  89. data/ext/ice/cpp/include/Ice/SHA1.h +42 -0
  90. data/ext/ice/cpp/include/Ice/ServantManagerF.h +1 -6
  91. data/ext/ice/cpp/include/Ice/Service.h +273 -154
  92. data/ext/ice/cpp/include/Ice/SliceChecksums.h +5 -6
  93. data/ext/ice/cpp/include/Ice/SlicedData.h +121 -53
  94. data/ext/ice/cpp/include/Ice/SlicedDataF.h +17 -11
  95. data/ext/ice/cpp/include/Ice/StreamHelpers.h +453 -140
  96. data/ext/ice/cpp/include/Ice/StringConverter.h +78 -0
  97. data/ext/ice/cpp/include/Ice/ThreadPoolF.h +1 -6
  98. data/ext/ice/cpp/include/Ice/UUID.h +19 -0
  99. data/ext/ice/cpp/include/{IceUtil → Ice}/UniquePtr.h +22 -28
  100. data/ext/ice/cpp/include/Ice/UniqueRef.h +97 -0
  101. data/ext/ice/cpp/include/Ice/UserExceptionFactory.h +45 -13
  102. data/ext/ice/cpp/include/Ice/Value.h +139 -0
  103. data/ext/ice/cpp/include/Ice/ValueF.h +21 -0
  104. data/ext/ice/cpp/include/IceSSL/Config.h +8 -28
  105. data/ext/ice/cpp/include/IceSSL/IceSSL.h +17 -11
  106. data/ext/ice/cpp/include/IceSSL/OpenSSL.h +147 -0
  107. data/ext/ice/cpp/include/IceSSL/Plugin.h +461 -448
  108. data/ext/ice/cpp/include/IceSSL/SChannel.h +72 -0
  109. data/ext/ice/cpp/include/IceSSL/SecureTransport.h +72 -0
  110. data/ext/ice/cpp/include/IceSSL/UWP.h +62 -0
  111. data/ext/ice/cpp/include/IceUtil/Atomic.h +7 -14
  112. data/ext/ice/cpp/include/IceUtil/Cond.h +17 -23
  113. data/ext/ice/cpp/include/IceUtil/Config.h +166 -46
  114. data/ext/ice/cpp/include/IceUtil/ConsoleUtil.h +92 -0
  115. data/ext/ice/cpp/include/IceUtil/CountDownLatch.h +5 -10
  116. data/ext/ice/cpp/include/IceUtil/CtrlCHandler.h +63 -41
  117. data/ext/ice/cpp/include/IceUtil/DisableWarnings.h +5 -13
  118. data/ext/ice/cpp/include/IceUtil/Exception.h +284 -75
  119. data/ext/ice/cpp/include/IceUtil/FileUtil.h +143 -0
  120. data/ext/ice/cpp/include/IceUtil/Functional.h +4 -6
  121. data/ext/ice/cpp/include/IceUtil/Handle.h +11 -16
  122. data/ext/ice/cpp/include/IceUtil/IceUtil.h +4 -15
  123. data/ext/ice/cpp/include/IceUtil/InputUtil.h +3 -8
  124. data/ext/ice/cpp/include/IceUtil/Iterator.h +2 -7
  125. data/ext/ice/cpp/include/IceUtil/Lock.h +8 -15
  126. data/ext/ice/cpp/include/IceUtil/Monitor.h +1 -7
  127. data/ext/ice/cpp/include/IceUtil/Mutex.h +19 -23
  128. data/ext/ice/cpp/include/IceUtil/MutexProtocol.h +2 -7
  129. data/ext/ice/cpp/include/IceUtil/MutexPtrLock.h +4 -9
  130. data/ext/ice/cpp/include/IceUtil/MutexPtrTryLock.h +4 -9
  131. data/ext/ice/cpp/include/IceUtil/Optional.h +134 -23
  132. data/ext/ice/cpp/include/IceUtil/Options.h +17 -23
  133. data/ext/ice/cpp/include/IceUtil/OutputUtil.h +61 -37
  134. data/ext/ice/cpp/include/IceUtil/PopDisableWarnings.h +6 -11
  135. data/ext/ice/cpp/include/IceUtil/PushDisableWarnings.h +18 -15
  136. data/ext/ice/cpp/include/IceUtil/Random.h +39 -8
  137. data/ext/ice/cpp/include/IceUtil/RecMutex.h +7 -13
  138. data/ext/ice/cpp/include/IceUtil/ResourceConfig.h +53 -0
  139. data/ext/ice/cpp/include/IceUtil/ScannerConfig.h +10 -15
  140. data/ext/ice/cpp/include/IceUtil/ScopedArray.h +8 -7
  141. data/ext/ice/cpp/include/IceUtil/Shared.h +5 -12
  142. data/ext/ice/cpp/{src → include}/IceUtil/StopWatch.h +2 -7
  143. data/ext/ice/cpp/include/IceUtil/StringConverter.h +146 -126
  144. data/ext/ice/cpp/include/IceUtil/StringUtil.h +32 -26
  145. data/ext/ice/cpp/include/IceUtil/Thread.h +10 -17
  146. data/ext/ice/cpp/include/IceUtil/ThreadException.h +33 -47
  147. data/ext/ice/cpp/include/IceUtil/Time.h +3 -8
  148. data/ext/ice/cpp/include/IceUtil/Timer.h +18 -18
  149. data/ext/ice/cpp/include/IceUtil/UUID.h +6 -7
  150. data/ext/ice/cpp/include/IceUtil/UndefSysMacros.h +1 -6
  151. data/ext/ice/cpp/include/generated/Ice/BuiltinSequences.h +170 -0
  152. data/ext/ice/cpp/include/generated/Ice/Communicator.h +1156 -0
  153. data/ext/ice/cpp/include/{Ice → generated/Ice}/CommunicatorF.h +51 -16
  154. data/ext/ice/cpp/include/generated/Ice/Connection.h +1660 -0
  155. data/ext/ice/cpp/include/generated/Ice/ConnectionF.h +119 -0
  156. data/ext/ice/cpp/include/generated/Ice/Current.h +322 -0
  157. data/ext/ice/cpp/include/generated/Ice/Endpoint.h +943 -0
  158. data/ext/ice/cpp/include/generated/Ice/EndpointF.h +166 -0
  159. data/ext/ice/cpp/include/generated/Ice/EndpointTypes.h +118 -0
  160. data/ext/ice/cpp/include/{Ice → generated/Ice}/FacetMap.h +31 -15
  161. data/ext/ice/cpp/include/generated/Ice/Identity.h +264 -0
  162. data/ext/ice/cpp/include/generated/Ice/ImplicitContext.h +278 -0
  163. data/ext/ice/cpp/include/{Ice → generated/Ice}/ImplicitContextF.h +51 -16
  164. data/ext/ice/cpp/include/generated/Ice/Instrumentation.h +1143 -0
  165. data/ext/ice/cpp/include/generated/Ice/InstrumentationF.h +128 -0
  166. data/ext/ice/cpp/include/generated/Ice/LocalException.h +7041 -0
  167. data/ext/ice/cpp/include/generated/Ice/Locator.h +3850 -0
  168. data/ext/ice/cpp/include/generated/Ice/LocatorF.h +147 -0
  169. data/ext/ice/cpp/include/generated/Ice/Logger.h +231 -0
  170. data/ext/ice/cpp/include/{Ice → generated/Ice}/LoggerF.h +51 -16
  171. data/ext/ice/cpp/include/generated/Ice/Metrics.h +4717 -0
  172. data/ext/ice/cpp/include/generated/Ice/ObjectAdapter.h +1175 -0
  173. data/ext/ice/cpp/include/{Ice → generated/Ice}/ObjectAdapterF.h +51 -16
  174. data/ext/ice/cpp/include/generated/Ice/ObjectFactory.h +197 -0
  175. data/ext/ice/cpp/include/generated/Ice/Plugin.h +306 -0
  176. data/ext/ice/cpp/include/generated/Ice/PluginF.h +110 -0
  177. data/ext/ice/cpp/include/generated/Ice/Process.h +971 -0
  178. data/ext/ice/cpp/include/generated/Ice/ProcessF.h +125 -0
  179. data/ext/ice/cpp/include/generated/Ice/Properties.h +446 -0
  180. data/ext/ice/cpp/include/generated/Ice/PropertiesAdmin.h +1360 -0
  181. data/ext/ice/cpp/include/generated/Ice/PropertiesF.h +134 -0
  182. data/ext/ice/cpp/include/generated/Ice/RemoteLogger.h +2689 -0
  183. data/ext/ice/cpp/include/generated/Ice/Router.h +1838 -0
  184. data/ext/ice/cpp/include/generated/Ice/RouterF.h +125 -0
  185. data/ext/ice/cpp/include/generated/Ice/ServantLocator.h +299 -0
  186. data/ext/ice/cpp/include/{Ice → generated/Ice}/ServantLocatorF.h +51 -16
  187. data/ext/ice/cpp/include/{Ice → generated/Ice}/SliceChecksumDict.h +34 -14
  188. data/ext/ice/cpp/include/generated/Ice/ValueFactory.h +318 -0
  189. data/ext/ice/cpp/include/generated/Ice/Version.h +357 -0
  190. data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfo.h +223 -0
  191. data/ext/ice/cpp/include/generated/IceSSL/ConnectionInfoF.h +101 -0
  192. data/ext/ice/cpp/include/generated/IceSSL/EndpointInfo.h +181 -0
  193. data/ext/ice/cpp/src/Ice/ACM.cpp +38 -27
  194. data/ext/ice/cpp/src/Ice/ACM.h +9 -7
  195. data/ext/ice/cpp/src/Ice/ACMF.h +30 -0
  196. data/ext/ice/cpp/src/Ice/Acceptor.cpp +6 -6
  197. data/ext/ice/cpp/src/Ice/Acceptor.h +4 -8
  198. data/ext/ice/cpp/src/Ice/AcceptorF.h +1 -6
  199. data/ext/ice/cpp/src/Ice/ArgVector.cpp +59 -0
  200. data/ext/ice/cpp/src/Ice/ArgVector.h +36 -0
  201. data/ext/ice/cpp/src/Ice/AsyncResult.cpp +15 -544
  202. data/ext/ice/cpp/src/Ice/Base64.cpp +22 -28
  203. data/ext/ice/cpp/src/Ice/Base64.h +1 -6
  204. data/ext/ice/cpp/src/Ice/BatchRequestQueue.cpp +41 -18
  205. data/ext/ice/cpp/src/Ice/BatchRequestQueue.h +15 -15
  206. data/ext/ice/cpp/src/Ice/Buffer.cpp +75 -18
  207. data/ext/ice/cpp/src/Ice/BuiltinSequences.cpp +21 -12
  208. data/ext/ice/cpp/src/Ice/CollocatedRequestHandler.cpp +86 -197
  209. data/ext/ice/cpp/src/Ice/CollocatedRequestHandler.h +17 -23
  210. data/ext/ice/cpp/src/Ice/Communicator.cpp +43 -15
  211. data/ext/ice/cpp/src/Ice/CommunicatorF.cpp +28 -11
  212. data/ext/ice/cpp/src/Ice/CommunicatorI.cpp +318 -117
  213. data/ext/ice/cpp/src/Ice/CommunicatorI.h +95 -40
  214. data/ext/ice/cpp/src/{IceUtil → Ice}/Cond.cpp +3 -8
  215. data/ext/ice/cpp/src/Ice/ConnectRequestHandler.cpp +55 -122
  216. data/ext/ice/cpp/src/Ice/ConnectRequestHandler.h +15 -31
  217. data/ext/ice/cpp/src/Ice/ConnectRequestHandlerF.h +6 -7
  218. data/ext/ice/cpp/src/Ice/Connection.cpp +111 -20
  219. data/ext/ice/cpp/src/Ice/ConnectionF.cpp +28 -11
  220. data/ext/ice/cpp/src/Ice/ConnectionFactory.cpp +300 -107
  221. data/ext/ice/cpp/src/Ice/ConnectionFactory.h +44 -28
  222. data/ext/ice/cpp/src/Ice/ConnectionFactoryF.h +30 -0
  223. data/ext/ice/cpp/src/Ice/ConnectionI.cpp +785 -713
  224. data/ext/ice/cpp/src/Ice/ConnectionI.h +105 -80
  225. data/ext/ice/cpp/src/Ice/ConnectionRequestHandler.cpp +2 -20
  226. data/ext/ice/cpp/src/Ice/ConnectionRequestHandler.h +5 -9
  227. data/ext/ice/cpp/src/Ice/Connector.cpp +6 -6
  228. data/ext/ice/cpp/src/Ice/Connector.h +4 -8
  229. data/ext/ice/cpp/src/Ice/ConnectorF.h +1 -6
  230. data/ext/ice/cpp/src/{IceUtil → Ice}/CountDownLatch.cpp +4 -9
  231. data/ext/ice/cpp/src/Ice/Current.cpp +30 -12
  232. data/ext/ice/cpp/src/Ice/DefaultsAndOverrides.cpp +10 -16
  233. data/ext/ice/cpp/src/Ice/DefaultsAndOverrides.h +1 -6
  234. data/ext/ice/cpp/src/Ice/DefaultsAndOverridesF.h +1 -6
  235. data/ext/ice/cpp/src/Ice/DispatchInterceptor.cpp +13 -25
  236. data/ext/ice/cpp/src/Ice/DynamicLibrary.cpp +34 -28
  237. data/ext/ice/cpp/src/Ice/Endpoint.cpp +107 -19
  238. data/ext/ice/cpp/src/Ice/EndpointF.cpp +28 -11
  239. data/ext/ice/cpp/src/Ice/EndpointFactory.cpp +152 -6
  240. data/ext/ice/cpp/src/Ice/EndpointFactory.h +72 -11
  241. data/ext/ice/cpp/src/Ice/EndpointFactoryF.h +1 -6
  242. data/ext/ice/cpp/src/Ice/EndpointFactoryManager.cpp +41 -36
  243. data/ext/ice/cpp/src/Ice/EndpointFactoryManager.h +10 -9
  244. data/ext/ice/cpp/src/Ice/EndpointFactoryManagerF.h +1 -6
  245. data/ext/ice/cpp/src/Ice/EndpointI.cpp +18 -7
  246. data/ext/ice/cpp/src/Ice/EndpointI.h +39 -18
  247. data/ext/ice/cpp/src/Ice/EndpointIF.h +18 -10
  248. data/ext/ice/cpp/src/Ice/EndpointTypes.cpp +19 -12
  249. data/ext/ice/cpp/src/Ice/EventHandler.cpp +6 -9
  250. data/ext/ice/cpp/src/Ice/EventHandler.h +13 -13
  251. data/ext/ice/cpp/src/Ice/EventHandlerF.h +5 -7
  252. data/ext/ice/cpp/src/Ice/Exception.cpp +102 -98
  253. data/ext/ice/cpp/src/Ice/FacetMap.cpp +21 -12
  254. data/ext/ice/cpp/src/Ice/FactoryTable.cpp +37 -33
  255. data/ext/ice/cpp/src/Ice/FactoryTableInit.cpp +2 -9
  256. data/ext/ice/cpp/src/Ice/GCObject.cpp +29 -31
  257. data/ext/ice/cpp/src/Ice/HashUtil.h +3 -9
  258. data/ext/ice/cpp/src/Ice/HttpParser.cpp +1 -7
  259. data/ext/ice/cpp/src/Ice/HttpParser.h +1 -6
  260. data/ext/ice/cpp/src/Ice/IPEndpointI.cpp +128 -111
  261. data/ext/ice/cpp/src/Ice/IPEndpointI.h +23 -19
  262. data/ext/ice/cpp/src/Ice/IPEndpointIF.h +6 -7
  263. data/ext/ice/cpp/src/Ice/IconvStringConverter.cpp +51 -0
  264. data/ext/ice/cpp/src/Ice/Identity.cpp +25 -16
  265. data/ext/ice/cpp/src/Ice/ImplicitContext.cpp +41 -13
  266. data/ext/ice/cpp/src/Ice/ImplicitContextF.cpp +28 -11
  267. data/ext/ice/cpp/src/Ice/ImplicitContextI.cpp +11 -28
  268. data/ext/ice/cpp/src/Ice/ImplicitContextI.h +7 -10
  269. data/ext/ice/cpp/src/Ice/Incoming.cpp +284 -255
  270. data/ext/ice/cpp/src/Ice/IncomingAsync.cpp +104 -214
  271. data/ext/ice/cpp/src/Ice/IncomingRequest.h +5 -9
  272. data/ext/ice/cpp/src/Ice/Initialize.cpp +309 -193
  273. data/ext/ice/cpp/src/Ice/InputStream.cpp +2726 -0
  274. data/ext/ice/cpp/src/Ice/Instance.cpp +243 -262
  275. data/ext/ice/cpp/src/Ice/Instance.h +30 -23
  276. data/ext/ice/cpp/src/Ice/Instrumentation.cpp +137 -23
  277. data/ext/ice/cpp/src/Ice/InstrumentationF.cpp +28 -11
  278. data/ext/ice/cpp/src/Ice/InstrumentationI.cpp +118 -105
  279. data/ext/ice/cpp/src/Ice/InstrumentationI.h +30 -36
  280. data/ext/ice/cpp/src/Ice/LocalException.cpp +1191 -422
  281. data/ext/ice/cpp/src/Ice/LocalObject.cpp +1 -7
  282. data/ext/ice/cpp/src/Ice/Locator.cpp +1282 -1222
  283. data/ext/ice/cpp/src/Ice/LocatorF.cpp +30 -12
  284. data/ext/ice/cpp/src/Ice/LocatorInfo.cpp +150 -186
  285. data/ext/ice/cpp/src/Ice/LocatorInfo.h +31 -36
  286. data/ext/ice/cpp/src/Ice/LocatorInfoF.h +1 -6
  287. data/ext/ice/cpp/src/Ice/Logger.cpp +39 -12
  288. data/ext/ice/cpp/src/Ice/LoggerAdminI.cpp +182 -88
  289. data/ext/ice/cpp/src/Ice/LoggerAdminI.h +4 -9
  290. data/ext/ice/cpp/src/Ice/LoggerF.cpp +28 -11
  291. data/ext/ice/cpp/src/Ice/LoggerI.cpp +26 -55
  292. data/ext/ice/cpp/src/Ice/LoggerI.h +7 -18
  293. data/ext/ice/cpp/src/Ice/LoggerUtil.cpp +10 -17
  294. data/ext/ice/cpp/src/Ice/Metrics.cpp +1280 -1107
  295. data/ext/ice/cpp/src/Ice/MetricsAdminI.cpp +58 -33
  296. data/ext/ice/cpp/src/Ice/MetricsObserverI.cpp +1 -7
  297. data/ext/ice/cpp/src/Ice/Network.cpp +753 -408
  298. data/ext/ice/cpp/src/Ice/Network.h +99 -36
  299. data/ext/ice/cpp/src/Ice/NetworkF.h +2 -7
  300. data/ext/ice/cpp/src/Ice/NetworkProxy.cpp +20 -19
  301. data/ext/ice/cpp/src/Ice/NetworkProxy.h +5 -7
  302. data/ext/ice/cpp/src/Ice/NetworkProxyF.h +1 -6
  303. data/ext/ice/cpp/src/Ice/OSLogLoggerI.cpp +57 -0
  304. data/ext/ice/cpp/src/Ice/OSLogLoggerI.h +40 -0
  305. data/ext/ice/cpp/src/Ice/Object.cpp +227 -232
  306. data/ext/ice/cpp/src/Ice/ObjectAdapter.cpp +45 -13
  307. data/ext/ice/cpp/src/Ice/ObjectAdapterF.cpp +28 -11
  308. data/ext/ice/cpp/src/Ice/ObjectAdapterFactory.cpp +83 -33
  309. data/ext/ice/cpp/src/Ice/ObjectAdapterFactory.h +13 -12
  310. data/ext/ice/cpp/src/Ice/ObjectAdapterFactoryF.h +25 -0
  311. data/ext/ice/cpp/src/Ice/ObjectAdapterI.cpp +298 -191
  312. data/ext/ice/cpp/src/Ice/ObjectAdapterI.h +44 -39
  313. data/ext/ice/cpp/src/Ice/ObjectFactory.cpp +41 -13
  314. data/ext/ice/cpp/src/Ice/ObserverHelper.cpp +9 -37
  315. data/ext/ice/cpp/src/Ice/OpaqueEndpointI.cpp +67 -67
  316. data/ext/ice/cpp/src/Ice/OpaqueEndpointI.h +15 -11
  317. data/ext/ice/cpp/src/Ice/OutgoingAsync.cpp +801 -366
  318. data/ext/ice/cpp/src/Ice/OutputStream.cpp +1367 -0
  319. data/ext/ice/cpp/src/Ice/Plugin.cpp +52 -14
  320. data/ext/ice/cpp/src/Ice/PluginF.cpp +28 -11
  321. data/ext/ice/cpp/src/Ice/PluginManagerI.cpp +27 -51
  322. data/ext/ice/cpp/src/Ice/PluginManagerI.h +7 -13
  323. data/ext/ice/cpp/src/Ice/Process.cpp +294 -128
  324. data/ext/ice/cpp/src/Ice/ProcessF.cpp +30 -12
  325. data/ext/ice/cpp/src/Ice/Properties.cpp +42 -15
  326. data/ext/ice/cpp/src/Ice/PropertiesAdmin.cpp +382 -340
  327. data/ext/ice/cpp/src/Ice/PropertiesAdminI.cpp +83 -24
  328. data/ext/ice/cpp/src/Ice/PropertiesAdminI.h +29 -10
  329. data/ext/ice/cpp/src/Ice/PropertiesF.cpp +30 -12
  330. data/ext/ice/cpp/src/Ice/PropertiesI.cpp +46 -57
  331. data/ext/ice/cpp/src/Ice/PropertiesI.h +18 -26
  332. data/ext/ice/cpp/src/Ice/PropertyNames.cpp +112 -19
  333. data/ext/ice/cpp/src/Ice/PropertyNames.h +4 -7
  334. data/ext/ice/cpp/src/Ice/Protocol.cpp +6 -19
  335. data/ext/ice/cpp/src/Ice/ProtocolInstance.cpp +37 -7
  336. data/ext/ice/cpp/src/Ice/ProtocolInstance.h +9 -25
  337. data/ext/ice/cpp/src/Ice/ProtocolInstanceF.h +1 -6
  338. data/ext/ice/cpp/src/Ice/ProtocolPluginFacade.cpp +6 -6
  339. data/ext/ice/cpp/src/Ice/ProtocolPluginFacade.h +3 -6
  340. data/ext/ice/cpp/src/Ice/ProtocolPluginFacadeF.h +1 -6
  341. data/ext/ice/cpp/src/Ice/Proxy.cpp +729 -957
  342. data/ext/ice/cpp/src/Ice/ProxyFactory.cpp +33 -38
  343. data/ext/ice/cpp/src/Ice/ProxyFactory.h +16 -16
  344. data/ext/ice/cpp/src/Ice/Reference.cpp +190 -106
  345. data/ext/ice/cpp/src/Ice/Reference.h +39 -28
  346. data/ext/ice/cpp/src/Ice/ReferenceFactory.cpp +69 -118
  347. data/ext/ice/cpp/src/Ice/ReferenceFactory.h +12 -17
  348. data/ext/ice/cpp/src/Ice/ReferenceFactoryF.h +1 -6
  349. data/ext/ice/cpp/src/Ice/RegisterPluginsInit.cpp +19 -9
  350. data/ext/ice/cpp/src/Ice/RegisterPluginsInit.h +1 -6
  351. data/ext/ice/cpp/src/Ice/RemoteLogger.cpp +766 -565
  352. data/ext/ice/cpp/src/Ice/ReplyStatus.h +1 -6
  353. data/ext/ice/cpp/src/Ice/RequestHandler.cpp +5 -8
  354. data/ext/ice/cpp/src/Ice/RequestHandler.h +10 -18
  355. data/ext/ice/cpp/src/Ice/RequestHandlerFactory.cpp +10 -11
  356. data/ext/ice/cpp/src/Ice/RequestHandlerFactory.h +2 -7
  357. data/ext/ice/cpp/src/Ice/ResponseHandler.cpp +3 -11
  358. data/ext/ice/cpp/src/Ice/ResponseHandler.h +16 -12
  359. data/ext/ice/cpp/src/Ice/RetryQueue.cpp +12 -20
  360. data/ext/ice/cpp/src/Ice/RetryQueue.h +7 -11
  361. data/ext/ice/cpp/src/Ice/RetryQueueF.h +1 -6
  362. data/ext/ice/cpp/src/Ice/Router.cpp +614 -492
  363. data/ext/ice/cpp/src/Ice/RouterF.cpp +30 -12
  364. data/ext/ice/cpp/src/Ice/RouterInfo.cpp +93 -99
  365. data/ext/ice/cpp/src/Ice/RouterInfo.h +42 -38
  366. data/ext/ice/cpp/src/Ice/RouterInfoF.h +1 -6
  367. data/ext/ice/cpp/src/{IceUtil → Ice}/SHA1.cpp +23 -28
  368. data/ext/ice/cpp/src/Ice/Selector.cpp +948 -855
  369. data/ext/ice/cpp/src/Ice/Selector.h +100 -152
  370. data/ext/ice/cpp/src/Ice/ServantLocator.cpp +41 -13
  371. data/ext/ice/cpp/src/Ice/ServantLocatorF.cpp +28 -11
  372. data/ext/ice/cpp/src/Ice/ServantManager.cpp +24 -45
  373. data/ext/ice/cpp/src/Ice/ServantManager.h +1 -6
  374. data/ext/ice/cpp/src/Ice/SharedContext.h +2 -7
  375. data/ext/ice/cpp/src/Ice/SliceChecksumDict.cpp +21 -12
  376. data/ext/ice/cpp/src/Ice/SliceChecksums.cpp +2 -7
  377. data/ext/ice/cpp/src/Ice/SlicedData.cpp +72 -25
  378. data/ext/ice/cpp/src/Ice/StreamSocket.cpp +208 -76
  379. data/ext/ice/cpp/src/Ice/StreamSocket.h +13 -9
  380. data/ext/ice/cpp/src/Ice/StringConverterPlugin.cpp +57 -22
  381. data/ext/ice/cpp/src/Ice/StringUtil.h +30 -0
  382. data/ext/ice/cpp/src/Ice/SysLoggerI.cpp +6 -7
  383. data/ext/ice/cpp/src/Ice/SysLoggerI.h +2 -8
  384. data/ext/ice/cpp/src/Ice/SystemdJournalI.cpp +66 -0
  385. data/ext/ice/cpp/src/Ice/SystemdJournalI.h +39 -0
  386. data/ext/ice/cpp/src/Ice/TcpAcceptor.cpp +169 -49
  387. data/ext/ice/cpp/src/Ice/TcpAcceptor.h +12 -10
  388. data/ext/ice/cpp/src/Ice/TcpConnector.cpp +6 -12
  389. data/ext/ice/cpp/src/Ice/TcpConnector.h +1 -7
  390. data/ext/ice/cpp/src/Ice/TcpEndpointI.cpp +51 -46
  391. data/ext/ice/cpp/src/Ice/TcpEndpointI.h +12 -14
  392. data/ext/ice/cpp/src/Ice/TcpTransceiver.cpp +17 -32
  393. data/ext/ice/cpp/src/Ice/TcpTransceiver.h +7 -15
  394. data/ext/ice/cpp/src/{IceUtil → Ice}/Thread.cpp +41 -54
  395. data/ext/ice/cpp/src/Ice/ThreadPool.cpp +242 -274
  396. data/ext/ice/cpp/src/Ice/ThreadPool.h +46 -48
  397. data/ext/ice/cpp/src/{IceUtil → Ice}/Timer.cpp +38 -26
  398. data/ext/ice/cpp/src/Ice/TraceLevels.cpp +2 -7
  399. data/ext/ice/cpp/src/Ice/TraceLevels.h +1 -6
  400. data/ext/ice/cpp/src/Ice/TraceLevelsF.h +2 -7
  401. data/ext/ice/cpp/src/Ice/TraceUtil.cpp +53 -36
  402. data/ext/ice/cpp/src/Ice/TraceUtil.h +13 -11
  403. data/ext/ice/cpp/src/Ice/Transceiver.cpp +1 -7
  404. data/ext/ice/cpp/src/Ice/Transceiver.h +8 -12
  405. data/ext/ice/cpp/src/Ice/TransceiverF.h +3 -8
  406. data/ext/ice/cpp/src/Ice/UdpConnector.cpp +5 -13
  407. data/ext/ice/cpp/src/Ice/UdpConnector.h +1 -7
  408. data/ext/ice/cpp/src/Ice/UdpEndpointI.cpp +118 -60
  409. data/ext/ice/cpp/src/Ice/UdpEndpointI.h +13 -10
  410. data/ext/ice/cpp/src/Ice/UdpTransceiver.cpp +177 -236
  411. data/ext/ice/cpp/src/Ice/UdpTransceiver.h +15 -22
  412. data/ext/ice/cpp/src/Ice/Value.cpp +76 -0
  413. data/ext/ice/cpp/src/Ice/ValueFactory.cpp +83 -0
  414. data/ext/ice/cpp/src/Ice/ValueFactoryManagerI.cpp +61 -0
  415. data/ext/ice/cpp/src/Ice/ValueFactoryManagerI.h +37 -0
  416. data/ext/ice/cpp/src/Ice/Version.cpp +25 -20
  417. data/ext/ice/cpp/src/Ice/VirtualShared.h +38 -0
  418. data/ext/ice/cpp/src/Ice/WSAcceptor.cpp +3 -14
  419. data/ext/ice/cpp/src/Ice/WSAcceptor.h +3 -12
  420. data/ext/ice/cpp/src/Ice/WSConnector.cpp +5 -16
  421. data/ext/ice/cpp/src/Ice/WSConnector.h +3 -11
  422. data/ext/ice/cpp/src/Ice/WSEndpoint.cpp +188 -89
  423. data/ext/ice/cpp/src/Ice/WSEndpoint.h +22 -37
  424. data/ext/ice/cpp/src/Ice/WSTransceiver.cpp +65 -66
  425. data/ext/ice/cpp/src/Ice/WSTransceiver.h +7 -27
  426. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.cpp +596 -281
  427. data/ext/ice/cpp/src/IceDiscovery/IceDiscovery.h +1383 -543
  428. data/ext/ice/cpp/src/IceDiscovery/LocatorI.cpp +89 -32
  429. data/ext/ice/cpp/src/IceDiscovery/LocatorI.h +59 -28
  430. data/ext/ice/cpp/src/IceDiscovery/LookupI.cpp +315 -66
  431. data/ext/ice/cpp/src/IceDiscovery/LookupI.h +83 -41
  432. data/ext/ice/cpp/src/IceDiscovery/PluginI.cpp +57 -64
  433. data/ext/ice/cpp/src/IceDiscovery/PluginI.h +3 -8
  434. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.cpp +450 -172
  435. data/ext/ice/cpp/src/IceLocatorDiscovery/IceLocatorDiscovery.h +863 -406
  436. data/ext/ice/cpp/src/IceLocatorDiscovery/Plugin.h +47 -0
  437. data/ext/ice/cpp/src/IceLocatorDiscovery/PluginI.cpp +636 -144
  438. data/ext/ice/cpp/src/IceSSL/AcceptorI.cpp +20 -173
  439. data/ext/ice/cpp/src/IceSSL/AcceptorI.h +8 -22
  440. data/ext/ice/cpp/src/IceSSL/CertificateI.cpp +279 -0
  441. data/ext/ice/cpp/src/IceSSL/CertificateI.h +64 -0
  442. data/ext/ice/cpp/src/IceSSL/ConnectionInfo.cpp +42 -17
  443. data/ext/ice/cpp/src/IceSSL/ConnectionInfoF.cpp +61 -0
  444. data/ext/ice/cpp/src/IceSSL/ConnectorI.cpp +15 -64
  445. data/ext/ice/cpp/src/IceSSL/ConnectorI.h +6 -18
  446. data/ext/ice/cpp/src/IceSSL/EndpointI.cpp +207 -204
  447. data/ext/ice/cpp/src/IceSSL/EndpointI.h +43 -40
  448. data/ext/ice/cpp/src/IceSSL/EndpointInfo.cpp +42 -16
  449. data/ext/ice/cpp/src/IceSSL/Instance.cpp +1 -11
  450. data/ext/ice/cpp/src/IceSSL/Instance.h +7 -12
  451. data/ext/ice/cpp/src/IceSSL/InstanceF.h +11 -12
  452. data/ext/ice/cpp/src/IceSSL/OpenSSLCertificateI.cpp +583 -0
  453. data/ext/ice/cpp/src/IceSSL/OpenSSLEngine.cpp +134 -115
  454. data/ext/ice/cpp/src/IceSSL/OpenSSLEngine.h +59 -0
  455. data/ext/ice/cpp/src/IceSSL/OpenSSLEngineF.h +27 -0
  456. data/ext/ice/cpp/src/IceSSL/OpenSSLPluginI.cpp +127 -0
  457. data/ext/ice/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +477 -182
  458. data/ext/ice/cpp/src/IceSSL/OpenSSLTransceiverI.h +32 -26
  459. data/ext/ice/cpp/src/IceSSL/OpenSSLUtil.cpp +286 -0
  460. data/ext/ice/cpp/src/IceSSL/OpenSSLUtil.h +58 -0
  461. data/ext/ice/cpp/src/IceSSL/PluginI.cpp +71 -46
  462. data/ext/ice/cpp/src/IceSSL/PluginI.h +13 -23
  463. data/ext/ice/cpp/src/IceSSL/RFC2253.cpp +9 -60
  464. data/ext/ice/cpp/src/IceSSL/RFC2253.h +7 -12
  465. data/ext/ice/cpp/src/IceSSL/SChannelCertificateI.cpp +580 -0
  466. data/ext/ice/cpp/src/IceSSL/SChannelEngine.cpp +523 -74
  467. data/ext/ice/cpp/src/IceSSL/SChannelEngine.h +123 -0
  468. data/ext/ice/cpp/src/IceSSL/SChannelEngineF.h +31 -0
  469. data/ext/ice/cpp/src/IceSSL/SChannelPluginI.cpp +73 -0
  470. data/ext/ice/cpp/src/IceSSL/SChannelTransceiverI.cpp +187 -221
  471. data/ext/ice/cpp/src/IceSSL/SChannelTransceiverI.h +24 -26
  472. data/ext/ice/cpp/src/IceSSL/SSLEngine.cpp +97 -94
  473. data/ext/ice/cpp/src/IceSSL/SSLEngine.h +26 -192
  474. data/ext/ice/cpp/src/IceSSL/SSLEngineF.h +4 -24
  475. data/ext/ice/cpp/src/IceSSL/SecureTransportCertificateI.cpp +868 -0
  476. data/ext/ice/cpp/src/IceSSL/SecureTransportEngine.cpp +69 -201
  477. data/ext/ice/cpp/src/IceSSL/SecureTransportEngine.h +59 -0
  478. data/ext/ice/cpp/src/IceSSL/SecureTransportEngineF.h +29 -0
  479. data/ext/ice/cpp/src/IceSSL/SecureTransportPluginI.cpp +75 -0
  480. data/ext/ice/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +174 -161
  481. data/ext/ice/cpp/src/IceSSL/SecureTransportTransceiverI.h +29 -33
  482. data/ext/ice/cpp/src/IceSSL/SecureTransportUtil.cpp +864 -0
  483. data/ext/ice/cpp/src/IceSSL/SecureTransportUtil.h +45 -0
  484. data/ext/ice/cpp/src/IceSSL/TrustManager.cpp +12 -22
  485. data/ext/ice/cpp/src/IceSSL/TrustManager.h +4 -9
  486. data/ext/ice/cpp/src/IceSSL/TrustManagerF.h +3 -8
  487. data/ext/ice/cpp/src/IceSSL/UWPCertificateI.cpp +266 -0
  488. data/ext/ice/cpp/src/IceSSL/UWPEngine.cpp +338 -0
  489. data/ext/ice/cpp/src/IceSSL/UWPEngine.h +41 -0
  490. data/ext/ice/cpp/src/IceSSL/UWPEngineF.h +26 -0
  491. data/ext/ice/cpp/src/IceSSL/UWPPluginI.cpp +89 -0
  492. data/ext/ice/cpp/src/IceSSL/UWPTransceiverI.cpp +383 -0
  493. data/ext/ice/cpp/src/IceSSL/UWPTransceiverI.h +71 -0
  494. data/ext/ice/cpp/src/IceSSL/Util.cpp +71 -1260
  495. data/ext/ice/cpp/src/IceSSL/Util.h +48 -142
  496. data/ext/ice/cpp/src/IceUtil/ConsoleUtil.cpp +157 -0
  497. data/ext/ice/cpp/src/IceUtil/ConvertUTF.cpp +22 -27
  498. data/ext/ice/cpp/src/IceUtil/ConvertUTF.h +34 -31
  499. data/ext/ice/cpp/src/IceUtil/CtrlCHandler.cpp +22 -36
  500. data/ext/ice/cpp/src/IceUtil/FileUtil.cpp +30 -126
  501. data/ext/ice/cpp/src/IceUtil/InputUtil.cpp +1 -6
  502. data/ext/ice/cpp/src/IceUtil/MutexProtocol.cpp +1 -6
  503. data/ext/ice/cpp/src/IceUtil/Options.cpp +20 -33
  504. data/ext/ice/cpp/src/IceUtil/OutputUtil.cpp +47 -21
  505. data/ext/ice/cpp/src/IceUtil/Random.cpp +15 -20
  506. data/ext/ice/cpp/src/IceUtil/RecMutex.cpp +4 -19
  507. data/ext/ice/cpp/src/IceUtil/Shared.cpp +8 -8
  508. data/ext/ice/cpp/src/IceUtil/StringConverter.cpp +501 -269
  509. data/ext/ice/cpp/src/IceUtil/StringUtil.cpp +582 -244
  510. data/ext/ice/cpp/src/IceUtil/ThreadException.cpp +37 -79
  511. data/ext/ice/cpp/src/IceUtil/Time.cpp +6 -11
  512. data/ext/ice/cpp/src/IceUtil/UUID.cpp +17 -22
  513. data/ext/ice/cpp/src/IceUtil/Unicode.cpp +97 -101
  514. data/ext/ice/cpp/src/IceUtil/Unicode.h +21 -40
  515. data/ext/ice/cpp/src/IceUtil/UtilException.cpp +839 -0
  516. data/ext/ice/cpp/src/Slice/CPlusPlusUtil.cpp +894 -234
  517. data/ext/ice/cpp/src/Slice/CPlusPlusUtil.h +72 -0
  518. data/ext/ice/cpp/src/Slice/Checksum.cpp +2 -7
  519. data/ext/ice/cpp/src/Slice/Checksum.h +21 -0
  520. data/ext/ice/cpp/src/Slice/FileTracker.cpp +25 -83
  521. data/ext/ice/cpp/{include → src}/Slice/FileTracker.h +9 -14
  522. data/ext/ice/cpp/src/Slice/Grammar.cpp +1981 -1944
  523. data/ext/ice/cpp/src/Slice/Grammar.h +39 -19
  524. data/ext/ice/cpp/src/Slice/GrammarUtil.h +14 -20
  525. data/ext/ice/cpp/src/Slice/JavaUtil.cpp +2752 -1948
  526. data/ext/ice/cpp/src/Slice/JavaUtil.h +398 -0
  527. data/ext/ice/cpp/src/Slice/MD5.cpp +1 -6
  528. data/ext/ice/cpp/src/Slice/MD5.h +1 -6
  529. data/ext/ice/cpp/src/Slice/MD5I.cpp +8 -1
  530. data/ext/ice/cpp/src/Slice/MD5I.h +1 -1
  531. data/ext/ice/cpp/src/Slice/PHPUtil.cpp +17 -20
  532. data/ext/ice/cpp/src/Slice/PHPUtil.h +36 -0
  533. data/ext/ice/cpp/src/Slice/Parser.cpp +1190 -426
  534. data/ext/ice/cpp/{include → src}/Slice/Parser.h +143 -91
  535. data/ext/ice/cpp/src/Slice/Preprocessor.cpp +67 -36
  536. data/ext/ice/cpp/{include → src}/Slice/Preprocessor.h +8 -18
  537. data/ext/ice/cpp/src/Slice/Python.cpp +218 -111
  538. data/ext/ice/cpp/src/Slice/PythonUtil.cpp +787 -699
  539. data/ext/ice/cpp/src/Slice/PythonUtil.h +70 -0
  540. data/ext/ice/cpp/src/Slice/Ruby.cpp +42 -43
  541. data/ext/ice/cpp/src/Slice/RubyUtil.cpp +175 -445
  542. data/ext/ice/cpp/{include → src}/Slice/RubyUtil.h +6 -11
  543. data/ext/ice/cpp/src/Slice/Scanner.cpp +390 -399
  544. data/ext/ice/cpp/src/Slice/{Util.cpp → SliceUtil.cpp} +36 -69
  545. data/ext/ice/cpp/src/Slice/StringLiteralUtil.cpp +456 -0
  546. data/ext/ice/cpp/src/Slice/Util.h +50 -0
  547. data/ice.gemspec +2 -9
  548. data/lib/Glacier2.rb +1 -6
  549. data/lib/Glacier2/Metrics.rb +6 -50
  550. data/lib/Glacier2/PermissionsVerifier.rb +23 -99
  551. data/lib/Glacier2/PermissionsVerifierF.rb +2 -7
  552. data/lib/Glacier2/Router.rb +31 -78
  553. data/lib/Glacier2/RouterF.rb +2 -7
  554. data/lib/Glacier2/SSLInfo.rb +3 -11
  555. data/lib/Glacier2/Session.rb +87 -311
  556. data/lib/Ice.rb +84 -58
  557. data/lib/Ice/BuiltinSequences.rb +3 -8
  558. data/lib/Ice/Communicator.rb +54 -61
  559. data/lib/Ice/CommunicatorF.rb +2 -7
  560. data/lib/Ice/Connection.rb +152 -166
  561. data/lib/Ice/ConnectionF.rb +2 -7
  562. data/lib/Ice/Current.rb +3 -15
  563. data/lib/Ice/Endpoint.rb +56 -137
  564. data/lib/Ice/EndpointF.rb +2 -7
  565. data/lib/Ice/EndpointTypes.rb +2 -11
  566. data/lib/Ice/FacetMap.rb +3 -8
  567. data/lib/Ice/Identity.rb +4 -12
  568. data/lib/Ice/ImplicitContext.rb +4 -38
  569. data/lib/Ice/ImplicitContextF.rb +2 -7
  570. data/lib/Ice/Instrumentation.rb +22 -279
  571. data/lib/Ice/InstrumentationF.rb +2 -7
  572. data/lib/Ice/LocalException.rb +94 -145
  573. data/lib/Ice/Locator.rb +50 -169
  574. data/lib/Ice/LocatorF.rb +2 -7
  575. data/lib/Ice/Logger.rb +4 -38
  576. data/lib/Ice/LoggerF.rb +2 -7
  577. data/lib/Ice/Metrics.rb +60 -420
  578. data/lib/Ice/ObjectAdapter.rb +29 -0
  579. data/lib/Ice/ObjectAdapterF.rb +2 -7
  580. data/lib/Ice/ObjectFactory.rb +4 -34
  581. data/lib/Ice/Plugin.rb +6 -64
  582. data/lib/Ice/PluginF.rb +2 -7
  583. data/lib/Ice/Process.rb +15 -56
  584. data/lib/Ice/ProcessF.rb +2 -7
  585. data/lib/Ice/Properties.rb +4 -45
  586. data/lib/Ice/PropertiesAdmin.rb +18 -60
  587. data/lib/Ice/PropertiesF.rb +2 -7
  588. data/lib/Ice/RemoteLogger.rb +33 -119
  589. data/lib/Ice/Router.rb +28 -105
  590. data/lib/Ice/RouterF.rb +2 -7
  591. data/lib/Ice/ServantLocator.rb +26 -0
  592. data/lib/Ice/ServantLocatorF.rb +24 -0
  593. data/lib/Ice/SliceChecksumDict.rb +2 -7
  594. data/lib/Ice/ValueFactory.rb +28 -0
  595. data/lib/Ice/Version.rb +4 -15
  596. data/lib/IceBox.rb +1 -6
  597. data/lib/IceBox/IceBox.rb +43 -152
  598. data/lib/IceGrid.rb +1 -9
  599. data/lib/IceGrid/Admin.rb +550 -431
  600. data/lib/IceGrid/Descriptor.rb +61 -533
  601. data/lib/IceGrid/Exception.rb +23 -49
  602. data/lib/IceGrid/FileParser.rb +13 -54
  603. data/lib/IceGrid/PluginFacade.rb +35 -0
  604. data/lib/IceGrid/Registry.rb +150 -62
  605. data/lib/IceGrid/Session.rb +24 -68
  606. data/lib/IceGrid/UserAccountMapper.rb +13 -54
  607. data/lib/IcePatch2.rb +1 -6
  608. data/lib/IcePatch2/FileInfo.rb +4 -15
  609. data/lib/IcePatch2/FileServer.rb +32 -80
  610. data/lib/IceStorm.rb +1 -6
  611. data/lib/IceStorm/IceStorm.rb +78 -210
  612. data/lib/IceStorm/Metrics.rb +10 -93
  613. data/slice/Glacier2/Metrics.ice +20 -10
  614. data/slice/Glacier2/PermissionsVerifier.ice +19 -12
  615. data/slice/Glacier2/PermissionsVerifierF.ice +16 -9
  616. data/slice/Glacier2/Router.ice +19 -13
  617. data/slice/Glacier2/RouterF.ice +16 -9
  618. data/slice/Glacier2/SSLInfo.ice +17 -10
  619. data/slice/Glacier2/Session.ice +24 -18
  620. data/slice/Ice/BuiltinSequences.ice +18 -9
  621. data/slice/Ice/Communicator.ice +180 -64
  622. data/slice/Ice/CommunicatorF.ice +18 -9
  623. data/slice/Ice/Connection.ice +208 -75
  624. data/slice/Ice/ConnectionF.ice +18 -9
  625. data/slice/Ice/Current.ice +37 -28
  626. data/slice/Ice/Endpoint.ice +73 -21
  627. data/slice/Ice/EndpointF.ice +19 -10
  628. data/slice/Ice/EndpointTypes.ice +21 -13
  629. data/slice/Ice/FacetMap.ice +19 -10
  630. data/slice/Ice/Identity.ice +24 -10
  631. data/slice/Ice/ImplicitContext.ice +41 -33
  632. data/slice/Ice/ImplicitContextF.ice +17 -9
  633. data/slice/Ice/Instrumentation.ice +37 -30
  634. data/slice/Ice/InstrumentationF.ice +19 -10
  635. data/slice/Ice/LocalException.ice +118 -112
  636. data/slice/Ice/Locator.ice +28 -21
  637. data/slice/Ice/LocatorF.ice +18 -9
  638. data/slice/Ice/Logger.ice +26 -18
  639. data/slice/Ice/LoggerF.ice +18 -9
  640. data/slice/Ice/Metrics.ice +42 -30
  641. data/slice/Ice/ObjectAdapter.ice +88 -53
  642. data/slice/Ice/ObjectAdapterF.ice +18 -9
  643. data/slice/Ice/ObjectFactory.ice +28 -17
  644. data/slice/Ice/Plugin.ice +25 -13
  645. data/slice/Ice/PluginF.ice +22 -9
  646. data/slice/Ice/Process.ice +20 -11
  647. data/slice/Ice/ProcessF.ice +18 -9
  648. data/slice/Ice/Properties.ice +42 -28
  649. data/slice/Ice/PropertiesAdmin.ice +20 -10
  650. data/slice/Ice/PropertiesF.ice +18 -9
  651. data/slice/Ice/RemoteLogger.ice +23 -19
  652. data/slice/Ice/Router.ice +28 -13
  653. data/slice/Ice/RouterF.ice +18 -9
  654. data/slice/Ice/ServantLocator.ice +40 -29
  655. data/slice/Ice/ServantLocatorF.ice +18 -9
  656. data/slice/Ice/SliceChecksumDict.ice +18 -9
  657. data/slice/Ice/ValueFactory.ice +132 -0
  658. data/slice/Ice/Version.ice +20 -10
  659. data/slice/IceBT/ConnectionInfo.ice +58 -0
  660. data/slice/IceBT/EndpointInfo.ice +56 -0
  661. data/slice/IceBT/Types.ice +44 -0
  662. data/slice/IceBox/IceBox.ice +45 -27
  663. data/slice/IceDiscovery/IceDiscovery.ice +75 -10
  664. data/slice/IceGrid/Admin.ice +410 -44
  665. data/slice/IceGrid/Descriptor.ice +47 -34
  666. data/slice/IceGrid/Exception.ice +43 -32
  667. data/slice/IceGrid/FileParser.ice +21 -12
  668. data/slice/IceGrid/PluginFacade.ice +26 -18
  669. data/slice/IceGrid/Registry.ice +150 -21
  670. data/slice/IceGrid/Session.ice +25 -17
  671. data/slice/IceGrid/UserAccountMapper.ice +23 -14
  672. data/slice/IceIAP/ConnectionInfo.ice +73 -0
  673. data/slice/IceIAP/EndpointInfo.ice +67 -0
  674. data/slice/IceLocatorDiscovery/IceLocatorDiscovery.ice +19 -12
  675. data/slice/IcePatch2/FileInfo.ice +19 -13
  676. data/slice/IcePatch2/FileServer.ice +27 -18
  677. data/slice/IceSSL/ConnectionInfo.ice +27 -23
  678. data/slice/IceSSL/ConnectionInfoF.ice +30 -0
  679. data/slice/IceSSL/EndpointInfo.ice +21 -36
  680. data/slice/IceStorm/IceStorm.ice +33 -24
  681. data/slice/IceStorm/Metrics.ice +19 -11
  682. metadata +148 -120
  683. data/ext/ObjectFactory.cpp +0 -140
  684. data/ext/ObjectFactory.h +0 -50
  685. data/ext/ice/cpp/include/Ice/ACMF.h +0 -30
  686. data/ext/ice/cpp/include/Ice/BasicStream.h +0 -1335
  687. data/ext/ice/cpp/include/Ice/BuiltinSequences.h +0 -82
  688. data/ext/ice/cpp/include/Ice/Communicator.h +0 -200
  689. data/ext/ice/cpp/include/Ice/Connection.h +0 -497
  690. data/ext/ice/cpp/include/Ice/ConnectionF.h +0 -74
  691. data/ext/ice/cpp/include/Ice/ConnectionFactoryF.h +0 -30
  692. data/ext/ice/cpp/include/Ice/Current.h +0 -102
  693. data/ext/ice/cpp/include/Ice/DefaultObjectFactory.h +0 -48
  694. data/ext/ice/cpp/include/Ice/DeprecatedStringConverter.h +0 -62
  695. data/ext/ice/cpp/include/Ice/Endpoint.h +0 -341
  696. data/ext/ice/cpp/include/Ice/EndpointF.h +0 -93
  697. data/ext/ice/cpp/include/Ice/EndpointTypes.h +0 -82
  698. data/ext/ice/cpp/include/Ice/Identity.h +0 -168
  699. data/ext/ice/cpp/include/Ice/ImplicitContext.h +0 -102
  700. data/ext/ice/cpp/include/Ice/Instrumentation.h +0 -365
  701. data/ext/ice/cpp/include/Ice/InstrumentationF.h +0 -75
  702. data/ext/ice/cpp/include/Ice/LocalException.h +0 -1030
  703. data/ext/ice/cpp/include/Ice/Locator.h +0 -2193
  704. data/ext/ice/cpp/include/Ice/LocatorF.h +0 -93
  705. data/ext/ice/cpp/include/Ice/Logger.h +0 -100
  706. data/ext/ice/cpp/include/Ice/Metrics.h +0 -2974
  707. data/ext/ice/cpp/include/Ice/ObjectAdapter.h +0 -168
  708. data/ext/ice/cpp/include/Ice/ObjectAdapterFactoryF.h +0 -26
  709. data/ext/ice/cpp/include/Ice/ObjectFactory.h +0 -92
  710. data/ext/ice/cpp/include/Ice/ObjectFactoryF.h +0 -66
  711. data/ext/ice/cpp/include/Ice/ObjectFactoryManagerF.h +0 -26
  712. data/ext/ice/cpp/include/Ice/Outgoing.h +0 -225
  713. data/ext/ice/cpp/include/Ice/Plugin.h +0 -125
  714. data/ext/ice/cpp/include/Ice/PluginF.h +0 -70
  715. data/ext/ice/cpp/include/Ice/Process.h +0 -574
  716. data/ext/ice/cpp/include/Ice/ProcessF.h +0 -83
  717. data/ext/ice/cpp/include/Ice/Properties.h +0 -136
  718. data/ext/ice/cpp/include/Ice/PropertiesAdmin.h +0 -830
  719. data/ext/ice/cpp/include/Ice/PropertiesF.h +0 -87
  720. data/ext/ice/cpp/include/Ice/RemoteLogger.h +0 -1500
  721. data/ext/ice/cpp/include/Ice/Router.h +0 -1159
  722. data/ext/ice/cpp/include/Ice/RouterF.h +0 -83
  723. data/ext/ice/cpp/include/Ice/ServantLocator.h +0 -96
  724. data/ext/ice/cpp/include/Ice/Stream.h +0 -447
  725. data/ext/ice/cpp/include/Ice/StreamF.h +0 -30
  726. data/ext/ice/cpp/include/Ice/Version.h +0 -262
  727. data/ext/ice/cpp/include/IceSSL/ConnectionInfo.h +0 -158
  728. data/ext/ice/cpp/include/IceSSL/EndpointInfo.h +0 -142
  729. data/ext/ice/cpp/include/IceUtil/AbstractMutex.h +0 -119
  730. data/ext/ice/cpp/include/IceUtil/Cache.h +0 -362
  731. data/ext/ice/cpp/include/IceUtil/IconvStringConverter.h +0 -302
  732. data/ext/ice/cpp/include/IceUtil/SHA1.h +0 -47
  733. data/ext/ice/cpp/include/Slice/CPlusPlusUtil.h +0 -65
  734. data/ext/ice/cpp/include/Slice/Checksum.h +0 -26
  735. data/ext/ice/cpp/include/Slice/CsUtil.h +0 -92
  736. data/ext/ice/cpp/include/Slice/DotNetNames.h +0 -34
  737. data/ext/ice/cpp/include/Slice/JavaUtil.h +0 -279
  738. data/ext/ice/cpp/include/Slice/ObjCUtil.h +0 -127
  739. data/ext/ice/cpp/include/Slice/PHPUtil.h +0 -50
  740. data/ext/ice/cpp/include/Slice/PythonUtil.h +0 -64
  741. data/ext/ice/cpp/include/Slice/Util.h +0 -56
  742. data/ext/ice/cpp/src/Ice/BasicStream.cpp +0 -3428
  743. data/ext/ice/cpp/src/Ice/DeprecatedStringConverter.cpp +0 -62
  744. data/ext/ice/cpp/src/Ice/ObjectFactoryF.cpp +0 -44
  745. data/ext/ice/cpp/src/Ice/ObjectFactoryManager.cpp +0 -139
  746. data/ext/ice/cpp/src/Ice/ObjectFactoryManager.h +0 -43
  747. data/ext/ice/cpp/src/Ice/Outgoing.cpp +0 -694
  748. data/ext/ice/cpp/src/Ice/Stream.cpp +0 -53
  749. data/ext/ice/cpp/src/Ice/StreamI.cpp +0 -832
  750. data/ext/ice/cpp/src/Ice/StreamI.h +0 -198
  751. data/ext/ice/cpp/src/IceSSL/Certificate.cpp +0 -1336
  752. data/ext/ice/cpp/src/IceUtil/ArgVector.cpp +0 -64
  753. data/ext/ice/cpp/src/IceUtil/ArgVector.h +0 -41
  754. data/ext/ice/cpp/src/IceUtil/Exception.cpp +0 -792
  755. data/ext/ice/cpp/src/IceUtil/FileUtil.h +0 -185
  756. data/ext/ice/cpp/src/Slice/CsUtil.cpp +0 -2660
  757. data/ext/ice/cpp/src/Slice/DotNetNames.cpp +0 -146
  758. data/ext/ice/cpp/src/Slice/ObjCUtil.cpp +0 -1310
  759. data/lib/Ice/ObjectFactoryF.rb +0 -29
  760. data/lib/IceGrid/Locator.rb +0 -106
  761. data/lib/IceGrid/Observer.rb +0 -572
  762. data/lib/IceGrid/Query.rb +0 -169
  763. data/slice/Freeze/BackgroundSaveEvictor.ice +0 -111
  764. data/slice/Freeze/CatalogData.ice +0 -49
  765. data/slice/Freeze/Connection.ice +0 -121
  766. data/slice/Freeze/ConnectionF.ice +0 -20
  767. data/slice/Freeze/DB.ice +0 -37
  768. data/slice/Freeze/Evictor.ice +0 -346
  769. data/slice/Freeze/EvictorF.ice +0 -22
  770. data/slice/Freeze/EvictorStorage.ice +0 -72
  771. data/slice/Freeze/Exception.ice +0 -100
  772. data/slice/Freeze/Transaction.ice +0 -58
  773. data/slice/Freeze/TransactionalEvictor.ice +0 -50
  774. data/slice/Ice/ObjectFactoryF.ice +0 -21
  775. data/slice/IceGrid/Locator.ice +0 -57
  776. data/slice/IceGrid/Observer.ice +0 -395
  777. data/slice/IceGrid/Query.ice +0 -131
@@ -1,11 +1,6 @@
1
- // **********************************************************************
2
1
  //
3
- // Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
2
+ // Copyright (c) ZeroC, Inc. All rights reserved.
4
3
  //
5
- // This copy of Ice is licensed to you under the terms described in the
6
- // ICE_LICENSE file included in this distribution.
7
- //
8
- // **********************************************************************
9
4
 
10
5
  #include <IceUtil/Shared.h>
11
6
 
@@ -29,6 +24,11 @@ IceUtil::SimpleShared::SimpleShared(const SimpleShared&) :
29
24
  {
30
25
  }
31
26
 
27
+ IceUtil::SimpleShared::~SimpleShared()
28
+ {
29
+ // Out of line to avoid weak vtable
30
+ }
31
+
32
32
  IceUtil::Shared::Shared() :
33
33
  _ref(0),
34
34
  _flags(0)
@@ -41,14 +41,14 @@ IceUtil::Shared::Shared(const Shared&) :
41
41
  {
42
42
  }
43
43
 
44
- void
44
+ void
45
45
  IceUtil::Shared::__incRef()
46
46
  {
47
47
  assert(_ref >= 0);
48
48
  ++_ref;
49
49
  }
50
50
 
51
- void
51
+ void
52
52
  IceUtil::Shared::__decRef()
53
53
  {
54
54
  assert(_ref > 0);
@@ -1,18 +1,18 @@
1
- // **********************************************************************
2
1
  //
3
- // Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
2
+ // Copyright (c) ZeroC, Inc. All rights reserved.
4
3
  //
5
- // This copy of Ice is licensed to you under the terms described in the
6
- // ICE_LICENSE file included in this distribution.
7
- //
8
- // **********************************************************************
9
4
 
10
5
  #include <IceUtil/StringConverter.h>
11
6
  #include <IceUtil/MutexPtrLock.h>
12
7
  #include <IceUtil/Mutex.h>
13
- #include <IceUtil/ScopedArray.h>
14
8
  #include <IceUtil/StringUtil.h>
9
+
10
+ #ifdef ICE_HAS_CODECVT_UTF8
11
+ #include <codecvt>
12
+ #include <locale>
13
+ #else
15
14
  #include <IceUtil/Unicode.h>
15
+ #endif
16
16
 
17
17
  using namespace IceUtil;
18
18
  using namespace IceUtilInternal;
@@ -25,268 +25,290 @@ IceUtil::Mutex* processStringConverterMutex = 0;
25
25
  IceUtil::StringConverterPtr processStringConverter;
26
26
  IceUtil::WstringConverterPtr processWstringConverter;
27
27
 
28
- class Init
29
- {
30
- public:
31
-
32
- Init()
33
- {
34
- processStringConverterMutex = new IceUtil::Mutex;
35
- }
28
+ #ifndef ICE_HAS_THREAD_SAFE_LOCAL_STATIC
29
+ IceUtil::WstringConverterPtr unicodeWstringConverter;
30
+ #endif
36
31
 
37
- ~Init()
38
- {
39
- delete processStringConverterMutex;
40
- processStringConverterMutex = 0;
41
- }
42
- };
32
+ #ifdef ICE_HAS_CODECVT_UTF8
43
33
 
44
- Init init;
34
+ template<size_t wcharSize>
35
+ struct SelectCodeCvt;
45
36
 
46
- }
37
+ template<>
38
+ struct SelectCodeCvt<2>
39
+ {
40
+ typedef std::codecvt_utf8_utf16<wchar_t> Type;
41
+ };
47
42
 
48
- namespace
43
+ template<>
44
+ struct SelectCodeCvt<4>
49
45
  {
46
+ typedef std::codecvt_utf8<wchar_t> Type;
47
+ };
50
48
 
51
- class UTF8BufferI : public UTF8Buffer
49
+ class UnicodeWstringConverter : public WstringConverter
52
50
  {
53
51
  public:
54
52
 
55
- UTF8BufferI() :
56
- _buffer(0),
57
- _offset(0)
53
+ #if defined(_MSC_VER) && (_MSC_VER <= 1800)
54
+ //
55
+ // VS 2013 needs a default ctor
56
+ //
57
+ UnicodeWstringConverter()
58
58
  {
59
59
  }
60
+ #endif
60
61
 
61
- ~UTF8BufferI()
62
+ virtual Byte* toUTF8(const wchar_t* sourceStart, const wchar_t* sourceEnd, UTF8Buffer& buffer) const
62
63
  {
63
- free(_buffer);
64
+ //
65
+ // Max bytes for a character encoding in UTF-8 is 4,
66
+ // however MSVC returns 6
67
+ //
68
+ #ifdef _MSC_VER
69
+ assert(_codecvt.max_length() == 4 || _codecvt.max_length() == 6);
70
+ #else
71
+ assert(_codecvt.max_length() == 4);
72
+ #endif
73
+ if(sourceStart == sourceEnd)
74
+ {
75
+ return buffer.getMoreBytes(1, 0);
76
+ }
77
+
78
+ char* targetStart = 0;
79
+ char* targetEnd = 0;
80
+ char* targetNext = 0;
81
+
82
+ mbstate_t state = mbstate_t(); // must be initialized!
83
+ const wchar_t* sourceNext = sourceStart;
84
+
85
+ bool more = false;
86
+
87
+ //
88
+ // The number of bytes we request from buffer for each remaining source character
89
+ //
90
+ size_t factor = 2;
91
+
92
+ do
93
+ {
94
+ assert(factor <= 4);
95
+ const size_t chunkSize = std::max<size_t>(static_cast<size_t>(sourceEnd - sourceStart) * factor, 4);
96
+ ++factor; // at the next round, we'll allocate more bytes per remaining source character
97
+
98
+ targetStart = reinterpret_cast<char*>(buffer.getMoreBytes(chunkSize, reinterpret_cast<Byte*>(targetNext)));
99
+ targetEnd = targetStart + chunkSize;
100
+ targetNext = targetStart;
101
+
102
+ codecvt_base::result result =
103
+ _codecvt.out(state, sourceStart, sourceEnd, sourceNext, targetStart, targetEnd, targetNext);
104
+
105
+ switch(result)
106
+ {
107
+ case codecvt_base::ok:
108
+ //
109
+ // MSVC returns ok when target is exhausted
110
+ //
111
+ more = sourceNext < sourceEnd;
112
+ break;
113
+
114
+ case codecvt_base::partial:
115
+ //
116
+ // clang/libc++ and g++5 return partial when target is exhausted
117
+ //
118
+ more = true;
119
+ assert(sourceNext < sourceEnd);
120
+ break;
121
+
122
+ case codecvt_base::noconv:
123
+ //
124
+ // Unexpected
125
+ //
126
+ assert(0);
127
+ throw IllegalConversionException(__FILE__, __LINE__, "codecvt.out noconv");
128
+
129
+ default:
130
+ throw IllegalConversionException(__FILE__, __LINE__, "codecvt.out error");
131
+ }
132
+
133
+ if(targetStart == targetNext)
134
+ {
135
+ // We didn't convert a single character
136
+ throw IllegalConversionException(__FILE__, __LINE__,
137
+ "no character converted by codecvt.out");
138
+ }
139
+
140
+ sourceStart = sourceNext;
141
+ } while (more);
142
+
143
+ return reinterpret_cast<Byte*>(targetNext);
64
144
  }
65
145
 
66
- Byte* getMoreBytes(size_t howMany, Byte* firstUnused)
146
+ virtual void fromUTF8(const Byte* sourceStart, const Byte* sourceEnd, wstring& target) const
67
147
  {
68
- if(_buffer == 0)
148
+ const size_t sourceSize = static_cast<size_t>(sourceEnd - sourceStart);
149
+
150
+ if(sourceSize == 0)
69
151
  {
70
- _buffer = static_cast<Byte*>(malloc(howMany));
152
+ target = L"";
71
153
  }
72
154
  else
73
155
  {
74
- assert(firstUnused != 0);
75
- _offset = firstUnused - _buffer;
76
- _buffer = static_cast<Byte*>(realloc(_buffer, _offset + howMany));
77
- }
78
-
79
- if(!_buffer)
80
- {
81
- throw std::bad_alloc();
82
- }
83
- return _buffer + _offset;
84
- }
156
+ target.resize(sourceSize);
157
+ wchar_t* targetStart = const_cast<wchar_t*>(target.data());
158
+ wchar_t* targetEnd = targetStart + sourceSize;
159
+ wchar_t* targetNext = targetStart;
85
160
 
86
- Byte* getBuffer()
87
- {
88
- return _buffer;
89
- }
161
+ const char* sourceNext = reinterpret_cast<const char*>(sourceStart);
90
162
 
91
- void reset()
92
- {
93
- free(_buffer);
94
- _buffer = 0;
95
- _offset = 0;
163
+ mbstate_t state = mbstate_t();
164
+
165
+ codecvt_base::result result = _codecvt.in(state,
166
+ reinterpret_cast<const char*>(sourceStart),
167
+ reinterpret_cast<const char*>(sourceEnd),
168
+ sourceNext,
169
+ targetStart, targetEnd, targetNext);
170
+
171
+ if(result != codecvt_base::ok)
172
+ {
173
+ throw IllegalConversionException(__FILE__, __LINE__, "codecvt.in failure");
174
+ }
175
+
176
+ target.resize(static_cast<size_t>(targetNext - targetStart));
177
+ }
96
178
  }
97
-
179
+
98
180
  private:
99
181
 
100
- IceUtil::Byte* _buffer;
101
- size_t _offset;
182
+ typedef SelectCodeCvt<sizeof(wchar_t)>::Type CodeCvt;
183
+ const CodeCvt _codecvt;
102
184
  };
103
185
 
104
- }
186
+ #else
105
187
 
188
+ class UnicodeWstringConverter : public WstringConverter
189
+ {
190
+ public:
106
191
 
192
+ virtual Byte* toUTF8(const wchar_t* sourceStart, const wchar_t* sourceEnd, UTF8Buffer& buffer) const
193
+ {
194
+ if(sourceStart == sourceEnd)
195
+ {
196
+ return buffer.getMoreBytes(1, 0);
197
+ }
107
198
 
108
- UnicodeWstringConverter::UnicodeWstringConverter(ConversionFlags flags) :
109
- _conversionFlags(flags)
110
- {
111
- }
199
+ Byte* targetStart = 0;
200
+ Byte* targetEnd = 0;
112
201
 
113
- Byte*
114
- UnicodeWstringConverter::toUTF8(const wchar_t* sourceStart,
115
- const wchar_t* sourceEnd,
116
- UTF8Buffer& buffer) const
117
- {
118
- //
119
- // The "chunk size" is the maximum of the number of characters in the
120
- // source and 6 (== max bytes necessary to encode one Unicode character).
121
- //
122
- size_t chunkSize = std::max<size_t>(static_cast<size_t>(sourceEnd - sourceStart), 6);
202
+ //
203
+ // The number of bytes we request from buffer for each remaining source character
204
+ //
205
+ size_t factor = 2;
123
206
 
124
- Byte* targetStart = buffer.getMoreBytes(chunkSize, 0);
125
- Byte* targetEnd = targetStart + chunkSize;
207
+ do
208
+ {
209
+ assert(factor <= 4);
210
+ const size_t chunkSize = std::max<size_t>((sourceEnd - sourceStart) * factor, 4);
211
+ ++factor; // at the next round, we'll allocate more bytes per remaining source character
126
212
 
127
- ConversionResult result;
213
+ targetStart = buffer.getMoreBytes(chunkSize, targetStart);
214
+ targetEnd = targetStart + chunkSize;
215
+ }
216
+ while(convertUTFWstringToUTF8(sourceStart, sourceEnd, targetStart, targetEnd) == false);
128
217
 
129
- while((result =
130
- convertUTFWstringToUTF8(sourceStart, sourceEnd,
131
- targetStart, targetEnd, _conversionFlags))
132
- == targetExhausted)
133
- {
134
- targetStart = buffer.getMoreBytes(chunkSize, targetStart);
135
- targetEnd = targetStart + chunkSize;
218
+ return targetStart;
136
219
  }
137
-
138
- switch(result)
220
+
221
+ virtual void fromUTF8(const Byte* sourceStart, const Byte* sourceEnd, wstring& target) const
139
222
  {
140
- case conversionOK:
141
- break;
142
- case sourceExhausted:
143
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "wide string source exhausted");
144
- case sourceIllegal:
145
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "wide string source illegal");
146
- default:
223
+ if(sourceStart == sourceEnd)
224
+ {
225
+ target = L"";
226
+ }
227
+ else
147
228
  {
148
- assert(0);
149
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
229
+ convertUTF8ToUTFWstring(sourceStart, sourceEnd, target);
150
230
  }
151
231
  }
152
- return targetStart;
153
- }
232
+ };
154
233
 
234
+ #endif
155
235
 
156
- void
157
- UnicodeWstringConverter::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd,
158
- wstring& target) const
236
+ class Init
159
237
  {
160
- if(sourceStart == sourceEnd)
238
+ public:
239
+
240
+ Init()
161
241
  {
162
- target = L"";
163
- return;
242
+ processStringConverterMutex = new IceUtil::Mutex;
243
+ #ifndef ICE_HAS_THREAD_SAFE_LOCAL_STATIC
244
+ unicodeWstringConverter = ICE_MAKE_SHARED(UnicodeWstringConverter);
245
+ #endif
164
246
  }
165
247
 
166
- ConversionResult result =
167
- convertUTF8ToUTFWstring(sourceStart, sourceEnd, target, _conversionFlags);
168
-
169
- switch(result)
248
+ ~Init()
170
249
  {
171
- case conversionOK:
172
- break;
173
- case sourceExhausted:
174
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "UTF-8 string source exhausted");
175
- case sourceIllegal:
176
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "UTF-8 string source illegal");
177
- default:
178
- {
179
- assert(0);
180
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
181
- }
250
+ delete processStringConverterMutex;
251
+ processStringConverterMutex = 0;
182
252
  }
183
- }
253
+ };
184
254
 
185
- #ifdef _WIN32
186
- WindowsStringConverter::WindowsStringConverter(unsigned int cp) :
187
- _cp(cp)
255
+ Init init;
256
+
257
+ const WstringConverterPtr&
258
+ getUnicodeWstringConverter()
188
259
  {
260
+ #ifdef ICE_HAS_THREAD_SAFE_LOCAL_STATIC
261
+ static const WstringConverterPtr unicodeWstringConverter = ICE_MAKE_SHARED(UnicodeWstringConverter);
262
+ #endif
263
+ return unicodeWstringConverter;
189
264
  }
190
265
 
191
- Byte*
192
- WindowsStringConverter::toUTF8(const char* sourceStart,
193
- const char* sourceEnd,
194
- UTF8Buffer& buffer) const
266
+ class UTF8BufferI : public UTF8Buffer
195
267
  {
196
- //
197
- // First convert to UTF-16
198
- //
199
- int sourceSize = static_cast<int>(sourceEnd - sourceStart);
200
- if(sourceSize == 0)
201
- {
202
- return buffer.getMoreBytes(1, 0);
203
- }
268
+ public:
204
269
 
205
- int size = 0;
206
- int writtenWchar = 0;
207
- ScopedArray<wchar_t> wbuffer;
208
-
209
270
  //
210
- // The following code pages doesn't support MB_ERR_INVALID_CHARS flag
211
- // see http://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx
271
+ // Returns the first unused byte in the resized buffer
212
272
  //
213
- DWORD flags =
214
- (_cp == 50220 || _cp == 50221 || _cp == 50222 ||
215
- _cp == 50225 || _cp == 50227 || _cp == 50229 ||
216
- _cp == 65000 || _cp == 42 || (_cp >= 57002 && _cp <= 57011)) ? 0 : MB_ERR_INVALID_CHARS;
217
-
218
- do
219
- {
220
- size = size == 0 ? sourceSize + 2 : 2 * size;
221
- wbuffer.reset(new wchar_t[size]);
222
-
223
- writtenWchar = MultiByteToWideChar(_cp, flags, sourceStart,
224
- sourceSize, wbuffer.get(), size);
225
- } while(writtenWchar == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
226
-
227
- if(writtenWchar == 0)
273
+ Byte* getMoreBytes(size_t howMany, Byte* firstUnused)
228
274
  {
229
- throw IllegalConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString());
230
- }
275
+ size_t bytesUsed = 0;
276
+ if(firstUnused != 0)
277
+ {
278
+ bytesUsed = static_cast<size_t>(firstUnused - reinterpret_cast<const Byte*>(_buffer.data()));
279
+ }
231
280
 
232
- //
233
- // Then convert this UTF-16 wbuffer into UTF-8
234
- //
235
- return _unicodeWstringConverter.toUTF8(wbuffer.get(), wbuffer.get() + writtenWchar, buffer);
236
- }
281
+ if(_buffer.size() < howMany + bytesUsed)
282
+ {
283
+ _buffer.resize(bytesUsed + howMany);
284
+ }
237
285
 
238
- void
239
- WindowsStringConverter::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd,
240
- string& target) const
241
- {
242
- if(sourceStart == sourceEnd)
243
- {
244
- target = "";
245
- return;
286
+ return const_cast<Byte*>(reinterpret_cast<const Byte*>(_buffer.data())) + bytesUsed;
246
287
  }
247
288
 
248
- if(_cp == CP_UTF8)
289
+ void swap(string& other, const Byte* tail)
249
290
  {
250
- string tmp(reinterpret_cast<const char*>(sourceStart), sourceEnd - sourceStart);
251
- tmp.swap(target);
252
- return;
291
+ assert(tail >= reinterpret_cast<const Byte*>(_buffer.data()));
292
+ _buffer.resize(static_cast<size_t>(tail - reinterpret_cast<const Byte*>(_buffer.data())));
293
+ other.swap(_buffer);
253
294
  }
254
295
 
255
- //
256
- // First convert to wstring (UTF-16)
257
- //
258
- wstring wtarget;
259
- _unicodeWstringConverter.fromUTF8(sourceStart, sourceEnd, wtarget);
260
-
261
- //
262
- // WC_ERR_INVALID_CHARS conversion flag is only supported with 65001 (UTF-8) and
263
- // 54936 (GB18030 Simplified Chinese)
264
- //
265
- DWORD flags = (_cp == 65001 || _cp == 54936) ? WC_ERR_INVALID_CHARS : 0;
266
- //
267
- // And then to a multi-byte narrow string
268
- //
269
- int size = 0;
270
- int writtenChar = 0;
271
- ScopedArray<char> buffer;
272
- do
273
- {
274
- size = size == 0 ? static_cast<int>(sourceEnd - sourceStart) + 2 : 2 * size;
275
- buffer.reset(new char[size]);
276
- writtenChar = WideCharToMultiByte(_cp, flags, wtarget.data(), static_cast<int>(wtarget.size()),
277
- buffer.get(), size, 0, 0);
278
- } while(writtenChar == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
279
-
280
- if(writtenChar == 0)
281
- {
282
- throw IllegalConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString());
283
- }
296
+ private:
297
+ string _buffer;
298
+ };
284
299
 
285
- target.assign(buffer.get(), writtenChar);
286
300
  }
287
301
 
288
- #endif
302
+ IceUtil::UTF8Buffer::~UTF8Buffer()
303
+ {
304
+ // Out of line to avoid weak vtable
305
+ }
289
306
 
307
+ WstringConverterPtr
308
+ IceUtil::createUnicodeWstringConverter()
309
+ {
310
+ return getUnicodeWstringConverter();
311
+ }
290
312
 
291
313
  StringConverterPtr
292
314
  IceUtil::getProcessStringConverter()
@@ -298,75 +320,54 @@ IceUtil::getProcessStringConverter()
298
320
  void
299
321
  IceUtil::setProcessStringConverter(const StringConverterPtr& converter)
300
322
  {
301
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(processStringConverterMutex);
302
- processStringConverter = converter;
323
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(processStringConverterMutex);
324
+ processStringConverter = converter;
303
325
  }
304
326
 
305
327
  WstringConverterPtr
306
328
  IceUtil::getProcessWstringConverter()
307
329
  {
308
330
  IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(processStringConverterMutex);
309
- return processWstringConverter;
331
+ if(processWstringConverter)
332
+ {
333
+ return processWstringConverter;
334
+ }
335
+ else
336
+ {
337
+ return getUnicodeWstringConverter();
338
+ }
310
339
  }
311
340
 
312
341
  void
313
342
  IceUtil::setProcessWstringConverter(const WstringConverterPtr& converter)
314
343
  {
315
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(processStringConverterMutex);
316
- processWstringConverter = converter;
344
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(processStringConverterMutex);
345
+ processWstringConverter = converter;
317
346
  }
318
347
 
319
348
  string
320
- IceUtil::wstringToString(const wstring& v, const StringConverterPtr& converter, const WstringConverterPtr& wConverter,
321
- IceUtil::ConversionFlags flags)
349
+ IceUtil::wstringToString(const wstring& v, const StringConverterPtr& converter, const WstringConverterPtr& wConverter)
322
350
  {
323
351
  string target;
324
352
  if(!v.empty())
325
353
  {
354
+ const WstringConverterPtr& wConverterWithDefault = wConverter ? wConverter : getUnicodeWstringConverter();
355
+
326
356
  //
327
- // First convert to UTF8 narrow string.
357
+ // First convert to UTF-8 narrow string.
328
358
  //
329
- if(wConverter)
330
- {
331
- UTF8BufferI buffer;
332
- Byte* last = wConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
333
- target = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
334
- }
335
- else
336
- {
337
- size_t size = v.size() * 4 * sizeof(char);
338
-
339
- Byte* outBuf = new Byte[size];
340
- Byte* targetStart = outBuf;
341
- Byte* targetEnd = outBuf + size;
342
-
343
- const wchar_t* sourceStart = v.data();
344
-
345
- ConversionResult cr =
346
- convertUTFWstringToUTF8(
347
- sourceStart, sourceStart + v.size(),
348
- targetStart, targetEnd, flags);
349
-
350
- if(cr != conversionOK)
351
- {
352
- delete[] outBuf;
353
- assert(cr == sourceExhausted || cr == sourceIllegal);
354
- throw IllegalConversionException(__FILE__, __LINE__,
355
- cr == sourceExhausted ? "partial character" : "bad encoding");
356
- }
357
-
358
- target = string(reinterpret_cast<char*>(outBuf), static_cast<size_t>(targetStart - outBuf));
359
- delete[] outBuf;
360
- }
359
+ UTF8BufferI buffer;
360
+ Byte* last = wConverterWithDefault->toUTF8(v.data(), v.data() + v.size(), buffer);
361
+ buffer.swap(target, last);
361
362
 
362
363
  //
363
- // If narrow string converter is present convert to the native narrow string encoding, otherwise
364
+ // If narrow string converter is present convert to the native narrow string encoding, otherwise
364
365
  // native narrow string encoding is UTF8 and we are done.
365
366
  //
366
367
  if(converter)
367
368
  {
368
369
  string tmp;
369
- converter->fromUTF8(reinterpret_cast<const Byte*>(target.data()),
370
+ converter->fromUTF8(reinterpret_cast<const Byte*>(target.data()),
370
371
  reinterpret_cast<const Byte*>(target.data() + target.size()), tmp);
371
372
  tmp.swap(target);
372
373
  }
@@ -375,8 +376,7 @@ IceUtil::wstringToString(const wstring& v, const StringConverterPtr& converter,
375
376
  }
376
377
 
377
378
  wstring
378
- IceUtil::stringToWstring(const string& v, const StringConverterPtr& converter,
379
- const WstringConverterPtr& wConverter, IceUtil::ConversionFlags flags)
379
+ IceUtil::stringToWstring(const string& v, const StringConverterPtr& converter, const WstringConverterPtr& wConverter)
380
380
  {
381
381
  wstring target;
382
382
  if(!v.empty())
@@ -390,36 +390,21 @@ IceUtil::stringToWstring(const string& v, const StringConverterPtr& converter,
390
390
  {
391
391
  UTF8BufferI buffer;
392
392
  Byte* last = converter->toUTF8(v.data(), v.data() + v.size(), buffer);
393
- tmp = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
393
+ buffer.swap(tmp, last);
394
394
  }
395
395
  else
396
396
  {
397
397
  tmp = v;
398
398
  }
399
399
 
400
+ const WstringConverterPtr& wConverterWithDefault = wConverter ? wConverter : getUnicodeWstringConverter();
401
+
400
402
  //
401
- // If there is a wide string converter use fromUTF8 to convert to the wide string native encoding.
403
+ // Convert from UTF-8 to the wide string encoding
402
404
  //
403
- if(wConverter)
404
- {
405
- wConverter->fromUTF8(reinterpret_cast<const Byte*>(tmp.data()),
406
- reinterpret_cast<const Byte*>(tmp.data() + tmp.size()), target);
407
- }
408
- else
409
- {
410
- const Byte* sourceStart = reinterpret_cast<const Byte*>(tmp.data());
411
-
412
- ConversionResult cr =
413
- convertUTF8ToUTFWstring(sourceStart, sourceStart + tmp.size(), target, flags);
405
+ wConverterWithDefault->fromUTF8(reinterpret_cast<const Byte*>(tmp.data()),
406
+ reinterpret_cast<const Byte*>(tmp.data() + tmp.size()), target);
414
407
 
415
- if(cr != conversionOK)
416
- {
417
- assert(cr == sourceExhausted || cr == sourceIllegal);
418
-
419
- throw IllegalConversionException(__FILE__, __LINE__,
420
- cr == sourceExhausted ? "partial character" : "bad encoding");
421
- }
422
- }
423
408
  }
424
409
  return target;
425
410
  }
@@ -430,10 +415,12 @@ IceUtil::nativeToUTF8(const string& str, const IceUtil::StringConverterPtr& conv
430
415
  if(!converter || str.empty())
431
416
  {
432
417
  return str;
433
- }
418
+ }
434
419
  UTF8BufferI buffer;
435
420
  Byte* last = converter->toUTF8(str.data(), str.data() + str.size(), buffer);
436
- return string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
421
+ string result;
422
+ buffer.swap(result, last);
423
+ return result;
437
424
  }
438
425
 
439
426
  string
@@ -448,3 +435,248 @@ IceUtil::UTF8ToNative(const string& str, const IceUtil::StringConverterPtr& conv
448
435
  reinterpret_cast<const Byte*>(str.data() + str.size()), tmp);
449
436
  return tmp;
450
437
  }
438
+
439
+ #ifdef ICE_HAS_CODECVT_UTF8
440
+
441
+ #if defined(_MSC_VER) && (_MSC_VER >= 1900)
442
+ //
443
+ // Workaround for compiler bug - see http://stackoverflow.com/questions/32055357
444
+ //
445
+ typedef unsigned short Char16T;
446
+ typedef unsigned int Char32T;
447
+
448
+ #else
449
+ typedef char16_t Char16T;
450
+ typedef char32_t Char32T;
451
+ #endif
452
+
453
+ #endif
454
+
455
+ vector<unsigned short>
456
+ IceUtilInternal::toUTF16(const vector<Byte>& source)
457
+ {
458
+ vector<unsigned short> result;
459
+ if(!source.empty())
460
+ {
461
+
462
+ #ifdef ICE_HAS_CODECVT_UTF8
463
+ assert(sizeof(Char16T) == sizeof(unsigned short));
464
+
465
+ typedef wstring_convert<codecvt_utf8_utf16<Char16T>, Char16T> Convert;
466
+
467
+ Convert convert;
468
+
469
+ try
470
+ {
471
+ Convert::wide_string ws = convert.from_bytes(reinterpret_cast<const char*>(&source.front()),
472
+ reinterpret_cast<const char*>(&source.front() + source.size()));
473
+
474
+ result = vector<unsigned short>(reinterpret_cast<const unsigned short*>(ws.data()),
475
+ reinterpret_cast<const unsigned short*>(ws.data()) + ws.length());
476
+ }
477
+ catch(const std::range_error& ex)
478
+ {
479
+ throw IllegalConversionException(__FILE__, __LINE__, ex.what());
480
+ }
481
+
482
+ #else
483
+ convertUTF8ToUTF16(source, result);
484
+ #endif
485
+ }
486
+ return result;
487
+ }
488
+
489
+ vector<unsigned int>
490
+ IceUtilInternal::toUTF32(const vector<Byte>& source)
491
+ {
492
+ vector<unsigned int> result;
493
+ if(!source.empty())
494
+ {
495
+
496
+ #ifdef ICE_HAS_CODECVT_UTF8
497
+ assert(sizeof(Char32T) == sizeof(unsigned int));
498
+
499
+ typedef wstring_convert<codecvt_utf8<Char32T>, Char32T> Convert;
500
+ Convert convert;
501
+
502
+ try
503
+ {
504
+ Convert::wide_string ws = convert.from_bytes(reinterpret_cast<const char*>(&source.front()),
505
+ reinterpret_cast<const char*>(&source.front() + source.size()));
506
+
507
+ result = vector<unsigned int>(reinterpret_cast<const unsigned int*>(ws.data()),
508
+ reinterpret_cast<const unsigned int*>(ws.data()) + ws.length());
509
+ }
510
+ catch(const std::range_error& ex)
511
+ {
512
+ throw IllegalConversionException(__FILE__, __LINE__, ex.what());
513
+ }
514
+
515
+ #else
516
+ convertUTF8ToUTF32(source, result);
517
+ #endif
518
+ }
519
+ return result;
520
+ }
521
+
522
+ vector<Byte>
523
+ IceUtilInternal::fromUTF32(const vector<unsigned int>& source)
524
+ {
525
+ vector<Byte> result;
526
+ if(!source.empty())
527
+ {
528
+
529
+ #ifdef ICE_HAS_CODECVT_UTF8
530
+ assert(sizeof(Char32T) == sizeof(unsigned int));
531
+
532
+ typedef wstring_convert<codecvt_utf8<Char32T>, Char32T> Convert;
533
+ Convert convert;
534
+
535
+ try
536
+ {
537
+ Convert::byte_string bs = convert.to_bytes(reinterpret_cast<const Char32T*>(&source.front()),
538
+ reinterpret_cast<const Char32T*>(&source.front() + source.size()));
539
+
540
+ result = vector<Byte>(reinterpret_cast<const Byte*>(bs.data()),
541
+ reinterpret_cast<const Byte*>(bs.data()) + bs.length());
542
+ }
543
+ catch(const std::range_error& ex)
544
+ {
545
+ throw IllegalConversionException(__FILE__, __LINE__, ex.what());
546
+ }
547
+
548
+ #else
549
+ convertUTF32ToUTF8(source, result);
550
+ #endif
551
+ }
552
+ return result;
553
+ }
554
+
555
+ #ifdef _WIN32
556
+
557
+ namespace
558
+ {
559
+ //
560
+ // Converts to/from UTF-8 using MultiByteToWideChar and WideCharToMultiByte
561
+ //
562
+ class WindowsStringConverter : public StringConverter
563
+ {
564
+ public:
565
+
566
+ explicit WindowsStringConverter(unsigned int);
567
+
568
+ virtual Byte* toUTF8(const char*, const char*, UTF8Buffer&) const;
569
+
570
+ virtual void fromUTF8(const Byte*, const Byte*, string& target) const;
571
+
572
+ private:
573
+ unsigned int _cp;
574
+ };
575
+
576
+ WindowsStringConverter::WindowsStringConverter(unsigned int cp) :
577
+ _cp(cp)
578
+ {
579
+ }
580
+
581
+ Byte*
582
+ WindowsStringConverter::toUTF8(const char* sourceStart, const char* sourceEnd, UTF8Buffer& buffer) const
583
+ {
584
+ //
585
+ // First convert to UTF-16
586
+ //
587
+ int sourceSize = static_cast<int>(sourceEnd - sourceStart);
588
+ if(sourceSize == 0)
589
+ {
590
+ return buffer.getMoreBytes(1, 0);
591
+ }
592
+
593
+ int writtenWchar = 0;
594
+ wstring wbuffer;
595
+
596
+ //
597
+ // The following code pages doesn't support MB_ERR_INVALID_CHARS flag
598
+ // see http://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx
599
+ //
600
+ DWORD flags =
601
+ (_cp == 50220 || _cp == 50221 || _cp == 50222 ||
602
+ _cp == 50225 || _cp == 50227 || _cp == 50229 ||
603
+ _cp == 65000 || _cp == 42 || (_cp >= 57002 && _cp <= 57011)) ? 0 : MB_ERR_INVALID_CHARS;
604
+
605
+ do
606
+ {
607
+ wbuffer.resize(wbuffer.size() == 0 ? sourceSize + 2 : 2 * wbuffer.size());
608
+ writtenWchar = MultiByteToWideChar(_cp, flags, sourceStart, sourceSize,
609
+ const_cast<wchar_t*>(wbuffer.data()), static_cast<int>(wbuffer.size()));
610
+ } while(writtenWchar == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
611
+
612
+ if(writtenWchar == 0)
613
+ {
614
+ throw IllegalConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString());
615
+ }
616
+
617
+ wbuffer.resize(static_cast<size_t>(writtenWchar));
618
+
619
+ //
620
+ // Then convert this UTF-16 wbuffer into UTF-8
621
+ //
622
+ return getUnicodeWstringConverter()->toUTF8(wbuffer.data(), wbuffer.data() + wbuffer.size(), buffer);
623
+ }
624
+
625
+ void
626
+ WindowsStringConverter::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd, string& target) const
627
+ {
628
+ if(sourceStart == sourceEnd)
629
+ {
630
+ target = "";
631
+ return;
632
+ }
633
+
634
+ if(_cp == CP_UTF8)
635
+ {
636
+ string tmp(reinterpret_cast<const char*>(sourceStart), sourceEnd - sourceStart);
637
+ tmp.swap(target);
638
+ return;
639
+ }
640
+
641
+ //
642
+ // First convert to wstring (UTF-16)
643
+ //
644
+ wstring wtarget;
645
+ getUnicodeWstringConverter()->fromUTF8(sourceStart, sourceEnd, wtarget);
646
+
647
+ //
648
+ // WC_ERR_INVALID_CHARS conversion flag is only supported with 65001 (UTF-8) and
649
+ // 54936 (GB18030 Simplified Chinese)
650
+ //
651
+ DWORD flags = (_cp == 65001 || _cp == 54936) ? WC_ERR_INVALID_CHARS : 0;
652
+
653
+ //
654
+ // And then to a multi-byte narrow string
655
+ //
656
+ int writtenChar = -1;
657
+ do
658
+ {
659
+ target.resize(writtenChar == -1 ?
660
+ std::max<size_t>(sourceEnd - sourceStart + 2, target.size()) :
661
+ 2 * target.size());
662
+
663
+ writtenChar = WideCharToMultiByte(_cp, flags, wtarget.data(), static_cast<int>(wtarget.size()),
664
+ const_cast<char*>(target.data()), static_cast<int>(target.size()),
665
+ 0, 0);
666
+ } while(writtenChar == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
667
+
668
+ if(writtenChar == 0)
669
+ {
670
+ throw IllegalConversionException(__FILE__, __LINE__, IceUtilInternal::lastErrorToString());
671
+ }
672
+
673
+ target.resize(static_cast<size_t>(writtenChar));
674
+ }
675
+ }
676
+
677
+ StringConverterPtr
678
+ IceUtil::createWindowsStringConverter(unsigned int cp)
679
+ {
680
+ return ICE_MAKE_SHARED(WindowsStringConverter, cp);
681
+ }
682
+ #endif