├── .gitattributes
├── .gitignore
├── Bin
├── ChatServer - 副本.db
├── ChatServer.db
├── ChatServer.exe
├── ChatServer.iobj
├── ChatServer.ipdb
├── ChatServer_d.exe
├── DuiLib_u.dll
├── DuiLib_ud.dll
├── Skin
│ ├── MainWnd.xml
│ ├── TopBar_Close_Btn.png
│ ├── TopBar_Close_Btn_Click.png
│ ├── TopBar_Close_Btn_Hover.png
│ ├── TopBar_Full_Btn.png
│ ├── TopBar_Full_Btn_Click.png
│ ├── TopBar_Full_Btn_Hover.png
│ ├── TopBar_Narrow_Btn.png
│ ├── TopBar_Narrow_Btn_Click.png
│ ├── TopBar_Narrow_Btn_Hover.png
│ ├── TopBar_Window_Btn.png
│ ├── TopBar_Window_Btn_Click.png
│ └── TopBar_Window_Btn_Hover.png
├── Sqlite3.dll
├── mfc140u.dll
├── msvcp140.dll
└── vcruntime140.dll
├── ChatServer.sln
├── ChatServer
├── ChatServer.vcxproj
├── ChatServer.vcxproj.filters
├── Common.cpp
├── Common.h
├── DBModule.cpp
├── DBModule.h
├── DuiLib
│ ├── Control
│ │ ├── UIActiveX.cpp
│ │ ├── UIActiveX.h
│ │ ├── UIButton.cpp
│ │ ├── UIButton.h
│ │ ├── UICheckBox.cpp
│ │ ├── UICheckBox.h
│ │ ├── UICombo.cpp
│ │ ├── UICombo.h
│ │ ├── UIDateTime.cpp
│ │ ├── UIDateTime.h
│ │ ├── UIEdit.cpp
│ │ ├── UIEdit.h
│ │ ├── UIFlash.cpp
│ │ ├── UIFlash.h
│ │ ├── UIGifAnim.cpp
│ │ ├── UIGifAnim.h
│ │ ├── UILabel.cpp
│ │ ├── UILabel.h
│ │ ├── UIList.cpp
│ │ ├── UIList.h
│ │ ├── UIOption.cpp
│ │ ├── UIOption.h
│ │ ├── UIProgress.cpp
│ │ ├── UIProgress.h
│ │ ├── UIRichEdit.cpp
│ │ ├── UIRichEdit.h
│ │ ├── UIScrollBar.cpp
│ │ ├── UIScrollBar.h
│ │ ├── UISlider.cpp
│ │ ├── UISlider.h
│ │ ├── UIText.cpp
│ │ ├── UIText.h
│ │ ├── UITreeView.cpp
│ │ ├── UITreeView.h
│ │ ├── UIWebBrowser.cpp
│ │ └── UIWebBrowser.h
│ ├── Core
│ │ ├── UIBase.cpp
│ │ ├── UIBase.h
│ │ ├── UIContainer.cpp
│ │ ├── UIContainer.h
│ │ ├── UIControl.cpp
│ │ ├── UIControl.h
│ │ ├── UIDefine.h
│ │ ├── UIDlgBuilder.cpp
│ │ ├── UIDlgBuilder.h
│ │ ├── UIManager.cpp
│ │ ├── UIManager.h
│ │ ├── UIMarkup.cpp
│ │ ├── UIMarkup.h
│ │ ├── UIRender.cpp
│ │ └── UIRender.h
│ ├── Layout
│ │ ├── UIChildLayout.cpp
│ │ ├── UIChildLayout.h
│ │ ├── UIHorizontalLayout.cpp
│ │ ├── UIHorizontalLayout.h
│ │ ├── UITabLayout.cpp
│ │ ├── UITabLayout.h
│ │ ├── UITileLayout.cpp
│ │ ├── UITileLayout.h
│ │ ├── UIVerticalLayout.cpp
│ │ └── UIVerticalLayout.h
│ ├── UIlib.cpp
│ ├── UIlib.h
│ └── Utils
│ │ ├── FlashEventHandler.h
│ │ ├── UIDelegate.cpp
│ │ ├── UIDelegate.h
│ │ ├── Utils.cpp
│ │ ├── Utils.h
│ │ ├── WebBrowserEventHandler.h
│ │ ├── WinImplBase.cpp
│ │ ├── WinImplBase.h
│ │ ├── WndShadow.cpp
│ │ ├── WndShadow.h
│ │ ├── XUnzip.cpp
│ │ ├── downloadmgr.h
│ │ ├── stb_image.c
│ │ └── stb_image.h
├── IOCPBase.cpp
├── IOCPBase.h
├── Mian.cpp
├── NetwordModule.cpp
├── NetwordModule.h
├── Protocol.h
├── SQLite.cpp
├── SQLite.h
├── Server.cpp
├── Server.h
├── ServerMainWnd.cpp
├── ServerMainWnd.h
├── Sqlite3
│ ├── sqlite3.c
│ └── sqlite3.h
├── Task.cpp
├── Task.h
├── ThreadPool.cpp
├── ThreadPool.h
├── dll
│ ├── DuiLib_u.dll
│ ├── DuiLib_ud.dll
│ ├── Sqlite3.dll
│ └── Sqlite3.lib
├── lib
│ ├── DuiLib_u.lib
│ ├── DuiLib_ud.lib
│ └── Sqlite3.lib
├── rapidjson
│ ├── allocators.h
│ ├── cursorstreamwrapper.h
│ ├── document.h
│ ├── encodedstream.h
│ ├── encodings.h
│ ├── error
│ │ ├── en.h
│ │ └── error.h
│ ├── filereadstream.h
│ ├── filewritestream.h
│ ├── fwd.h
│ ├── internal
│ │ ├── biginteger.h
│ │ ├── diyfp.h
│ │ ├── dtoa.h
│ │ ├── ieee754.h
│ │ ├── itoa.h
│ │ ├── meta.h
│ │ ├── pow10.h
│ │ ├── regex.h
│ │ ├── stack.h
│ │ ├── strfunc.h
│ │ ├── strtod.h
│ │ └── swap.h
│ ├── istreamwrapper.h
│ ├── memorybuffer.h
│ ├── memorystream.h
│ ├── msinttypes
│ │ ├── inttypes.h
│ │ └── stdint.h
│ ├── ostreamwrapper.h
│ ├── pointer.h
│ ├── prettywriter.h
│ ├── rapidjson.h
│ ├── reader.h
│ ├── schema.h
│ ├── stream.h
│ ├── stringbuffer.h
│ └── writer.h
├── stdafx.cpp
└── stdafx.h
├── LICENSE
├── README.md
├── Sqlite3.dll
└── Sqlite3.lib
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Oo]bj/
24 | [Ll]og/
25 |
26 | # Visual Studio 2015 cache/options directory
27 | .vs/
28 | # Uncomment if you have tasks that create the project's static files in wwwroot
29 | #wwwroot/
30 |
31 | # MSTest test Results
32 | [Tt]est[Rr]esult*/
33 | [Bb]uild[Ll]og.*
34 |
35 | # NUNIT
36 | *.VisualState.xml
37 | TestResult.xml
38 |
39 | # Build Results of an ATL Project
40 | [Dd]ebugPS/
41 | [Rr]eleasePS/
42 | dlldata.c
43 |
44 | # Benchmark Results
45 | BenchmarkDotNet.Artifacts/
46 |
47 | # .NET Core
48 | project.lock.json
49 | project.fragment.lock.json
50 | artifacts/
51 | **/Properties/launchSettings.json
52 |
53 | *_i.c
54 | *_p.c
55 | *_i.h
56 | *.ilk
57 | *.meta
58 | *.obj
59 | *.pch
60 | *.pdb
61 | *.pgc
62 | *.pgd
63 | *.rsp
64 | *.sbr
65 | *.tlb
66 | *.tli
67 | *.tlh
68 | *.tmp
69 | *.tmp_proj
70 | *.log
71 | *.vspscc
72 | *.vssscc
73 | .builds
74 | *.pidb
75 | *.svclog
76 | *.scc
77 |
78 | # Chutzpah Test files
79 | _Chutzpah*
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opendb
86 | *.opensdf
87 | *.sdf
88 | *.cachefile
89 | *.VC.db
90 | *.VC.VC.opendb
91 |
92 | # Visual Studio profiler
93 | *.psess
94 | *.vsp
95 | *.vspx
96 | *.sap
97 |
98 | # TFS 2012 Local Workspace
99 | $tf/
100 |
101 | # Guidance Automation Toolkit
102 | *.gpState
103 |
104 | # ReSharper is a .NET coding add-in
105 | _ReSharper*/
106 | *.[Rr]e[Ss]harper
107 | *.DotSettings.user
108 |
109 | # JustCode is a .NET coding add-in
110 | .JustCode
111 |
112 | # TeamCity is a build add-in
113 | _TeamCity*
114 |
115 | # DotCover is a Code Coverage Tool
116 | *.dotCover
117 |
118 | # AxoCover is a Code Coverage Tool
119 | .axoCover/*
120 | !.axoCover/settings.json
121 |
122 | # Visual Studio code coverage results
123 | *.coverage
124 | *.coveragexml
125 |
126 | # NCrunch
127 | _NCrunch_*
128 | .*crunch*.local.xml
129 | nCrunchTemp_*
130 |
131 | # MightyMoose
132 | *.mm.*
133 | AutoTest.Net/
134 |
135 | # Web workbench (sass)
136 | .sass-cache/
137 |
138 | # Installshield output folder
139 | [Ee]xpress/
140 |
141 | # DocProject is a documentation generator add-in
142 | DocProject/buildhelp/
143 | DocProject/Help/*.HxT
144 | DocProject/Help/*.HxC
145 | DocProject/Help/*.hhc
146 | DocProject/Help/*.hhk
147 | DocProject/Help/*.hhp
148 | DocProject/Help/Html2
149 | DocProject/Help/html
150 |
151 | # Click-Once directory
152 | publish/
153 |
154 | # Publish Web Output
155 | *.[Pp]ublish.xml
156 | *.azurePubxml
157 | # Note: Comment the next line if you want to checkin your web deploy settings,
158 | # but database connection strings (with potential passwords) will be unencrypted
159 | *.pubxml
160 | *.publishproj
161 |
162 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
163 | # checkin your Azure Web App publish settings, but sensitive information contained
164 | # in these scripts will be unencrypted
165 | PublishScripts/
166 |
167 | # NuGet Packages
168 | *.nupkg
169 | # The packages folder can be ignored because of Package Restore
170 | **/packages/*
171 | # except build/, which is used as an MSBuild target.
172 | !**/packages/build/
173 | # Uncomment if necessary however generally it will be regenerated when needed
174 | #!**/packages/repositories.config
175 | # NuGet v3's project.json files produces more ignorable files
176 | *.nuget.props
177 | *.nuget.targets
178 |
179 | # Microsoft Azure Build Output
180 | csx/
181 | *.build.csdef
182 |
183 | # Microsoft Azure Emulator
184 | ecf/
185 | rcf/
186 |
187 | # Windows Store app package directories and files
188 | AppPackages/
189 | BundleArtifacts/
190 | Package.StoreAssociation.xml
191 | _pkginfo.txt
192 | *.appx
193 |
194 | # Visual Studio cache files
195 | # files ending in .cache can be ignored
196 | *.[Cc]ache
197 | # but keep track of directories ending in .cache
198 | !*.[Cc]ache/
199 |
200 | # Others
201 | ClientBin/
202 | ~$*
203 | *~
204 | *.dbmdl
205 | *.dbproj.schemaview
206 | *.jfm
207 | *.pfx
208 | *.publishsettings
209 | orleans.codegen.cs
210 |
211 | # Since there are multiple workflows, uncomment next line to ignore bower_components
212 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
213 | #bower_components/
214 |
215 | # RIA/Silverlight projects
216 | Generated_Code/
217 |
218 | # Backup & report files from converting an old project file
219 | # to a newer Visual Studio version. Backup files are not needed,
220 | # because we have git ;-)
221 | _UpgradeReport_Files/
222 | Backup*/
223 | UpgradeLog*.XML
224 | UpgradeLog*.htm
225 |
226 | # SQL Server files
227 | *.mdf
228 | *.ldf
229 | *.ndf
230 |
231 | # Business Intelligence projects
232 | *.rdl.data
233 | *.bim.layout
234 | *.bim_*.settings
235 |
236 | # Microsoft Fakes
237 | FakesAssemblies/
238 |
239 | # GhostDoc plugin setting file
240 | *.GhostDoc.xml
241 |
242 | # Node.js Tools for Visual Studio
243 | .ntvs_analysis.dat
244 | node_modules/
245 |
246 | # Typescript v1 declaration files
247 | typings/
248 |
249 | # Visual Studio 6 build log
250 | *.plg
251 |
252 | # Visual Studio 6 workspace options file
253 | *.opt
254 |
255 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
256 | *.vbw
257 |
258 | # Visual Studio LightSwitch build output
259 | **/*.HTMLClient/GeneratedArtifacts
260 | **/*.DesktopClient/GeneratedArtifacts
261 | **/*.DesktopClient/ModelManifest.xml
262 | **/*.Server/GeneratedArtifacts
263 | **/*.Server/ModelManifest.xml
264 | _Pvt_Extensions
265 |
266 | # Paket dependency manager
267 | .paket/paket.exe
268 | paket-files/
269 |
270 | # FAKE - F# Make
271 | .fake/
272 |
273 | # JetBrains Rider
274 | .idea/
275 | *.sln.iml
276 |
277 | # CodeRush
278 | .cr/
279 |
280 | # Python Tools for Visual Studio (PTVS)
281 | __pycache__/
282 | *.pyc
283 |
284 | # Cake - Uncomment if you are using it
285 | # tools/**
286 | # !tools/packages.config
287 |
288 | # Tabs Studio
289 | *.tss
290 |
291 | # Telerik's JustMock configuration file
292 | *.jmconfig
293 |
294 | # BizTalk build output
295 | *.btp.cs
296 | *.btm.cs
297 | *.odx.cs
298 | *.xsd.cs
299 |
--------------------------------------------------------------------------------
/Bin/ChatServer - 副本.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/ChatServer - 副本.db
--------------------------------------------------------------------------------
/Bin/ChatServer.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/ChatServer.db
--------------------------------------------------------------------------------
/Bin/ChatServer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/ChatServer.exe
--------------------------------------------------------------------------------
/Bin/ChatServer.iobj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/ChatServer.iobj
--------------------------------------------------------------------------------
/Bin/ChatServer.ipdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/ChatServer.ipdb
--------------------------------------------------------------------------------
/Bin/ChatServer_d.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/ChatServer_d.exe
--------------------------------------------------------------------------------
/Bin/DuiLib_u.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/DuiLib_u.dll
--------------------------------------------------------------------------------
/Bin/DuiLib_ud.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/DuiLib_ud.dll
--------------------------------------------------------------------------------
/Bin/Skin/MainWnd.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Close_Btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Close_Btn.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Close_Btn_Click.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Close_Btn_Click.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Close_Btn_Hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Close_Btn_Hover.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Full_Btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Full_Btn.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Full_Btn_Click.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Full_Btn_Click.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Full_Btn_Hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Full_Btn_Hover.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Narrow_Btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Narrow_Btn.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Narrow_Btn_Click.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Narrow_Btn_Click.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Narrow_Btn_Hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Narrow_Btn_Hover.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Window_Btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Window_Btn.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Window_Btn_Click.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Window_Btn_Click.png
--------------------------------------------------------------------------------
/Bin/Skin/TopBar_Window_Btn_Hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Skin/TopBar_Window_Btn_Hover.png
--------------------------------------------------------------------------------
/Bin/Sqlite3.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/Sqlite3.dll
--------------------------------------------------------------------------------
/Bin/mfc140u.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/mfc140u.dll
--------------------------------------------------------------------------------
/Bin/msvcp140.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/msvcp140.dll
--------------------------------------------------------------------------------
/Bin/vcruntime140.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/Bin/vcruntime140.dll
--------------------------------------------------------------------------------
/ChatServer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27130.2027
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChatServer", "ChatServer\ChatServer.vcxproj", "{E67746AB-FF2E-4367-9E34-70906D43B84B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {E67746AB-FF2E-4367-9E34-70906D43B84B}.Debug|x64.ActiveCfg = Debug|x64
17 | {E67746AB-FF2E-4367-9E34-70906D43B84B}.Debug|x64.Build.0 = Debug|x64
18 | {E67746AB-FF2E-4367-9E34-70906D43B84B}.Debug|x86.ActiveCfg = Debug|Win32
19 | {E67746AB-FF2E-4367-9E34-70906D43B84B}.Debug|x86.Build.0 = Debug|Win32
20 | {E67746AB-FF2E-4367-9E34-70906D43B84B}.Release|x64.ActiveCfg = Release|x64
21 | {E67746AB-FF2E-4367-9E34-70906D43B84B}.Release|x64.Build.0 = Release|x64
22 | {E67746AB-FF2E-4367-9E34-70906D43B84B}.Release|x86.ActiveCfg = Release|Win32
23 | {E67746AB-FF2E-4367-9E34-70906D43B84B}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {226BD94C-6A7B-4E2A-8490-FAA0359366C7}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/ChatServer/ChatServer.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 15.0
23 | {E67746AB-FF2E-4367-9E34-70906D43B84B}
24 | ChatServer
25 | 10.0.16299.0
26 |
27 |
28 |
29 | Application
30 | true
31 | v141
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v141
38 | true
39 | Unicode
40 | false
41 |
42 |
43 | Application
44 | true
45 | v141
46 | MultiByte
47 |
48 |
49 | Application
50 | false
51 | v141
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | $(SolutionDir)\Bin\
75 | ChatServer_d
76 |
77 |
78 | $(SolutionDir)\Bin\
79 |
80 |
81 | $(SolutionDir)\Bin\
82 |
83 |
84 | ChatServer_d
85 | $(SolutionDir)\Bin\
86 |
87 |
88 |
89 | Level3
90 | Disabled
91 | true
92 | true
93 |
94 |
95 | ../Bin/ChatServer_d.exe
96 |
97 |
98 |
99 |
100 | Level3
101 | Disabled
102 | true
103 | true
104 |
105 |
106 | ../Bin/ChatClient_d.exe
107 |
108 |
109 |
110 |
111 | Level3
112 | MaxSpeed
113 | true
114 | true
115 | true
116 | true
117 | MultiThreadedDLL
118 |
119 |
120 | true
121 | true
122 | ../Bin/ChatServer.exe
123 |
124 |
125 |
126 |
127 | Level3
128 | MaxSpeed
129 | true
130 | true
131 | true
132 | true
133 |
134 |
135 | true
136 | true
137 | ../Bin/ChatClient.exe
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 | Designer
169 |
170 |
171 |
172 |
173 |
174 |
--------------------------------------------------------------------------------
/ChatServer/ChatServer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {cd45d795-9675-4b8c-bdbd-e5ccbba5785f}
18 |
19 |
20 |
21 |
22 | 头文件
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 | 头文件
32 |
33 |
34 | 头文件
35 |
36 |
37 | 头文件
38 |
39 |
40 | 头文件
41 |
42 |
43 | 头文件
44 |
45 |
46 | 头文件
47 |
48 |
49 | 头文件
50 |
51 |
52 | 头文件
53 |
54 |
55 |
56 |
57 | 源文件
58 |
59 |
60 | 源文件
61 |
62 |
63 | 源文件
64 |
65 |
66 | 源文件
67 |
68 |
69 | 源文件
70 |
71 |
72 | 源文件
73 |
74 |
75 | 源文件
76 |
77 |
78 | 源文件
79 |
80 |
81 | 源文件
82 |
83 |
84 | 源文件
85 |
86 |
87 | 源文件
88 |
89 |
90 |
91 |
92 | XML
93 |
94 |
95 |
--------------------------------------------------------------------------------
/ChatServer/Common.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/Common.cpp
--------------------------------------------------------------------------------
/ChatServer/Common.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/Common.h
--------------------------------------------------------------------------------
/ChatServer/DBModule.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DBModule.cpp
--------------------------------------------------------------------------------
/ChatServer/DBModule.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DBModule.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIActiveX.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIActiveX.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIActiveX.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIACTIVEX_H__
2 | #define __UIACTIVEX_H__
3 |
4 | #pragma once
5 |
6 | struct IOleObject;
7 |
8 |
9 | namespace DuiLib {
10 | /////////////////////////////////////////////////////////////////////////////////////
11 | //
12 |
13 | class CActiveXCtrl;
14 |
15 | template< class T >
16 | class CSafeRelease
17 | {
18 | public:
19 | CSafeRelease(T* p) : m_p(p) { };
20 | ~CSafeRelease() { if( m_p != NULL ) m_p->Release(); };
21 | T* Detach() { T* t = m_p; m_p = NULL; return t; };
22 | T* m_p;
23 | };
24 |
25 | /////////////////////////////////////////////////////////////////////////////////////
26 | //
27 |
28 | class DUILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI
29 | {
30 | friend class CActiveXCtrl;
31 | public:
32 | CActiveXUI();
33 | virtual ~CActiveXUI();
34 |
35 | LPCTSTR GetClass() const;
36 | LPVOID GetInterface(LPCTSTR pstrName);
37 | UINT GetControlFlags() const;
38 | HWND GetNativeWindow() const;
39 |
40 | bool IsDelayCreate() const;
41 | void SetDelayCreate(bool bDelayCreate = true);
42 |
43 | bool CreateControl(const CLSID clsid);
44 | bool CreateControl(LPCTSTR pstrCLSID);
45 | HRESULT GetControl(const IID iid, LPVOID* ppRet);
46 | CLSID GetClisd() const;
47 | CDuiString GetModuleName() const;
48 | void SetModuleName(LPCTSTR pstrText);
49 |
50 | void SetVisible(bool bVisible = true);
51 | void SetInternVisible(bool bVisible = true);
52 | void SetPos(RECT rc, bool bNeedInvalidate = true);
53 | void Move(SIZE szOffset, bool bNeedInvalidate = true);
54 | bool DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
55 |
56 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
57 |
58 | LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
59 |
60 | protected:
61 | virtual void ReleaseControl();
62 | virtual bool DoCreateControl();
63 |
64 | protected:
65 | CLSID m_clsid;
66 | CDuiString m_sModuleName;
67 | bool m_bCreated;
68 | bool m_bDelayCreate;
69 | IOleObject* m_pUnk;
70 | CActiveXCtrl* m_pControl;
71 | HWND m_hwndHost;
72 | };
73 |
74 | } // namespace DuiLib
75 |
76 | #endif // __UIACTIVEX_H__
77 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIButton.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIButton.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UICheckBox.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UICheckBox.h"
3 |
4 | namespace DuiLib
5 | {
6 | LPCTSTR CCheckBoxUI::GetClass() const
7 | {
8 | return DUI_CTR_CHECKBOX;
9 | }
10 |
11 | LPVOID CCheckBoxUI::GetInterface(LPCTSTR pstrName)
12 | {
13 | if( _tcscmp(pstrName, DUI_CTR_CHECKBOX) == 0 ) return static_cast(this);
14 | return COptionUI::GetInterface(pstrName);
15 | }
16 |
17 | void CCheckBoxUI::SetCheck(bool bCheck, bool bTriggerEvent)
18 | {
19 | Selected(bCheck, bTriggerEvent);
20 | }
21 |
22 | bool CCheckBoxUI::GetCheck() const
23 | {
24 | return IsSelected();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UICheckBox.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UICheckBox.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UICombo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UICombo.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UICombo.h:
--------------------------------------------------------------------------------
1 | #ifndef __UICOMBO_H__
2 | #define __UICOMBO_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib {
7 | /////////////////////////////////////////////////////////////////////////////////////
8 | //
9 |
10 | class CComboWnd;
11 |
12 | class DUILIB_API CComboUI : public CContainerUI, public IListOwnerUI
13 | {
14 | friend class CComboWnd;
15 | public:
16 | CComboUI();
17 |
18 | LPCTSTR GetClass() const;
19 | LPVOID GetInterface(LPCTSTR pstrName);
20 |
21 | void DoInit();
22 | UINT GetControlFlags() const;
23 |
24 | CDuiString GetText() const;
25 | void SetEnabled(bool bEnable = true);
26 |
27 | CDuiString GetDropBoxAttributeList();
28 | void SetDropBoxAttributeList(LPCTSTR pstrList);
29 | SIZE GetDropBoxSize() const;
30 | void SetDropBoxSize(SIZE szDropBox);
31 |
32 | int GetCurSel() const;
33 | bool GetSelectCloseFlag();
34 | void SetSelectCloseFlag(bool flag);
35 | bool SelectItem(int iIndex, bool bTakeFocus = false, bool bTriggerEvent=true);
36 | bool ExpandItem(int iIndex, bool bExpand = true);
37 | int GetExpandedItem() const;
38 |
39 | bool SetItemIndex(CControlUI* pControl, int iNewIndex);
40 | bool SetMultiItemIndex(CControlUI* pStartControl, int iCount, int iNewStartIndex);
41 | bool Add(CControlUI* pControl);
42 | bool AddAt(CControlUI* pControl, int iIndex);
43 | bool Remove(CControlUI* pControl, bool bDoNotDestroy=false);
44 | bool RemoveAt(int iIndex, bool bDoNotDestroy=false);
45 | void RemoveAll();
46 |
47 | bool Activate();
48 |
49 | bool GetShowText() const;
50 | void SetShowText(bool flag);
51 | RECT GetTextPadding() const;
52 | void SetTextPadding(RECT rc);
53 | LPCTSTR GetNormalImage() const;
54 | void SetNormalImage(LPCTSTR pStrImage);
55 | LPCTSTR GetHotImage() const;
56 | void SetHotImage(LPCTSTR pStrImage);
57 | LPCTSTR GetPushedImage() const;
58 | void SetPushedImage(LPCTSTR pStrImage);
59 | LPCTSTR GetFocusedImage() const;
60 | void SetFocusedImage(LPCTSTR pStrImage);
61 | LPCTSTR GetDisabledImage() const;
62 | void SetDisabledImage(LPCTSTR pStrImage);
63 |
64 | TListInfoUI* GetListInfo();
65 | UINT GetItemFixedHeight();
66 | void SetItemFixedHeight(UINT nHeight);
67 | int GetItemFont(int index);
68 | void SetItemFont(int index);
69 | UINT GetItemTextStyle();
70 | void SetItemTextStyle(UINT uStyle);
71 | RECT GetItemTextPadding() const;
72 | void SetItemTextPadding(RECT rc);
73 | DWORD GetItemTextColor() const;
74 | void SetItemTextColor(DWORD dwTextColor);
75 | DWORD GetItemBkColor() const;
76 | void SetItemBkColor(DWORD dwBkColor);
77 | LPCTSTR GetItemBkImage() const;
78 | void SetItemBkImage(LPCTSTR pStrImage);
79 | bool IsAlternateBk() const;
80 | void SetAlternateBk(bool bAlternateBk);
81 | DWORD GetSelectedItemTextColor() const;
82 | void SetSelectedItemTextColor(DWORD dwTextColor);
83 | DWORD GetSelectedItemBkColor() const;
84 | void SetSelectedItemBkColor(DWORD dwBkColor);
85 | LPCTSTR GetSelectedItemImage() const;
86 | void SetSelectedItemImage(LPCTSTR pStrImage);
87 | DWORD GetHotItemTextColor() const;
88 | void SetHotItemTextColor(DWORD dwTextColor);
89 | DWORD GetHotItemBkColor() const;
90 | void SetHotItemBkColor(DWORD dwBkColor);
91 | LPCTSTR GetHotItemImage() const;
92 | void SetHotItemImage(LPCTSTR pStrImage);
93 | DWORD GetDisabledItemTextColor() const;
94 | void SetDisabledItemTextColor(DWORD dwTextColor);
95 | DWORD GetDisabledItemBkColor() const;
96 | void SetDisabledItemBkColor(DWORD dwBkColor);
97 | LPCTSTR GetDisabledItemImage() const;
98 | void SetDisabledItemImage(LPCTSTR pStrImage);
99 | int GetItemHLineSize() const;
100 | void SetItemHLineSize(int iSize);
101 | DWORD GetItemHLineColor() const;
102 | void SetItemHLineColor(DWORD dwLineColor);
103 | int GetItemVLineSize() const;
104 | void SetItemVLineSize(int iSize);
105 | DWORD GetItemVLineColor() const;
106 | void SetItemVLineColor(DWORD dwLineColor);
107 | bool IsItemShowHtml();
108 | void SetItemShowHtml(bool bShowHtml = true);
109 |
110 | SIZE EstimateSize(SIZE szAvailable);
111 | void SetPos(RECT rc, bool bNeedInvalidate = true);
112 | void Move(SIZE szOffset, bool bNeedInvalidate = true);
113 | void DoEvent(TEventUI& event);
114 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
115 |
116 | bool DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
117 | void PaintText(HDC hDC);
118 | void PaintStatusImage(HDC hDC);
119 |
120 | protected:
121 | CComboWnd* m_pWindow;
122 |
123 | int m_iCurSel;
124 | bool m_bShowText;
125 | bool m_bSelectCloseFlag;
126 | RECT m_rcTextPadding;
127 | CDuiString m_sDropBoxAttributes;
128 | SIZE m_szDropBox;
129 | UINT m_uButtonState;
130 |
131 | TDrawInfo m_diNormal;
132 | TDrawInfo m_diHot;
133 | TDrawInfo m_diPushed;
134 | TDrawInfo m_diFocused;
135 | TDrawInfo m_diDisabled;
136 |
137 | TListInfoUI m_ListInfo;
138 | };
139 |
140 | } // namespace DuiLib
141 |
142 | #endif // __UICOMBO_H__
143 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIDateTime.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIDateTime.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIDateTime.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIDateTime.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIEdit.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIEdit.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIEdit.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIEDIT_H__
2 | #define __UIEDIT_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class CEditWnd;
9 |
10 | class DUILIB_API CEditUI : public CLabelUI
11 | {
12 | friend class CEditWnd;
13 | public:
14 | CEditUI();
15 |
16 | LPCTSTR GetClass() const;
17 | LPVOID GetInterface(LPCTSTR pstrName);
18 | UINT GetControlFlags() const;
19 | HWND GetNativeWindow() const;
20 |
21 | void SetEnabled(bool bEnable = true);
22 | void SetText(LPCTSTR pstrText);
23 | void SetMaxChar(UINT uMax);
24 | UINT GetMaxChar();
25 | void SetReadOnly(bool bReadOnly);
26 | bool IsReadOnly() const;
27 | void SetPasswordMode(bool bPasswordMode);
28 | bool IsPasswordMode() const;
29 | void SetPasswordChar(TCHAR cPasswordChar);
30 | TCHAR GetPasswordChar() const;
31 | bool IsAutoSelAll();
32 | void SetAutoSelAll(bool bAutoSelAll);
33 | void SetNumberOnly(bool bNumberOnly);
34 | bool IsNumberOnly() const;
35 | int GetWindowStyls() const;
36 | HWND GetNativeEditHWND() const;
37 |
38 | LPCTSTR GetNormalImage();
39 | void SetNormalImage(LPCTSTR pStrImage);
40 | LPCTSTR GetHotImage();
41 | void SetHotImage(LPCTSTR pStrImage);
42 | LPCTSTR GetFocusedImage();
43 | void SetFocusedImage(LPCTSTR pStrImage);
44 | LPCTSTR GetDisabledImage();
45 | void SetDisabledImage(LPCTSTR pStrImage);
46 | void SetNativeEditBkColor(DWORD dwBkColor);
47 | DWORD GetNativeEditBkColor() const;
48 |
49 | void SetSel(long nStartChar, long nEndChar);
50 | void SetSelAll();
51 | void SetReplaceSel(LPCTSTR lpszReplace);
52 |
53 | void SetPos(RECT rc, bool bNeedInvalidate = true);
54 | void Move(SIZE szOffset, bool bNeedInvalidate = true);
55 | void SetVisible(bool bVisible = true);
56 | void SetInternVisible(bool bVisible = true);
57 | SIZE EstimateSize(SIZE szAvailable);
58 | void DoEvent(TEventUI& event);
59 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
60 |
61 | void PaintStatusImage(HDC hDC);
62 | void PaintText(HDC hDC);
63 |
64 | protected:
65 | CEditWnd* m_pWindow;
66 |
67 | UINT m_uMaxChar;
68 | bool m_bReadOnly;
69 | bool m_bPasswordMode;
70 | bool m_bAutoSelAll;
71 | TCHAR m_cPasswordChar;
72 | UINT m_uButtonState;
73 | DWORD m_dwEditbkColor;
74 | int m_iWindowStyls;
75 |
76 | TDrawInfo m_diNormal;
77 | TDrawInfo m_diHot;
78 | TDrawInfo m_diFocused;
79 | TDrawInfo m_diDisabled;
80 | };
81 | }
82 | #endif // __UIEDIT_H__
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIFlash.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIFlash.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIFlash.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIFlash.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIGifAnim.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIGifAnim.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIGifAnim.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIGifAnim.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UILabel.h:
--------------------------------------------------------------------------------
1 | #ifndef __UILABEL_H__
2 | #define __UILABEL_H__
3 |
4 | #pragma once
5 |
6 | #define _USE_GDIPLUS 1
7 |
8 | #ifdef _USE_GDIPLUS
9 | #include
10 | #pragma comment( lib, "GdiPlus.lib" )
11 | using namespace Gdiplus;
12 | class DUILIB_API Gdiplus::RectF;
13 | struct DUILIB_API Gdiplus::GdiplusStartupInput;
14 | #endif
15 |
16 |
17 | namespace DuiLib
18 | {
19 | class DUILIB_API CLabelUI : public CControlUI
20 | {
21 | public:
22 | CLabelUI();
23 | ~CLabelUI();
24 |
25 | LPCTSTR GetClass() const;
26 | LPVOID GetInterface(LPCTSTR pstrName);
27 |
28 | void SetFixedWidth(int cx);
29 | void SetFixedHeight(int cy);
30 | void SetText(LPCTSTR pstrText);
31 |
32 | void SetTextStyle(UINT uStyle);
33 | UINT GetTextStyle() const;
34 | bool IsMultiLine();
35 | void SetMultiLine(bool bMultiLine = true);
36 | void SetTextColor(DWORD dwTextColor);
37 | DWORD GetTextColor() const;
38 | void SetDisabledTextColor(DWORD dwTextColor);
39 | DWORD GetDisabledTextColor() const;
40 | void SetFont(int index);
41 | int GetFont() const;
42 | RECT GetTextPadding() const;
43 | void SetTextPadding(RECT rc);
44 | bool IsShowHtml();
45 | void SetShowHtml(bool bShowHtml = true);
46 |
47 | SIZE EstimateSize(SIZE szAvailable);
48 | void DoEvent(TEventUI& event);
49 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
50 |
51 | void PaintText(HDC hDC);
52 |
53 | #ifdef _USE_GDIPLUS
54 | void SetEnabledEffect(bool _EnabledEffect);
55 | bool GetEnabledEffect();
56 | void SetEnabledLuminous(bool bEnableLuminous);
57 | bool GetEnabledLuminous();
58 | void SetLuminousFuzzy(float fFuzzy);
59 | float GetLuminousFuzzy();
60 | void SetGradientLength(int _GradientLength);
61 | int GetGradientLength();
62 | void SetShadowOffset(int _offset,int _angle);
63 | RectF GetShadowOffset();
64 | void SetTextColor1(DWORD _TextColor1);
65 | DWORD GetTextColor1();
66 | void SetTextShadowColorA(DWORD _TextShadowColorA);
67 | DWORD GetTextShadowColorA();
68 | void SetTextShadowColorB(DWORD _TextShadowColorB);
69 | DWORD GetTextShadowColorB();
70 | void SetStrokeColor(DWORD _StrokeColor);
71 | DWORD GetStrokeColor();
72 | void SetGradientAngle(int _SetGradientAngle);
73 | int GetGradientAngle();
74 | void SetEnabledStroke(bool _EnabledStroke);
75 | bool GetEnabledStroke();
76 | void SetEnabledShadow(bool _EnabledShadowe);
77 | bool GetEnabledShadow();
78 | #endif
79 |
80 | protected:
81 | LPWSTR m_pWideText;
82 | DWORD m_dwTextColor;
83 | DWORD m_dwDisabledTextColor;
84 | int m_iFont;
85 | UINT m_uTextStyle;
86 | RECT m_rcTextPadding;
87 | bool m_bShowHtml;
88 | SIZE m_szAvailableLast;
89 | SIZE m_cxyFixedLast;
90 | bool m_bNeedEstimateSize;
91 |
92 | float m_fLuminousFuzzy;
93 | int m_GradientLength;
94 | int m_GradientAngle;
95 | bool m_EnableEffect;
96 | bool m_bEnableLuminous;
97 | bool m_EnabledStroke;
98 | bool m_EnabledShadow;
99 | DWORD m_dwTextColor1;
100 | DWORD m_dwTextShadowColorA;
101 | DWORD m_dwTextShadowColorB;
102 | DWORD m_dwStrokeColor;
103 | RectF m_ShadowOffset;
104 | ULONG_PTR m_gdiplusToken;
105 | #ifdef _USE_GDIPLUS
106 | GdiplusStartupInput m_gdiplusStartupInput;
107 | #endif
108 | };
109 | }
110 |
111 | #endif // __UILABEL_H__
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIList.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIList.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIList.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIList.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIOption.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIOption.h"
3 |
4 | namespace DuiLib
5 | {
6 | COptionUI::COptionUI() : m_bSelected(false), m_dwSelectedBkColor(0), m_dwSelectedTextColor(0)
7 | {
8 | }
9 |
10 | COptionUI::~COptionUI()
11 | {
12 | if( !m_sGroupName.IsEmpty() && m_pManager ) m_pManager->RemoveOptionGroup(m_sGroupName, this);
13 | }
14 |
15 | LPCTSTR COptionUI::GetClass() const
16 | {
17 | return DUI_CTR_OPTION;
18 | }
19 |
20 | LPVOID COptionUI::GetInterface(LPCTSTR pstrName)
21 | {
22 | if( _tcscmp(pstrName, DUI_CTR_OPTION) == 0 ) return static_cast(this);
23 | return CButtonUI::GetInterface(pstrName);
24 | }
25 |
26 | void COptionUI::SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit)
27 | {
28 | CControlUI::SetManager(pManager, pParent, bInit);
29 | if( bInit && !m_sGroupName.IsEmpty() ) {
30 | if (m_pManager) m_pManager->AddOptionGroup(m_sGroupName, this);
31 | }
32 | }
33 |
34 | LPCTSTR COptionUI::GetGroup() const
35 | {
36 | return m_sGroupName;
37 | }
38 |
39 | void COptionUI::SetGroup(LPCTSTR pStrGroupName)
40 | {
41 | if( pStrGroupName == NULL ) {
42 | if( m_sGroupName.IsEmpty() ) return;
43 | m_sGroupName.Empty();
44 | }
45 | else {
46 | if( m_sGroupName == pStrGroupName ) return;
47 | if (!m_sGroupName.IsEmpty() && m_pManager) m_pManager->RemoveOptionGroup(m_sGroupName, this);
48 | m_sGroupName = pStrGroupName;
49 | }
50 |
51 | if( !m_sGroupName.IsEmpty() ) {
52 | if (m_pManager) m_pManager->AddOptionGroup(m_sGroupName, this);
53 | }
54 | else {
55 | if (m_pManager) m_pManager->RemoveOptionGroup(m_sGroupName, this);
56 | }
57 |
58 | Selected(m_bSelected);
59 | }
60 |
61 | bool COptionUI::IsSelected() const
62 | {
63 | return m_bSelected;
64 | }
65 |
66 | void COptionUI::Selected(bool bSelected, bool bTriggerEvent)
67 | {
68 | if( m_bSelected == bSelected ) return;
69 | m_bSelected = bSelected;
70 | if( m_bSelected ) m_uButtonState |= UISTATE_SELECTED;
71 | else m_uButtonState &= ~UISTATE_SELECTED;
72 |
73 | if( m_pManager != NULL ) {
74 | if( !m_sGroupName.IsEmpty() ) {
75 | if( m_bSelected ) {
76 | CDuiPtrArray* aOptionGroup = m_pManager->GetOptionGroup(m_sGroupName);
77 | for( int i = 0; i < aOptionGroup->GetSize(); i++ ) {
78 | COptionUI* pControl = static_cast(aOptionGroup->GetAt(i));
79 | if( pControl != this ) {
80 | pControl->Selected(false, bTriggerEvent);
81 | }
82 | }
83 | if (bTriggerEvent) m_pManager->SendNotify(this, DUI_MSGTYPE_SELECTCHANGED);
84 | }
85 | }
86 | else {
87 | if (bTriggerEvent) m_pManager->SendNotify(this, DUI_MSGTYPE_SELECTCHANGED);
88 | }
89 | }
90 |
91 | Invalidate();
92 | }
93 |
94 | bool COptionUI::Activate()
95 | {
96 | if( !CButtonUI::Activate() ) return false;
97 | if( !m_sGroupName.IsEmpty() ) Selected(true);
98 | else Selected(!m_bSelected);
99 |
100 | return true;
101 | }
102 |
103 | void COptionUI::SetEnabled(bool bEnable)
104 | {
105 | CControlUI::SetEnabled(bEnable);
106 | if( !IsEnabled() ) {
107 | if( m_bSelected ) m_uButtonState = UISTATE_SELECTED;
108 | else m_uButtonState = 0;
109 | }
110 | }
111 |
112 | LPCTSTR COptionUI::GetSelectedImage()
113 | {
114 | return m_diSelected.sDrawString;
115 | }
116 |
117 | void COptionUI::SetSelectedImage(LPCTSTR pStrImage)
118 | {
119 | if( m_diSelected.sDrawString == pStrImage && m_diSelected.pImageInfo != NULL ) return;
120 | m_diSelected.Clear();
121 | m_diSelected.sDrawString = pStrImage;
122 | Invalidate();
123 | }
124 |
125 | LPCTSTR COptionUI::GetSelectedHotImage()
126 | {
127 | return m_diSelectedHot.sDrawString;
128 | }
129 |
130 | void COptionUI::SetSelectedHotImage( LPCTSTR pStrImage )
131 | {
132 | if( m_diSelectedHot.sDrawString == pStrImage && m_diSelectedHot.pImageInfo != NULL ) return;
133 | m_diSelectedHot.Clear();
134 | m_diSelectedHot.sDrawString = pStrImage;
135 | Invalidate();
136 | }
137 |
138 | void COptionUI::SetSelectedTextColor(DWORD dwTextColor)
139 | {
140 | m_dwSelectedTextColor = dwTextColor;
141 | }
142 |
143 | DWORD COptionUI::GetSelectedTextColor()
144 | {
145 | if (m_dwSelectedTextColor == 0) m_dwSelectedTextColor = m_pManager->GetDefaultFontColor();
146 | return m_dwSelectedTextColor;
147 | }
148 |
149 | void COptionUI::SetSelectedBkColor( DWORD dwBkColor )
150 | {
151 | m_dwSelectedBkColor = dwBkColor;
152 | }
153 |
154 | DWORD COptionUI::GetSelectBkColor()
155 | {
156 | return m_dwSelectedBkColor;
157 | }
158 |
159 | LPCTSTR COptionUI::GetForeImage()
160 | {
161 | return m_diFore.sDrawString;
162 | }
163 |
164 | void COptionUI::SetForeImage(LPCTSTR pStrImage)
165 | {
166 | if( m_diFore.sDrawString == pStrImage && m_diFore.pImageInfo != NULL ) return;
167 | m_diFore.Clear();
168 | m_diFore.sDrawString = pStrImage;
169 | Invalidate();
170 | }
171 |
172 | SIZE COptionUI::EstimateSize(SIZE szAvailable)
173 | {
174 | if( m_cxyFixed.cy == 0 ) return CDuiSize(m_cxyFixed.cx, m_pManager->GetFontInfo(GetFont())->tm.tmHeight + 8);
175 | return CControlUI::EstimateSize(szAvailable);
176 | }
177 |
178 | void COptionUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
179 | {
180 | if( _tcscmp(pstrName, _T("group")) == 0 ) SetGroup(pstrValue);
181 | else if( _tcscmp(pstrName, _T("selected")) == 0 ) Selected(_tcscmp(pstrValue, _T("true")) == 0);
182 | else if( _tcscmp(pstrName, _T("selectedimage")) == 0 ) SetSelectedImage(pstrValue);
183 | else if( _tcscmp(pstrName, _T("selectedhotimage")) == 0 ) SetSelectedHotImage(pstrValue);
184 | else if( _tcscmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue);
185 | else if( _tcscmp(pstrName, _T("selectedbkcolor")) == 0 ) {
186 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
187 | LPTSTR pstr = NULL;
188 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
189 | SetSelectedBkColor(clrColor);
190 | }
191 | else if( _tcscmp(pstrName, _T("selectedtextcolor")) == 0 ) {
192 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
193 | LPTSTR pstr = NULL;
194 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
195 | SetSelectedTextColor(clrColor);
196 | }
197 | else CButtonUI::SetAttribute(pstrName, pstrValue);
198 | }
199 |
200 | void COptionUI::PaintStatusImage(HDC hDC)
201 | {
202 | if( (m_uButtonState & UISTATE_SELECTED) != 0 ) {
203 | if ((m_uButtonState & UISTATE_HOT) != 0)
204 | {
205 | if (DrawImage(hDC, m_diSelectedHot)) goto Label_ForeImage;
206 | }
207 |
208 | if( DrawImage(hDC, m_diSelected) ) goto Label_ForeImage;
209 | else if(m_dwSelectedBkColor != 0) {
210 | CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwSelectedBkColor));
211 | goto Label_ForeImage;
212 | }
213 | }
214 |
215 | UINT uSavedState = m_uButtonState;
216 | m_uButtonState &= ~UISTATE_PUSHED;
217 | CButtonUI::PaintStatusImage(hDC);
218 | m_uButtonState = uSavedState;
219 |
220 | Label_ForeImage:
221 | DrawImage(hDC, m_diFore);
222 | }
223 |
224 | void COptionUI::PaintText(HDC hDC)
225 | {
226 | if( (m_uButtonState & UISTATE_SELECTED) != 0 )
227 | {
228 | DWORD oldTextColor = m_dwTextColor;
229 | if( m_dwSelectedTextColor != 0 ) m_dwTextColor = m_dwSelectedTextColor;
230 |
231 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor();
232 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor();
233 |
234 | if( m_sText.IsEmpty() ) return;
235 | int nLinks = 0;
236 | RECT rc = m_rcItem;
237 | rc.left += m_rcTextPadding.left;
238 | rc.right -= m_rcTextPadding.right;
239 | rc.top += m_rcTextPadding.top;
240 | rc.bottom -= m_rcTextPadding.bottom;
241 |
242 | if( m_bShowHtml )
243 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, IsEnabled()?m_dwTextColor:m_dwDisabledTextColor, \
244 | NULL, NULL, nLinks, m_iFont, m_uTextStyle);
245 | else
246 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, IsEnabled()?m_dwTextColor:m_dwDisabledTextColor, \
247 | m_iFont, m_uTextStyle);
248 |
249 | m_dwTextColor = oldTextColor;
250 | }
251 | else
252 | {
253 | UINT uSavedState = m_uButtonState;
254 | m_uButtonState &= ~UISTATE_PUSHED;
255 | CButtonUI::PaintText(hDC);
256 | m_uButtonState = uSavedState;
257 | }
258 | }
259 | }
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIOption.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIOPTION_H__
2 | #define __UIOPTION_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API COptionUI : public CButtonUI
9 | {
10 | public:
11 | COptionUI();
12 | ~COptionUI();
13 |
14 | LPCTSTR GetClass() const;
15 | LPVOID GetInterface(LPCTSTR pstrName);
16 |
17 | void SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit = true);
18 |
19 | bool Activate();
20 | void SetEnabled(bool bEnable = true);
21 |
22 | LPCTSTR GetSelectedImage();
23 | void SetSelectedImage(LPCTSTR pStrImage);
24 |
25 | LPCTSTR GetSelectedHotImage();
26 | void SetSelectedHotImage(LPCTSTR pStrImage);
27 |
28 | void SetSelectedTextColor(DWORD dwTextColor);
29 | DWORD GetSelectedTextColor();
30 |
31 | void SetSelectedBkColor(DWORD dwBkColor);
32 | DWORD GetSelectBkColor();
33 |
34 | LPCTSTR GetForeImage();
35 | void SetForeImage(LPCTSTR pStrImage);
36 |
37 | LPCTSTR GetGroup() const;
38 | void SetGroup(LPCTSTR pStrGroupName = NULL);
39 | bool IsSelected() const;
40 | virtual void Selected(bool bSelected, bool bTriggerEvent=true);
41 |
42 | SIZE EstimateSize(SIZE szAvailable);
43 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
44 |
45 | void PaintStatusImage(HDC hDC);
46 | void PaintText(HDC hDC);
47 |
48 | protected:
49 | bool m_bSelected;
50 | CDuiString m_sGroupName;
51 |
52 | DWORD m_dwSelectedBkColor;
53 | DWORD m_dwSelectedTextColor;
54 |
55 | TDrawInfo m_diSelected;
56 | TDrawInfo m_diSelectedHot;
57 | TDrawInfo m_diFore;
58 | };
59 |
60 | } // namespace DuiLib
61 |
62 | #endif // __UIOPTION_H__
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIProgress.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIProgress.h"
3 |
4 | namespace DuiLib
5 | {
6 | CProgressUI::CProgressUI() : m_bHorizontal(true), m_nMin(0), m_nMax(100), m_nValue(0)
7 | {
8 | m_uTextStyle = DT_SINGLELINE | DT_CENTER;
9 | SetFixedHeight(12);
10 | }
11 |
12 | LPCTSTR CProgressUI::GetClass() const
13 | {
14 | return DUI_CTR_PROGRESS;
15 | }
16 |
17 | LPVOID CProgressUI::GetInterface(LPCTSTR pstrName)
18 | {
19 | if( _tcscmp(pstrName, DUI_CTR_PROGRESS) == 0 ) return static_cast(this);
20 | return CLabelUI::GetInterface(pstrName);
21 | }
22 |
23 | bool CProgressUI::IsHorizontal()
24 | {
25 | return m_bHorizontal;
26 | }
27 |
28 | void CProgressUI::SetHorizontal(bool bHorizontal)
29 | {
30 | if( m_bHorizontal == bHorizontal ) return;
31 |
32 | m_bHorizontal = bHorizontal;
33 | Invalidate();
34 | }
35 |
36 | int CProgressUI::GetMinValue() const
37 | {
38 | return m_nMin;
39 | }
40 |
41 | void CProgressUI::SetMinValue(int nMin)
42 | {
43 | m_nMin = nMin;
44 | Invalidate();
45 | }
46 |
47 | int CProgressUI::GetMaxValue() const
48 | {
49 | return m_nMax;
50 | }
51 |
52 | void CProgressUI::SetMaxValue(int nMax)
53 | {
54 | m_nMax = nMax;
55 | Invalidate();
56 | }
57 |
58 | int CProgressUI::GetValue() const
59 | {
60 | return m_nValue;
61 | }
62 |
63 | void CProgressUI::SetValue(int nValue)
64 | {
65 | m_nValue = nValue;
66 | if (m_nValue > m_nMax) m_nValue = m_nMax;
67 | if (m_nValue < m_nMin) m_nValue = m_nMin;
68 | Invalidate();
69 | }
70 |
71 | LPCTSTR CProgressUI::GetForeImage() const
72 | {
73 | return m_diFore.sDrawString;
74 | }
75 |
76 | void CProgressUI::SetForeImage(LPCTSTR pStrImage)
77 | {
78 | if( m_diFore.sDrawString == pStrImage && m_diFore.pImageInfo != NULL ) return;
79 | m_diFore.Clear();
80 | m_diFore.sDrawString = pStrImage;
81 | Invalidate();
82 | }
83 |
84 | void CProgressUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
85 | {
86 | if( _tcscmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue);
87 | else if( _tcscmp(pstrName, _T("hor")) == 0 ) SetHorizontal(_tcscmp(pstrValue, _T("true")) == 0);
88 | else if( _tcscmp(pstrName, _T("min")) == 0 ) SetMinValue(_ttoi(pstrValue));
89 | else if( _tcscmp(pstrName, _T("max")) == 0 ) SetMaxValue(_ttoi(pstrValue));
90 | else if( _tcscmp(pstrName, _T("value")) == 0 ) SetValue(_ttoi(pstrValue));
91 | else CLabelUI::SetAttribute(pstrName, pstrValue);
92 | }
93 |
94 | void CProgressUI::PaintStatusImage(HDC hDC)
95 | {
96 | if( m_nMax <= m_nMin ) m_nMax = m_nMin + 1;
97 | if( m_nValue > m_nMax ) m_nValue = m_nMax;
98 | if( m_nValue < m_nMin ) m_nValue = m_nMin;
99 |
100 | RECT rc = {0};
101 | if( m_bHorizontal ) {
102 | rc.right = (m_nValue - m_nMin) * (m_rcItem.right - m_rcItem.left) / (m_nMax - m_nMin);
103 | rc.bottom = m_rcItem.bottom - m_rcItem.top;
104 | }
105 | else {
106 | rc.top = (m_rcItem.bottom - m_rcItem.top) * (m_nMax - m_nValue) / (m_nMax - m_nMin);
107 | rc.right = m_rcItem.right - m_rcItem.left;
108 | rc.bottom = m_rcItem.bottom - m_rcItem.top;
109 | }
110 | m_diFore.rcDestOffset = rc;
111 | if( DrawImage(hDC, m_diFore) ) return;
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIProgress.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIPROGRESS_H__
2 | #define __UIPROGRESS_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API CProgressUI : public CLabelUI
9 | {
10 | public:
11 | CProgressUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 |
16 | bool IsHorizontal();
17 | void SetHorizontal(bool bHorizontal = true);
18 | int GetMinValue() const;
19 | void SetMinValue(int nMin);
20 | int GetMaxValue() const;
21 | void SetMaxValue(int nMax);
22 | int GetValue() const;
23 | void SetValue(int nValue);
24 | LPCTSTR GetForeImage() const;
25 | void SetForeImage(LPCTSTR pStrImage);
26 |
27 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
28 | void PaintStatusImage(HDC hDC);
29 |
30 | protected:
31 | bool m_bHorizontal;
32 | int m_nMax;
33 | int m_nMin;
34 | int m_nValue;
35 |
36 | TDrawInfo m_diFore;
37 | };
38 |
39 | } // namespace DuiLib
40 |
41 | #endif // __UIPROGRESS_H__
42 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIRichEdit.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIRichEdit.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIRichEdit.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIRichEdit.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIScrollBar.h:
--------------------------------------------------------------------------------
1 | #ifndef __UISCROLLBAR_H__
2 | #define __UISCROLLBAR_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API CScrollBarUI : public CControlUI
9 | {
10 | public:
11 | CScrollBarUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 |
16 | CContainerUI* GetOwner() const;
17 | void SetOwner(CContainerUI* pOwner);
18 |
19 | void SetVisible(bool bVisible = true);
20 | void SetEnabled(bool bEnable = true);
21 | void SetFocus();
22 |
23 | bool IsHorizontal();
24 | void SetHorizontal(bool bHorizontal = true);
25 | int GetScrollRange() const;
26 | void SetScrollRange(int nRange);
27 | int GetScrollPos() const;
28 | void SetScrollPos(int nPos, bool bTriggerEvent=true);
29 | int GetLineSize() const;
30 | void SetLineSize(int nSize);
31 | int GetScrollUnit() const;
32 | void SetScrollUnit(int iUnit);
33 |
34 | bool GetShowButton1();
35 | void SetShowButton1(bool bShow);
36 | DWORD GetButton1Color() const;
37 | void SetButton1Color(DWORD dwColor);
38 | LPCTSTR GetButton1NormalImage();
39 | void SetButton1NormalImage(LPCTSTR pStrImage);
40 | LPCTSTR GetButton1HotImage();
41 | void SetButton1HotImage(LPCTSTR pStrImage);
42 | LPCTSTR GetButton1PushedImage();
43 | void SetButton1PushedImage(LPCTSTR pStrImage);
44 | LPCTSTR GetButton1DisabledImage();
45 | void SetButton1DisabledImage(LPCTSTR pStrImage);
46 |
47 | bool GetShowButton2();
48 | void SetShowButton2(bool bShow);
49 | DWORD GetButton2Color() const;
50 | void SetButton2Color(DWORD dwColor);
51 | LPCTSTR GetButton2NormalImage();
52 | void SetButton2NormalImage(LPCTSTR pStrImage);
53 | LPCTSTR GetButton2HotImage();
54 | void SetButton2HotImage(LPCTSTR pStrImage);
55 | LPCTSTR GetButton2PushedImage();
56 | void SetButton2PushedImage(LPCTSTR pStrImage);
57 | LPCTSTR GetButton2DisabledImage();
58 | void SetButton2DisabledImage(LPCTSTR pStrImage);
59 |
60 | DWORD GetThumbColor() const;
61 | void SetThumbColor(DWORD dwColor);
62 | LPCTSTR GetThumbNormalImage();
63 | void SetThumbNormalImage(LPCTSTR pStrImage);
64 | LPCTSTR GetThumbHotImage();
65 | void SetThumbHotImage(LPCTSTR pStrImage);
66 | LPCTSTR GetThumbPushedImage();
67 | void SetThumbPushedImage(LPCTSTR pStrImage);
68 | LPCTSTR GetThumbDisabledImage();
69 | void SetThumbDisabledImage(LPCTSTR pStrImage);
70 |
71 | LPCTSTR GetRailNormalImage();
72 | void SetRailNormalImage(LPCTSTR pStrImage);
73 | LPCTSTR GetRailHotImage();
74 | void SetRailHotImage(LPCTSTR pStrImage);
75 | LPCTSTR GetRailPushedImage();
76 | void SetRailPushedImage(LPCTSTR pStrImage);
77 | LPCTSTR GetRailDisabledImage();
78 | void SetRailDisabledImage(LPCTSTR pStrImage);
79 |
80 | LPCTSTR GetBkNormalImage();
81 | void SetBkNormalImage(LPCTSTR pStrImage);
82 | LPCTSTR GetBkHotImage();
83 | void SetBkHotImage(LPCTSTR pStrImage);
84 | LPCTSTR GetBkPushedImage();
85 | void SetBkPushedImage(LPCTSTR pStrImage);
86 | LPCTSTR GetBkDisabledImage();
87 | void SetBkDisabledImage(LPCTSTR pStrImage);
88 |
89 | void SetPos(RECT rc, bool bNeedInvalidate = true);
90 | void DoEvent(TEventUI& event);
91 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
92 |
93 | bool DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
94 |
95 | void PaintBk(HDC hDC);
96 | void PaintButton1(HDC hDC);
97 | void PaintButton2(HDC hDC);
98 | void PaintThumb(HDC hDC);
99 | void PaintRail(HDC hDC);
100 |
101 | protected:
102 |
103 | enum
104 | {
105 | DEFAULT_SCROLLBAR_SIZE = 16,
106 | DEFAULT_TIMERID = 10,
107 | };
108 |
109 | bool m_bHorizontal;
110 | int m_nRange;
111 | int m_nScrollPos;
112 | int m_nLineSize;
113 | int m_nScrollUnit;
114 | CContainerUI* m_pOwner;
115 | POINT ptLastMouse;
116 | int m_nLastScrollPos;
117 | int m_nLastScrollOffset;
118 | int m_nScrollRepeatDelay;
119 |
120 | TDrawInfo m_diBkNormal;
121 | TDrawInfo m_diBkHot;
122 | TDrawInfo m_diBkPushed;
123 | TDrawInfo m_diBkDisabled;
124 |
125 | bool m_bShowButton1;
126 | RECT m_rcButton1;
127 | UINT m_uButton1State;
128 | DWORD m_dwButton1Color;
129 | TDrawInfo m_diButton1Normal;
130 | TDrawInfo m_diButton1Hot;
131 | TDrawInfo m_diButton1Pushed;
132 | TDrawInfo m_diButton1Disabled;
133 |
134 | bool m_bShowButton2;
135 | RECT m_rcButton2;
136 | UINT m_uButton2State;
137 | DWORD m_dwButton2Color;
138 | TDrawInfo m_diButton2Normal;
139 | TDrawInfo m_diButton2Hot;
140 | TDrawInfo m_diButton2Pushed;
141 | TDrawInfo m_diButton2Disabled;
142 |
143 | RECT m_rcThumb;
144 | UINT m_uThumbState;
145 | DWORD m_dwThumbColor;
146 | TDrawInfo m_diThumbNormal;
147 | TDrawInfo m_diThumbHot;
148 | TDrawInfo m_diThumbPushed;
149 | TDrawInfo m_diThumbDisabled;
150 |
151 | TDrawInfo m_diRailNormal;
152 | TDrawInfo m_diRailHot;
153 | TDrawInfo m_diRailPushed;
154 | TDrawInfo m_diRailDisabled;
155 | };
156 | }
157 |
158 | #endif // __UISCROLLBAR_H__
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UISlider.h:
--------------------------------------------------------------------------------
1 | #ifndef __UISLIDER_H__
2 | #define __UISLIDER_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API CSliderUI : public CProgressUI
9 | {
10 | public:
11 | CSliderUI();
12 |
13 | LPCTSTR GetClass() const;
14 | UINT GetControlFlags() const;
15 | LPVOID GetInterface(LPCTSTR pstrName);
16 |
17 | void SetEnabled(bool bEnable = true);
18 |
19 | int GetChangeStep();
20 | void SetChangeStep(int step);
21 | void SetThumbSize(SIZE szXY);
22 | RECT GetThumbRect() const;
23 | bool IsImmMode() const;
24 | void SetImmMode(bool bImmMode);
25 | LPCTSTR GetThumbImage() const;
26 | void SetThumbImage(LPCTSTR pStrImage);
27 | LPCTSTR GetThumbHotImage() const;
28 | void SetThumbHotImage(LPCTSTR pStrImage);
29 | LPCTSTR GetThumbPushedImage() const;
30 | void SetThumbPushedImage(LPCTSTR pStrImage);
31 |
32 | void DoEvent(TEventUI& event);
33 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
34 | void PaintStatusImage(HDC hDC);
35 |
36 | protected:
37 | SIZE m_szThumb;
38 | UINT m_uButtonState;
39 | int m_nStep;
40 | bool m_bImmMode;
41 |
42 | TDrawInfo m_diThumb;
43 | TDrawInfo m_diThumbHot;
44 | TDrawInfo m_diThumbPushed;
45 | };
46 | }
47 |
48 | #endif // __UISLIDER_H__
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIText.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 | #include "UIText.h"
3 |
4 | namespace DuiLib
5 | {
6 | CTextUI::CTextUI() : m_nLinks(0), m_nHoverLink(-1)
7 | {
8 | m_uTextStyle = DT_WORDBREAK;
9 | m_rcTextPadding.left = 2;
10 | m_rcTextPadding.right = 2;
11 | ::ZeroMemory(m_rcLinks, sizeof(m_rcLinks));
12 | }
13 |
14 | CTextUI::~CTextUI()
15 | {
16 | }
17 |
18 | LPCTSTR CTextUI::GetClass() const
19 | {
20 | return DUI_CTR_TEXT;
21 | }
22 |
23 | LPVOID CTextUI::GetInterface(LPCTSTR pstrName)
24 | {
25 | if( _tcscmp(pstrName, DUI_CTR_TEXT) == 0 ) return static_cast(this);
26 | return CLabelUI::GetInterface(pstrName);
27 | }
28 |
29 | UINT CTextUI::GetControlFlags() const
30 | {
31 | if( IsEnabled() && m_nLinks > 0 ) return UIFLAG_SETCURSOR;
32 | else return 0;
33 | }
34 |
35 | CDuiString* CTextUI::GetLinkContent(int iIndex)
36 | {
37 | if( iIndex >= 0 && iIndex < m_nLinks ) return &m_sLinks[iIndex];
38 | return NULL;
39 | }
40 |
41 | void CTextUI::DoEvent(TEventUI& event)
42 | {
43 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) {
44 | if( m_pParent != NULL ) m_pParent->DoEvent(event);
45 | else CLabelUI::DoEvent(event);
46 | return;
47 | }
48 |
49 | if( event.Type == UIEVENT_SETCURSOR ) {
50 | for( int i = 0; i < m_nLinks; i++ ) {
51 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) {
52 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND)));
53 | return;
54 | }
55 | }
56 | }
57 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK && IsEnabled() ) {
58 | for( int i = 0; i < m_nLinks; i++ ) {
59 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) {
60 | Invalidate();
61 | return;
62 | }
63 | }
64 | }
65 | if( event.Type == UIEVENT_BUTTONUP && IsEnabled() ) {
66 | for( int i = 0; i < m_nLinks; i++ ) {
67 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) {
68 | m_pManager->SendNotify(this, DUI_MSGTYPE_LINK, i);
69 | return;
70 | }
71 | }
72 | }
73 | if( event.Type == UIEVENT_CONTEXTMENU )
74 | {
75 | return;
76 | }
77 | // When you move over a link
78 | if( m_nLinks > 0 && event.Type == UIEVENT_MOUSEMOVE && IsEnabled() ) {
79 | int nHoverLink = -1;
80 | for( int i = 0; i < m_nLinks; i++ ) {
81 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) {
82 | nHoverLink = i;
83 | break;
84 | }
85 | }
86 |
87 | if(m_nHoverLink != nHoverLink) {
88 | m_nHoverLink = nHoverLink;
89 | Invalidate();
90 | return;
91 | }
92 | }
93 | if( event.Type == UIEVENT_MOUSELEAVE ) {
94 | if( m_nLinks > 0 && IsEnabled() ) {
95 | if(m_nHoverLink != -1) {
96 | if( !::PtInRect(&m_rcLinks[m_nHoverLink], event.ptMouse) ) {
97 | m_nHoverLink = -1;
98 | Invalidate();
99 | if (m_pManager) m_pManager->RemoveMouseLeaveNeeded(this);
100 | }
101 | else {
102 | if (m_pManager) m_pManager->AddMouseLeaveNeeded(this);
103 | return;
104 | }
105 | }
106 | }
107 | }
108 |
109 | CLabelUI::DoEvent(event);
110 | }
111 |
112 | void CTextUI::PaintText(HDC hDC)
113 | {
114 | if( m_sText.IsEmpty() ) {
115 | m_nLinks = 0;
116 | return;
117 | }
118 |
119 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor();
120 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor();
121 |
122 | if( m_sText.IsEmpty() ) return;
123 |
124 | m_nLinks = lengthof(m_rcLinks);
125 | RECT rc = m_rcItem;
126 | rc.left += m_rcTextPadding.left;
127 | rc.right -= m_rcTextPadding.right;
128 | rc.top += m_rcTextPadding.top;
129 | rc.bottom -= m_rcTextPadding.bottom;
130 | if( IsEnabled() ) {
131 | if( m_bShowHtml )
132 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, m_dwTextColor, \
133 | m_rcLinks, m_sLinks, m_nLinks, m_iFont, m_uTextStyle);
134 | else
135 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, m_dwTextColor, \
136 | m_iFont, m_uTextStyle);
137 | }
138 | else {
139 | if( m_bShowHtml )
140 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, m_dwDisabledTextColor, \
141 | m_rcLinks, m_sLinks, m_nLinks, m_iFont, m_uTextStyle);
142 | else
143 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, m_dwDisabledTextColor, \
144 | m_iFont, m_uTextStyle);
145 | }
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIText.h:
--------------------------------------------------------------------------------
1 | #ifndef __UITEXT_H__
2 | #define __UITEXT_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API CTextUI : public CLabelUI
9 | {
10 | public:
11 | CTextUI();
12 | ~CTextUI();
13 |
14 | LPCTSTR GetClass() const;
15 | UINT GetControlFlags() const;
16 | LPVOID GetInterface(LPCTSTR pstrName);
17 |
18 | CDuiString* GetLinkContent(int iIndex);
19 |
20 | void DoEvent(TEventUI& event);
21 |
22 | void PaintText(HDC hDC);
23 |
24 | protected:
25 | enum { MAX_LINK = 8 };
26 | int m_nLinks;
27 | RECT m_rcLinks[MAX_LINK];
28 | CDuiString m_sLinks[MAX_LINK];
29 | int m_nHoverLink;
30 | };
31 |
32 | } // namespace DuiLib
33 |
34 | #endif //__UITEXT_H__
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UITreeView.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UITreeView.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UITreeView.h:
--------------------------------------------------------------------------------
1 | #ifndef __UITREEVIEW_H__
2 | #define __UITREEVIEW_H__
3 |
4 | #include
5 | using namespace std;
6 |
7 | #pragma once
8 |
9 | namespace DuiLib
10 | {
11 | class CTreeViewUI;
12 | class CCheckBoxUI;
13 | class CLabelUI;
14 | class COptionUI;
15 |
16 | class DUILIB_API CTreeNodeUI : public CListContainerElementUI
17 | {
18 | public:
19 | CTreeNodeUI(CTreeNodeUI* _ParentNode = NULL);
20 | ~CTreeNodeUI(void);
21 |
22 | public:
23 | LPCTSTR GetClass() const;
24 | LPVOID GetInterface(LPCTSTR pstrName);
25 | void DoEvent(TEventUI& event);
26 | void Invalidate();
27 | bool Select(bool bSelect = true, bool bTriggerEvent=true);
28 |
29 | bool Add(CControlUI* _pTreeNodeUI);
30 | bool AddAt(CControlUI* pControl, int iIndex);
31 |
32 | void SetVisibleTag(bool _IsVisible);
33 | bool GetVisibleTag();
34 | void SetItemText(LPCTSTR pstrValue);
35 | CDuiString GetItemText();
36 | void CheckBoxSelected(bool _Selected);
37 | bool IsCheckBoxSelected() const;
38 | bool IsHasChild() const;
39 | long GetTreeLevel() const;
40 | bool AddChildNode(CTreeNodeUI* _pTreeNodeUI);
41 | bool RemoveAt(CTreeNodeUI* _pTreeNodeUI);
42 | void SetParentNode(CTreeNodeUI* _pParentTreeNode);
43 | CTreeNodeUI* GetParentNode();
44 | long GetCountChild();
45 | void SetTreeView(CTreeViewUI* _CTreeViewUI);
46 | CTreeViewUI* GetTreeView();
47 | CTreeNodeUI* GetChildNode(int _nIndex);
48 | void SetVisibleFolderBtn(bool _IsVisibled);
49 | bool GetVisibleFolderBtn();
50 | void SetVisibleCheckBtn(bool _IsVisibled);
51 | bool GetVisibleCheckBtn();
52 | void SetItemTextColor(DWORD _dwItemTextColor);
53 | DWORD GetItemTextColor() const;
54 | void SetItemHotTextColor(DWORD _dwItemHotTextColor);
55 | DWORD GetItemHotTextColor() const;
56 | void SetSelItemTextColor(DWORD _dwSelItemTextColor);
57 | DWORD GetSelItemTextColor() const;
58 | void SetSelItemHotTextColor(DWORD _dwSelHotItemTextColor);
59 | DWORD GetSelItemHotTextColor() const;
60 |
61 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
62 |
63 | CDuiPtrArray GetTreeNodes();
64 |
65 | int GetTreeIndex();
66 | int GetNodeIndex();
67 |
68 | private:
69 | CTreeNodeUI* GetLastNode();
70 | CTreeNodeUI* CalLocation(CTreeNodeUI* _pTreeNodeUI);
71 | public:
72 | CHorizontalLayoutUI* GetTreeNodeHoriznotal() const {return pHoriz;};
73 | CCheckBoxUI* GetFolderButton() const {return pFolderButton;};
74 | CLabelUI* GetDottedLine() const {return pDottedLine;};
75 | CCheckBoxUI* GetCheckBox() const {return pCheckBox;};
76 | COptionUI* GetItemButton() const {return pItemButton;};
77 |
78 | private:
79 | long m_iTreeLavel;
80 | bool m_bIsVisable;
81 | bool m_bIsCheckBox;
82 | DWORD m_dwItemTextColor;
83 | DWORD m_dwItemHotTextColor;
84 | DWORD m_dwSelItemTextColor;
85 | DWORD m_dwSelItemHotTextColor;
86 |
87 | CTreeViewUI* pTreeView;
88 | CHorizontalLayoutUI* pHoriz;
89 | CCheckBoxUI* pFolderButton;
90 | CLabelUI* pDottedLine;
91 | CCheckBoxUI* pCheckBox;
92 | COptionUI* pItemButton;
93 |
94 | CTreeNodeUI* pParentTreeNode;
95 |
96 | CDuiPtrArray mTreeNodes;
97 | };
98 |
99 | class DUILIB_API CTreeViewUI : public CListUI,public INotifyUI
100 | {
101 | public:
102 | CTreeViewUI(void);
103 | ~CTreeViewUI(void);
104 |
105 | public:
106 | virtual LPCTSTR GetClass() const;
107 | virtual LPVOID GetInterface(LPCTSTR pstrName);
108 | virtual bool Add(CControlUI* pControl);
109 | virtual bool AddAt(CControlUI* pControl, int iIndex);
110 | virtual bool Remove(CControlUI* pControl, bool bDoNotDestroy=false);
111 | virtual bool RemoveAt(int iIndex, bool bDoNotDestroy=false);
112 | virtual void RemoveAll();
113 |
114 | long AddAt(CTreeNodeUI* pControl, int iIndex);
115 | bool AddAt(CTreeNodeUI* pControl,CTreeNodeUI* _IndexNode);
116 |
117 | virtual bool OnCheckBoxChanged(void* param);
118 | virtual bool OnFolderChanged(void* param);
119 | virtual bool OnDBClickItem(void* param);
120 | virtual bool SetItemCheckBox(bool _Selected,CTreeNodeUI* _TreeNode = NULL);
121 | virtual void SetItemExpand(bool _Expanded,CTreeNodeUI* _TreeNode = NULL);
122 | virtual void Notify(TNotifyUI& msg);
123 | virtual void SetVisibleFolderBtn(bool _IsVisibled);
124 | virtual bool GetVisibleFolderBtn();
125 | virtual void SetVisibleCheckBtn(bool _IsVisibled);
126 | virtual bool GetVisibleCheckBtn();
127 | virtual void SetItemMinWidth(UINT _ItemMinWidth);
128 | virtual UINT GetItemMinWidth();
129 | virtual void SetItemTextColor(DWORD _dwItemTextColor);
130 | virtual void SetItemHotTextColor(DWORD _dwItemHotTextColor);
131 | virtual void SetSelItemTextColor(DWORD _dwSelItemTextColor);
132 | virtual void SetSelItemHotTextColor(DWORD _dwSelHotItemTextColor);
133 |
134 | virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
135 | private:
136 | UINT m_uItemMinWidth;
137 | bool m_bVisibleFolderBtn;
138 | bool m_bVisibleCheckBtn;
139 | };
140 | }
141 |
142 |
143 | #endif // __UITREEVIEW_H__
144 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIWebBrowser.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIWebBrowser.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Control/UIWebBrowser.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Control/UIWebBrowser.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIBase.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIBase.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIBase.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIBase.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIContainer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIContainer.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIContainer.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIContainer.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIControl.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIControl.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIDefine.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIDefine.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIDlgBuilder.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIDlgBuilder.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIDlgBuilder.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIDLGBUILDER_H__
2 | #define __UIDLGBUILDER_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib {
7 |
8 | class IDialogBuilderCallback
9 | {
10 | public:
11 | virtual CControlUI* CreateControl(LPCTSTR pstrClass) = 0;
12 | };
13 |
14 |
15 | class DUILIB_API CDialogBuilder
16 | {
17 | public:
18 | CDialogBuilder();
19 | CControlUI* Create(STRINGorID xml, LPCTSTR type = NULL, IDialogBuilderCallback* pCallback = NULL,
20 | CPaintManagerUI* pManager = NULL, CControlUI* pParent = NULL);
21 | CControlUI* Create(IDialogBuilderCallback* pCallback = NULL, CPaintManagerUI* pManager = NULL,
22 | CControlUI* pParent = NULL);
23 |
24 | CMarkup* GetMarkup();
25 |
26 | void GetLastErrorMessage(LPTSTR pstrMessage, SIZE_T cchMax) const;
27 | void GetLastErrorLocation(LPTSTR pstrSource, SIZE_T cchMax) const;
28 | private:
29 | CControlUI* _Parse(CMarkupNode* parent, CControlUI* pParent = NULL, CPaintManagerUI* pManager = NULL);
30 |
31 | CMarkup m_xml;
32 | IDialogBuilderCallback* m_pCallback;
33 | LPCTSTR m_pstrtype;
34 | };
35 |
36 | } // namespace DuiLib
37 |
38 | #endif // __UIDLGBUILDER_H__
39 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIManager.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIManager.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIMarkup.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIMarkup.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIMarkup.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIMARKUP_H__
2 | #define __UIMARKUP_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib {
7 |
8 | enum
9 | {
10 | XMLFILE_ENCODING_UTF8 = 0,
11 | XMLFILE_ENCODING_UNICODE = 1,
12 | XMLFILE_ENCODING_ASNI = 2,
13 | };
14 |
15 | class CMarkup;
16 | class CMarkupNode;
17 |
18 |
19 | class DUILIB_API CMarkup
20 | {
21 | friend class CMarkupNode;
22 | public:
23 | CMarkup(LPCTSTR pstrXML = NULL);
24 | ~CMarkup();
25 |
26 | bool Load(LPCTSTR pstrXML);
27 | bool LoadFromMem(BYTE* pByte, DWORD dwSize, int encoding = XMLFILE_ENCODING_UTF8);
28 | bool LoadFromFile(LPCTSTR pstrFilename, int encoding = XMLFILE_ENCODING_UTF8);
29 | void Release();
30 | bool IsValid() const;
31 |
32 | void SetPreserveWhitespace(bool bPreserve = true);
33 | void GetLastErrorMessage(LPTSTR pstrMessage, SIZE_T cchMax) const;
34 | void GetLastErrorLocation(LPTSTR pstrSource, SIZE_T cchMax) const;
35 |
36 | CMarkupNode GetRoot();
37 |
38 | private:
39 | typedef struct tagXMLELEMENT
40 | {
41 | ULONG iStart;
42 | ULONG iChild;
43 | ULONG iNext;
44 | ULONG iParent;
45 | ULONG iData;
46 | } XMLELEMENT;
47 |
48 | LPTSTR m_pstrXML;
49 | XMLELEMENT* m_pElements;
50 | ULONG m_nElements;
51 | ULONG m_nReservedElements;
52 | TCHAR m_szErrorMsg[100];
53 | TCHAR m_szErrorXML[50];
54 | bool m_bPreserveWhitespace;
55 |
56 | private:
57 | bool _Parse();
58 | bool _Parse(LPTSTR& pstrText, ULONG iParent);
59 | XMLELEMENT* _ReserveElement();
60 | inline void _SkipWhitespace(LPTSTR& pstr) const;
61 | inline void _SkipWhitespace(LPCTSTR& pstr) const;
62 | inline void _SkipIdentifier(LPTSTR& pstr) const;
63 | inline void _SkipIdentifier(LPCTSTR& pstr) const;
64 | bool _ParseData(LPTSTR& pstrText, LPTSTR& pstrData, char cEnd);
65 | void _ParseMetaChar(LPTSTR& pstrText, LPTSTR& pstrDest);
66 | bool _ParseAttributes(LPTSTR& pstrText);
67 | bool _Failed(LPCTSTR pstrError, LPCTSTR pstrLocation = NULL);
68 | };
69 |
70 |
71 | class DUILIB_API CMarkupNode
72 | {
73 | friend class CMarkup;
74 | private:
75 | CMarkupNode();
76 | CMarkupNode(CMarkup* pOwner, int iPos);
77 |
78 | public:
79 | bool IsValid() const;
80 |
81 | CMarkupNode GetParent();
82 | CMarkupNode GetSibling();
83 | CMarkupNode GetChild();
84 | CMarkupNode GetChild(LPCTSTR pstrName);
85 |
86 | bool HasSiblings() const;
87 | bool HasChildren() const;
88 | LPCTSTR GetName() const;
89 | LPCTSTR GetValue() const;
90 |
91 | bool HasAttributes();
92 | bool HasAttribute(LPCTSTR pstrName);
93 | int GetAttributeCount();
94 | LPCTSTR GetAttributeName(int iIndex);
95 | LPCTSTR GetAttributeValue(int iIndex);
96 | LPCTSTR GetAttributeValue(LPCTSTR pstrName);
97 | bool GetAttributeValue(int iIndex, LPTSTR pstrValue, SIZE_T cchMax);
98 | bool GetAttributeValue(LPCTSTR pstrName, LPTSTR pstrValue, SIZE_T cchMax);
99 |
100 | private:
101 | void _MapAttributes();
102 |
103 | enum { MAX_XML_ATTRIBUTES = 64 };
104 |
105 | typedef struct
106 | {
107 | ULONG iName;
108 | ULONG iValue;
109 | } XMLATTRIBUTE;
110 |
111 | int m_iPos;
112 | int m_nAttributes;
113 | XMLATTRIBUTE m_aAttributes[MAX_XML_ATTRIBUTES];
114 | CMarkup* m_pOwner;
115 | };
116 |
117 | } // namespace DuiLib
118 |
119 | #endif // __UIMARKUP_H__
120 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIRender.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIRender.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Core/UIRender.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Core/UIRender.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Layout/UIChildLayout.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIChildLayout.h"
3 |
4 | namespace DuiLib
5 | {
6 | CChildLayoutUI::CChildLayoutUI()
7 | {
8 |
9 | }
10 |
11 | void CChildLayoutUI::Init()
12 | {
13 | if (!m_pstrXMLFile.IsEmpty())
14 | {
15 | CDialogBuilder builder;
16 | CContainerUI* pChildWindow = static_cast(builder.Create(m_pstrXMLFile.GetData(), (UINT)0, NULL, m_pManager));
17 | if (pChildWindow)
18 | {
19 | this->Add(pChildWindow);
20 | }
21 | else
22 | {
23 | this->RemoveAll();
24 | }
25 | }
26 | }
27 |
28 | void CChildLayoutUI::SetAttribute( LPCTSTR pstrName, LPCTSTR pstrValue )
29 | {
30 | if( _tcscmp(pstrName, _T("xmlfile")) == 0 )
31 | SetChildLayoutXML(pstrValue);
32 | else
33 | CContainerUI::SetAttribute(pstrName,pstrValue);
34 | }
35 |
36 | void CChildLayoutUI::SetChildLayoutXML( CDuiString pXML )
37 | {
38 | m_pstrXMLFile=pXML;
39 | }
40 |
41 | CDuiString CChildLayoutUI::GetChildLayoutXML()
42 | {
43 | return m_pstrXMLFile;
44 | }
45 |
46 | LPVOID CChildLayoutUI::GetInterface( LPCTSTR pstrName )
47 | {
48 | if( _tcscmp(pstrName, DUI_CTR_CHILDLAYOUT) == 0 ) return static_cast(this);
49 | return CControlUI::GetInterface(pstrName);
50 | }
51 |
52 | LPCTSTR CChildLayoutUI::GetClass() const
53 | {
54 | return DUI_CTR_CHILDLAYOUT;
55 | }
56 | } // namespace DuiLib
57 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Layout/UIChildLayout.h:
--------------------------------------------------------------------------------
1 | #ifndef __UICHILDLAYOUT_H__
2 | #define __UICHILDLAYOUT_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API CChildLayoutUI : public CContainerUI
9 | {
10 | public:
11 | CChildLayoutUI();
12 |
13 | void Init();
14 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
15 | void SetChildLayoutXML(CDuiString pXML);
16 | CDuiString GetChildLayoutXML();
17 | virtual LPVOID GetInterface(LPCTSTR pstrName);
18 | virtual LPCTSTR GetClass() const;
19 |
20 | private:
21 | CDuiString m_pstrXMLFile;
22 | };
23 | } // namespace DuiLib
24 | #endif // __UICHILDLAYOUT_H__
25 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Layout/UIHorizontalLayout.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIHORIZONTALLAYOUT_H__
2 | #define __UIHORIZONTALLAYOUT_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API CHorizontalLayoutUI : public CContainerUI
9 | {
10 | public:
11 | CHorizontalLayoutUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 | UINT GetControlFlags() const;
16 |
17 | void SetSepWidth(int iWidth);
18 | int GetSepWidth() const;
19 | void SetSepImmMode(bool bImmediately);
20 | bool IsSepImmMode() const;
21 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
22 | void DoEvent(TEventUI& event);
23 |
24 | void SetPos(RECT rc, bool bNeedInvalidate = true);
25 | void DoPostPaint(HDC hDC, const RECT& rcPaint);
26 |
27 | RECT GetThumbRect(bool bUseNew = false) const;
28 |
29 | protected:
30 | int m_iSepWidth;
31 | UINT m_uButtonState;
32 | POINT m_ptLastMouse;
33 | RECT m_rcNewPos;
34 | bool m_bImmMode;
35 | };
36 | }
37 | #endif // __UIHORIZONTALLAYOUT_H__
38 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Layout/UITabLayout.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UITabLayout.h"
3 |
4 | namespace DuiLib
5 | {
6 | CTabLayoutUI::CTabLayoutUI() : m_iCurSel(-1)
7 | {
8 | }
9 |
10 | LPCTSTR CTabLayoutUI::GetClass() const
11 | {
12 | return DUI_CTR_TABLAYOUT;
13 | }
14 |
15 | LPVOID CTabLayoutUI::GetInterface(LPCTSTR pstrName)
16 | {
17 | if( _tcscmp(pstrName, DUI_CTR_TABLAYOUT) == 0 ) return static_cast(this);
18 | return CContainerUI::GetInterface(pstrName);
19 | }
20 |
21 | bool CTabLayoutUI::Add(CControlUI* pControl)
22 | {
23 | bool ret = CContainerUI::Add(pControl);
24 | if( !ret ) return ret;
25 |
26 | if(m_iCurSel == -1 && pControl->IsVisible())
27 | {
28 | m_iCurSel = GetItemIndex(pControl);
29 | }
30 | else
31 | {
32 | pControl->SetVisible(false);
33 | }
34 |
35 | return ret;
36 | }
37 |
38 | bool CTabLayoutUI::AddAt(CControlUI* pControl, int iIndex)
39 | {
40 | bool ret = CContainerUI::AddAt(pControl, iIndex);
41 | if( !ret ) return ret;
42 |
43 | if(m_iCurSel == -1 && pControl->IsVisible())
44 | {
45 | m_iCurSel = GetItemIndex(pControl);
46 | }
47 | else if( m_iCurSel != -1 && iIndex <= m_iCurSel )
48 | {
49 | m_iCurSel += 1;
50 | }
51 | else
52 | {
53 | pControl->SetVisible(false);
54 | }
55 |
56 | return ret;
57 | }
58 |
59 | bool CTabLayoutUI::Remove(CControlUI* pControl, bool bDoNotDestroy)
60 | {
61 | if( pControl == NULL) return false;
62 |
63 | int index = GetItemIndex(pControl);
64 | bool ret = CContainerUI::Remove(pControl, bDoNotDestroy);
65 | if( !ret ) return false;
66 |
67 | if( m_iCurSel == index)
68 | {
69 | if( GetCount() > 0 )
70 | {
71 | m_iCurSel=0;
72 | GetItemAt(m_iCurSel)->SetVisible(true);
73 | }
74 | else
75 | m_iCurSel=-1;
76 | NeedParentUpdate();
77 | }
78 | else if( m_iCurSel > index )
79 | {
80 | m_iCurSel -= 1;
81 | }
82 |
83 | return ret;
84 | }
85 |
86 | void CTabLayoutUI::RemoveAll()
87 | {
88 | m_iCurSel = -1;
89 | CContainerUI::RemoveAll();
90 | NeedParentUpdate();
91 | }
92 |
93 | int CTabLayoutUI::GetCurSel() const
94 | {
95 | return m_iCurSel;
96 | }
97 |
98 | bool CTabLayoutUI::SelectItem(int iIndex, bool bTriggerEvent)
99 | {
100 | if( iIndex < 0 || iIndex >= m_items.GetSize() ) return false;
101 | if( iIndex == m_iCurSel ) return true;
102 |
103 | int iOldSel = m_iCurSel;
104 | m_iCurSel = iIndex;
105 | for( int it = 0; it < m_items.GetSize(); it++ )
106 | {
107 | if( it == iIndex ) {
108 | GetItemAt(it)->SetVisible(true);
109 | GetItemAt(it)->SetFocus();
110 | }
111 | else GetItemAt(it)->SetVisible(false);
112 | }
113 | NeedParentUpdate();
114 |
115 | if( m_pManager != NULL ) {
116 | m_pManager->SetNextTabControl();
117 | if (bTriggerEvent) m_pManager->SendNotify(this, DUI_MSGTYPE_TABSELECT, m_iCurSel, iOldSel);
118 | }
119 | return true;
120 | }
121 |
122 | bool CTabLayoutUI::SelectItem(CControlUI* pControl, bool bTriggerEvent)
123 | {
124 | int iIndex=GetItemIndex(pControl);
125 | if (iIndex==-1)
126 | return false;
127 | else
128 | return SelectItem(iIndex, bTriggerEvent);
129 | }
130 |
131 | void CTabLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
132 | {
133 | if( _tcscmp(pstrName, _T("selectedid")) == 0 ) SelectItem(_ttoi(pstrValue));
134 | return CContainerUI::SetAttribute(pstrName, pstrValue);
135 | }
136 |
137 | void CTabLayoutUI::SetPos(RECT rc, bool bNeedInvalidate)
138 | {
139 | CControlUI::SetPos(rc, bNeedInvalidate);
140 | rc = m_rcItem;
141 |
142 | // Adjust for inset
143 | rc.left += m_rcInset.left;
144 | rc.top += m_rcInset.top;
145 | rc.right -= m_rcInset.right;
146 | rc.bottom -= m_rcInset.bottom;
147 |
148 | for( int it = 0; it < m_items.GetSize(); it++ ) {
149 | CControlUI* pControl = static_cast(m_items[it]);
150 | if( !pControl->IsVisible() ) continue;
151 | if( pControl->IsFloat() ) {
152 | SetFloatPos(it);
153 | continue;
154 | }
155 |
156 | if( it != m_iCurSel ) continue;
157 |
158 | RECT rcPadding = pControl->GetPadding();
159 | rc.left += rcPadding.left;
160 | rc.top += rcPadding.top;
161 | rc.right -= rcPadding.right;
162 | rc.bottom -= rcPadding.bottom;
163 |
164 | SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top };
165 |
166 | SIZE sz = pControl->EstimateSize(szAvailable);
167 | if( sz.cx == 0 ) {
168 | sz.cx = MAX(0, szAvailable.cx);
169 | }
170 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth();
171 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth();
172 |
173 | if(sz.cy == 0) {
174 | sz.cy = MAX(0, szAvailable.cy);
175 | }
176 | if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight();
177 | if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight();
178 |
179 | RECT rcCtrl = { rc.left, rc.top, rc.left + sz.cx, rc.top + sz.cy};
180 | pControl->SetPos(rcCtrl, false);
181 | }
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Layout/UITabLayout.h:
--------------------------------------------------------------------------------
1 | #ifndef __UITABLAYOUT_H__
2 | #define __UITABLAYOUT_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API CTabLayoutUI : public CContainerUI
9 | {
10 | public:
11 | CTabLayoutUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 |
16 | bool Add(CControlUI* pControl);
17 | bool AddAt(CControlUI* pControl, int iIndex);
18 | bool Remove(CControlUI* pControl, bool bDoNotDestroy=false);
19 | void RemoveAll();
20 | int GetCurSel() const;
21 | bool SelectItem(int iIndex, bool bTriggerEvent=true);
22 | bool SelectItem(CControlUI* pControl, bool bTriggerEvent=true);
23 |
24 | void SetPos(RECT rc, bool bNeedInvalidate = true);
25 |
26 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
27 |
28 | protected:
29 | int m_iCurSel;
30 | };
31 | }
32 | #endif // __UITABLAYOUT_H__
33 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Layout/UITileLayout.h:
--------------------------------------------------------------------------------
1 | #ifndef __UITILELAYOUT_H__
2 | #define __UITILELAYOUT_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API CTileLayoutUI : public CContainerUI
9 | {
10 | public:
11 | CTileLayoutUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 |
16 | void SetPos(RECT rc, bool bNeedInvalidate = true);
17 |
18 | int GetFixedColumns() const;
19 | void SetFixedColumns(int iColums);
20 | int GetChildVPadding() const;
21 | void SetChildVPadding(int iPadding);
22 |
23 | SIZE GetItemSize() const;
24 | void SetItemSize(SIZE szSize);
25 | int GetColumns() const;
26 | int GetRows() const;
27 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
28 |
29 | protected:
30 | SIZE m_szItem;
31 | int m_nColumns;
32 | int m_nRows;
33 |
34 | int m_nColumnsFixed;
35 | int m_iChildVPadding;
36 | bool m_bIgnoreItemPadding;
37 | };
38 | }
39 | #endif // __UITILELAYOUT_H__
40 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Layout/UIVerticalLayout.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIVERTICALLAYOUT_H__
2 | #define __UIVERTICALLAYOUT_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class DUILIB_API CVerticalLayoutUI : public CContainerUI
9 | {
10 | public:
11 | CVerticalLayoutUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 | UINT GetControlFlags() const;
16 |
17 | void SetSepHeight(int iHeight);
18 | int GetSepHeight() const;
19 | void SetSepImmMode(bool bImmediately);
20 | bool IsSepImmMode() const;
21 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
22 | void DoEvent(TEventUI& event);
23 |
24 | void SetPos(RECT rc, bool bNeedInvalidate = true);
25 | void DoPostPaint(HDC hDC, const RECT& rcPaint);
26 |
27 | RECT GetThumbRect(bool bUseNew = false) const;
28 |
29 | protected:
30 | int m_iSepHeight;
31 | UINT m_uButtonState;
32 | POINT m_ptLastMouse;
33 | RECT m_rcNewPos;
34 | bool m_bImmMode;
35 | };
36 | }
37 | #endif // __UIVERTICALLAYOUT_H__
38 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/UIlib.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2011, duilib develop team(www.duilib.com).
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or
5 | // without modification, are permitted provided that the
6 | // following conditions are met.
7 | //
8 | // Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | //
11 | // Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following
13 | // disclaimer in the documentation and/or other materials
14 | // provided with the distribution.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
17 | // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | //
31 | // DirectUI - UI Library
32 | //
33 | // Written by Bjarke Viksoe (bjarke@viksoe.dk)
34 | // Copyright (c) 2006-2007 Bjarke Viksoe.
35 | //
36 | // This code may be used in compiled form in any way you desire. These
37 | // source files may be redistributed by any means PROVIDING it is
38 | // not sold for profit without the authors written consent, and
39 | // providing that this notice and the authors name is included.
40 | //
41 | // This file is provided "as is" with no expressed or implied warranty.
42 | // The author accepts no liability if it causes any damage to you or your
43 | // computer whatsoever. It's free, so don't hassle me about it.
44 | //
45 | // Beware of bugs.
46 | //
47 | //
48 |
49 |
50 | #include "stdafx.h"
51 | #include "UIlib.h"
52 |
53 |
54 | BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID /*lpReserved*/)
55 | {
56 | switch( dwReason ) {
57 | case DLL_PROCESS_ATTACH:
58 | case DLL_THREAD_ATTACH:
59 | case DLL_THREAD_DETACH:
60 | case DLL_PROCESS_DETACH:
61 | ::DisableThreadLibraryCalls((HMODULE)hModule);
62 | break;
63 | }
64 | return TRUE;
65 | }
66 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/UIlib.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2010-2011, duilib develop team(www.duilib.com).
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or
5 | // without modification, are permitted provided that the
6 | // following conditions are met.
7 | //
8 | // Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | //
11 | // Redistributions in binary form must reproduce the above
12 | // copyright notice, this list of conditions and the following
13 | // disclaimer in the documentation and/or other materials
14 | // provided with the distribution.
15 | //
16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
17 | // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | #ifdef UILIB_STATIC
31 | # define DUILIB_API
32 | #else
33 | # if defined(UILIB_EXPORTS)
34 | # if defined(_MSC_VER)
35 | # define DUILIB_API __declspec(dllexport)
36 | # else
37 | # define DUILIB_API
38 | # endif
39 | # else
40 | # if defined(_MSC_VER)
41 | # define DUILIB_API __declspec(dllimport)
42 | # else
43 | # define DUILIB_API
44 | # endif
45 | # endif
46 | #endif
47 |
48 | #define UILIB_COMDAT __declspec(selectany)
49 |
50 | #if defined _M_IX86
51 | # pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
52 | #elif defined _M_IA64
53 | # pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
54 | #elif defined _M_X64
55 | # pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
56 | #else
57 | # pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
58 | #endif
59 |
60 | #include
61 | #include
62 | #include
63 | #include
64 | #include
65 | #include
66 | #include
67 | #include
68 | #include
69 | #include
70 |
71 | #include "Utils/Utils.h"
72 | #include "Utils/UIDelegate.h"
73 | #include "Core/UIDefine.h"
74 | #include "Core/UIManager.h"
75 | #include "Core/UIBase.h"
76 | #include "Core/UIControl.h"
77 | #include "Core/UIContainer.h"
78 | #include "Core/UIMarkup.h"
79 | #include "Core/UIDlgBuilder.h"
80 | #include "Core/UIRender.h"
81 | #include "Utils/WinImplBase.h"
82 | #include "Utils/WndShadow.h"
83 |
84 | #include "Layout/UIVerticalLayout.h"
85 | #include "Layout/UIHorizontalLayout.h"
86 | #include "Layout/UITileLayout.h"
87 | #include "Layout/UITabLayout.h"
88 | #include "Layout/UIChildLayout.h"
89 |
90 | #include "Control/UIList.h"
91 | #include "Control/UICombo.h"
92 | #include "Control/UIScrollBar.h"
93 | #include "Control/UITreeView.h"
94 |
95 | #include "Control/UILabel.h"
96 | #include "Control/UIText.h"
97 | #include "Control/UIEdit.h"
98 |
99 | #include "Control/UIButton.h"
100 | #include "Control/UIOption.h"
101 | #include "Control/UICheckBox.h"
102 |
103 | #include "Control/UIProgress.h"
104 | #include "Control/UISlider.h"
105 |
106 | #include "Control/UIRichEdit.h"
107 | #include "Control/UIDateTime.h"
108 |
109 | #include "Control/UIActiveX.h"
110 | #include "Control/UIWebBrowser.h"
111 | #include "Control/UIGifAnim.h"
112 | //#include "Control/UIFlash.h"
113 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/FlashEventHandler.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Utils/FlashEventHandler.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/UIDelegate.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 |
3 | namespace DuiLib {
4 |
5 | CDelegateBase::CDelegateBase(void* pObject, void* pFn)
6 | {
7 | m_pObject = pObject;
8 | m_pFn = pFn;
9 | }
10 |
11 | CDelegateBase::CDelegateBase(const CDelegateBase& rhs)
12 | {
13 | m_pObject = rhs.m_pObject;
14 | m_pFn = rhs.m_pFn;
15 | }
16 |
17 | CDelegateBase::~CDelegateBase()
18 | {
19 |
20 | }
21 |
22 | bool CDelegateBase::Equals(const CDelegateBase& rhs) const
23 | {
24 | return m_pObject == rhs.m_pObject && m_pFn == rhs.m_pFn;
25 | }
26 |
27 | bool CDelegateBase::operator() (void* param)
28 | {
29 | return Invoke(param);
30 | }
31 |
32 | void* CDelegateBase::GetFn()
33 | {
34 | return m_pFn;
35 | }
36 |
37 | void* CDelegateBase::GetObject()
38 | {
39 | return m_pObject;
40 | }
41 |
42 | CEventSource::~CEventSource()
43 | {
44 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) {
45 | CDelegateBase* pObject = static_cast(m_aDelegates[i]);
46 | if( pObject) delete pObject;
47 | }
48 | }
49 |
50 | CEventSource::operator bool()
51 | {
52 | return m_aDelegates.GetSize() > 0;
53 | }
54 |
55 | void CEventSource::operator+= (const CDelegateBase& d)
56 | {
57 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) {
58 | CDelegateBase* pObject = static_cast(m_aDelegates[i]);
59 | if( pObject && pObject->Equals(d) ) return;
60 | }
61 |
62 | m_aDelegates.Add(d.Copy());
63 | }
64 |
65 | void CEventSource::operator+= (FnType pFn)
66 | {
67 | (*this) += MakeDelegate(pFn);
68 | }
69 |
70 | void CEventSource::operator-= (const CDelegateBase& d)
71 | {
72 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) {
73 | CDelegateBase* pObject = static_cast(m_aDelegates[i]);
74 | if( pObject && pObject->Equals(d) ) {
75 | delete pObject;
76 | m_aDelegates.Remove(i);
77 | return;
78 | }
79 | }
80 | }
81 | void CEventSource::operator-= (FnType pFn)
82 | {
83 | (*this) -= MakeDelegate(pFn);
84 | }
85 |
86 | bool CEventSource::operator() (void* param)
87 | {
88 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) {
89 | CDelegateBase* pObject = static_cast(m_aDelegates[i]);
90 | if( pObject && !(*pObject)(param) ) return false;
91 | }
92 | return true;
93 | }
94 |
95 | } // namespace DuiLib
96 |
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/UIDelegate.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIDELEGATE_H__
2 | #define __UIDELEGATE_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib {
7 |
8 | class DUILIB_API CDelegateBase
9 | {
10 | public:
11 | CDelegateBase(void* pObject, void* pFn);
12 | CDelegateBase(const CDelegateBase& rhs);
13 | virtual ~CDelegateBase();
14 | bool Equals(const CDelegateBase& rhs) const;
15 | bool operator() (void* param);
16 | virtual CDelegateBase* Copy() const = 0; // add const for gcc
17 |
18 | protected:
19 | void* GetFn();
20 | void* GetObject();
21 | virtual bool Invoke(void* param) = 0;
22 |
23 | private:
24 | void* m_pObject;
25 | void* m_pFn;
26 | };
27 |
28 | class CDelegateStatic: public CDelegateBase
29 | {
30 | typedef bool (*Fn)(void*);
31 | public:
32 | CDelegateStatic(Fn pFn) : CDelegateBase(NULL, pFn) { }
33 | CDelegateStatic(const CDelegateStatic& rhs) : CDelegateBase(rhs) { }
34 | virtual CDelegateBase* Copy() const { return new CDelegateStatic(*this); }
35 |
36 | protected:
37 | virtual bool Invoke(void* param)
38 | {
39 | Fn pFn = (Fn)GetFn();
40 | return (*pFn)(param);
41 | }
42 | };
43 |
44 | template
45 | class CDelegate : public CDelegateBase
46 | {
47 | typedef bool (T::* Fn)(void*);
48 | public:
49 | CDelegate(O* pObj, Fn pFn) : CDelegateBase(pObj, *(void**)&pFn) { }
50 | CDelegate(const CDelegate& rhs) : CDelegateBase(rhs) { }
51 | virtual CDelegateBase* Copy() const { return new CDelegate(*this); }
52 |
53 | protected:
54 | virtual bool Invoke(void* param)
55 | {
56 | O* pObject = (O*) GetObject();
57 | union
58 | {
59 | void* ptr;
60 | Fn fn;
61 | } func = { GetFn() };
62 | return (pObject->*func.fn)(param);
63 | }
64 |
65 | private:
66 | Fn m_pFn;
67 | };
68 |
69 | template
70 | CDelegate MakeDelegate(O* pObject, bool (T::* pFn)(void*))
71 | {
72 | return CDelegate(pObject, pFn);
73 | }
74 |
75 | inline CDelegateStatic MakeDelegate(bool (*pFn)(void*))
76 | {
77 | return CDelegateStatic(pFn);
78 | }
79 |
80 | class DUILIB_API CEventSource
81 | {
82 | typedef bool (*FnType)(void*);
83 | public:
84 | ~CEventSource();
85 | operator bool();
86 | void operator+= (const CDelegateBase& d); // add const for gcc
87 | void operator+= (FnType pFn);
88 | void operator-= (const CDelegateBase& d);
89 | void operator-= (FnType pFn);
90 | bool operator() (void* param);
91 |
92 | protected:
93 | CDuiPtrArray m_aDelegates;
94 | };
95 |
96 | } // namespace DuiLib
97 |
98 | #endif // __UIDELEGATE_H__
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/Utils.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Utils/Utils.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/Utils.h:
--------------------------------------------------------------------------------
1 | #ifndef __UTILS_H__
2 | #define __UTILS_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | /////////////////////////////////////////////////////////////////////////////////////
9 | //
10 |
11 | class DUILIB_API STRINGorID
12 | {
13 | public:
14 | STRINGorID(LPCTSTR lpString);
15 | STRINGorID(unsigned int nID);
16 |
17 | LPCTSTR m_lpstr;
18 | };
19 |
20 | /////////////////////////////////////////////////////////////////////////////////////
21 | //
22 | class CDuiString;
23 | class DUILIB_API CDuiPoint : public tagPOINT
24 | {
25 | public:
26 | CDuiPoint();
27 | CDuiPoint(const POINT& src);
28 | CDuiPoint(long x, long y);
29 | CDuiPoint(LPARAM lParam);
30 | CDuiPoint(LPCTSTR pstrValue);
31 | CDuiString ToString();
32 | };
33 |
34 | /////////////////////////////////////////////////////////////////////////////////////
35 | //
36 |
37 | class DUILIB_API CDuiSize : public tagSIZE
38 | {
39 | public:
40 | CDuiSize();
41 | CDuiSize(const SIZE& src);
42 | CDuiSize(const RECT rc);
43 | CDuiSize(long cx, long cy);
44 | CDuiSize(LPCTSTR pstrValue);
45 | CDuiString ToString();
46 | };
47 |
48 | /////////////////////////////////////////////////////////////////////////////////////
49 | //
50 |
51 | class DUILIB_API CDuiRect : public tagRECT
52 | {
53 | public:
54 | CDuiRect();
55 | CDuiRect(const RECT& src);
56 | CDuiRect(long iLeft, long iTop, long iRight, long iBottom);
57 | CDuiRect(LPCTSTR pstrValue);
58 | CDuiString ToString();
59 |
60 | int GetWidth() const;
61 | int GetHeight() const;
62 | void Empty();
63 | bool IsNull() const;
64 | void Join(const RECT& rc);
65 | void ResetOffset();
66 | void Normalize();
67 | void Offset(int cx, int cy);
68 | void Inflate(int cx, int cy);
69 | void Deflate(int cx, int cy);
70 | void Union(CDuiRect& rc);
71 | };
72 |
73 | /////////////////////////////////////////////////////////////////////////////////////
74 | //
75 |
76 | class DUILIB_API CDuiString
77 | {
78 | public:
79 | enum { MAX_LOCAL_STRING_LEN = 63 };
80 |
81 | CDuiString();
82 | CDuiString(const TCHAR ch);
83 | CDuiString(const CDuiString& src);
84 | CDuiString(LPCTSTR lpsz, int nLen = -1);
85 | ~CDuiString();
86 | CDuiString ToString();
87 |
88 | void Empty();
89 | int GetLength() const;
90 | bool IsEmpty() const;
91 | TCHAR GetAt(int nIndex) const;
92 | void Append(LPCTSTR pstr);
93 | void Assign(LPCTSTR pstr, int nLength = -1);
94 | LPCTSTR GetData() const;
95 |
96 | void SetAt(int nIndex, TCHAR ch);
97 | operator LPCTSTR() const;
98 |
99 | TCHAR operator[] (int nIndex) const;
100 | const CDuiString& operator=(const CDuiString& src);
101 | const CDuiString& operator=(const TCHAR ch);
102 | const CDuiString& operator=(LPCTSTR pstr);
103 | #ifdef _UNICODE
104 | const CDuiString& /*CDuiString::*/operator=(LPCSTR lpStr);
105 | const CDuiString& /*CDuiString::*/operator+=(LPCSTR lpStr);
106 | #else
107 | const CDuiString& CDuiString::operator=(LPCWSTR lpwStr);
108 | const CDuiString& CDuiString::operator+=(LPCWSTR lpwStr);
109 | #endif
110 | CDuiString operator+(const CDuiString& src) const;
111 | CDuiString operator+(LPCTSTR pstr) const;
112 | const CDuiString& operator+=(const CDuiString& src);
113 | const CDuiString& operator+=(LPCTSTR pstr);
114 | const CDuiString& operator+=(const TCHAR ch);
115 |
116 | bool operator == (LPCTSTR str) const;
117 | bool operator != (LPCTSTR str) const;
118 | bool operator <= (LPCTSTR str) const;
119 | bool operator < (LPCTSTR str) const;
120 | bool operator >= (LPCTSTR str) const;
121 | bool operator > (LPCTSTR str) const;
122 |
123 | int Compare(LPCTSTR pstr) const;
124 | int CompareNoCase(LPCTSTR pstr) const;
125 |
126 | void MakeUpper();
127 | void MakeLower();
128 |
129 | CDuiString Left(int nLength) const;
130 | CDuiString Mid(int iPos, int nLength = -1) const;
131 | CDuiString Right(int nLength) const;
132 |
133 | int Find(TCHAR ch, int iPos = 0) const;
134 | int Find(LPCTSTR pstr, int iPos = 0) const;
135 | int ReverseFind(TCHAR ch) const;
136 | int Replace(LPCTSTR pstrFrom, LPCTSTR pstrTo);
137 |
138 | int __cdecl Format(LPCTSTR pstrFormat, ...);
139 | int __cdecl SmallFormat(LPCTSTR pstrFormat, ...);
140 |
141 | protected:
142 | LPTSTR m_pstr;
143 | TCHAR m_szBuffer[MAX_LOCAL_STRING_LEN + 1];
144 | };
145 |
146 | /////////////////////////////////////////////////////////////////////////////////////
147 | //
148 |
149 | class DUILIB_API CDuiPtrArray
150 | {
151 | public:
152 | CDuiPtrArray(int iPreallocSize = 0);
153 | CDuiPtrArray(const CDuiPtrArray& src);
154 | ~CDuiPtrArray();
155 |
156 | void Empty();
157 | void Resize(int iSize);
158 | bool IsEmpty() const;
159 | int Find(LPVOID iIndex) const;
160 | bool Add(LPVOID pData);
161 | bool SetAt(int iIndex, LPVOID pData);
162 | bool InsertAt(int iIndex, LPVOID pData);
163 | bool Remove(int iIndex, int iCount = 1);
164 | int GetSize() const;
165 | LPVOID* GetData();
166 |
167 | LPVOID GetAt(int iIndex) const;
168 | LPVOID operator[] (int nIndex) const;
169 |
170 | protected:
171 | LPVOID* m_ppVoid;
172 | int m_nCount;
173 | int m_nAllocated;
174 | };
175 |
176 |
177 | /////////////////////////////////////////////////////////////////////////////////////
178 | //
179 |
180 | class DUILIB_API CDuiValArray
181 | {
182 | public:
183 | CDuiValArray(int iElementSize, int iPreallocSize = 0);
184 | ~CDuiValArray();
185 |
186 | void Empty();
187 | bool IsEmpty() const;
188 | bool Add(LPCVOID pData);
189 | bool Remove(int iIndex, int iCount = 1);
190 | int GetSize() const;
191 | LPVOID GetData();
192 |
193 | LPVOID GetAt(int iIndex) const;
194 | LPVOID operator[] (int nIndex) const;
195 |
196 | protected:
197 | LPBYTE m_pVoid;
198 | int m_iElementSize;
199 | int m_nCount;
200 | int m_nAllocated;
201 | };
202 |
203 | /////////////////////////////////////////////////////////////////////////////////////
204 | //
205 |
206 | struct TITEM;
207 | class DUILIB_API CDuiStringPtrMap
208 | {
209 | public:
210 | CDuiStringPtrMap(int nSize = 83);
211 | ~CDuiStringPtrMap();
212 |
213 | void Resize(int nSize = 83);
214 | LPVOID Find(LPCTSTR key, bool optimize = true) const;
215 | bool Insert(LPCTSTR key, LPVOID pData);
216 | LPVOID Set(LPCTSTR key, LPVOID pData);
217 | bool Remove(LPCTSTR key);
218 | void RemoveAll();
219 | int GetSize() const;
220 | LPCTSTR GetAt(int iIndex) const;
221 | LPCTSTR operator[] (int nIndex) const;
222 |
223 | protected:
224 | TITEM** m_aT;
225 | int m_nBuckets;
226 | int m_nCount;
227 | };
228 |
229 | /////////////////////////////////////////////////////////////////////////////////////
230 | //
231 |
232 | class DUILIB_API CWaitCursor
233 | {
234 | public:
235 | CWaitCursor();
236 | ~CWaitCursor();
237 |
238 | protected:
239 | HCURSOR m_hOrigCursor;
240 | };
241 |
242 | /////////////////////////////////////////////////////////////////////////////////////
243 | //
244 |
245 | class CVariant : public VARIANT
246 | {
247 | public:
248 | CVariant()
249 | {
250 | VariantInit(this);
251 | }
252 | CVariant(int i)
253 | {
254 | VariantInit(this);
255 | this->vt = VT_I4;
256 | this->intVal = i;
257 | }
258 | CVariant(float f)
259 | {
260 | VariantInit(this);
261 | this->vt = VT_R4;
262 | this->fltVal = f;
263 | }
264 | CVariant(LPOLESTR s)
265 | {
266 | VariantInit(this);
267 | this->vt = VT_BSTR;
268 | this->bstrVal = s;
269 | }
270 | CVariant(IDispatch *disp)
271 | {
272 | VariantInit(this);
273 | this->vt = VT_DISPATCH;
274 | this->pdispVal = disp;
275 | }
276 |
277 | ~CVariant()
278 | {
279 | VariantClear(this);
280 | }
281 | };
282 |
283 | }// namespace DuiLib
284 |
285 | #endif // __UTILS_H__
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/WebBrowserEventHandler.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Utils/WebBrowserEventHandler.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/WinImplBase.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Utils/WinImplBase.cpp
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/WinImplBase.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Utils/WinImplBase.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/WndShadow.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/DuiLib/Utils/WndShadow.h
--------------------------------------------------------------------------------
/ChatServer/DuiLib/Utils/downloadmgr.h:
--------------------------------------------------------------------------------
1 |
2 | #pragma warning( disable: 4049 ) /* more than 64k source lines */
3 |
4 | /* this ALWAYS GENERATED file contains the definitions for the interfaces */
5 |
6 |
7 | /* File created by MIDL compiler version 5.03.0279 */
8 | /* at Mon Jul 23 17:42:46 2001
9 | */
10 | /* Compiler settings for downloadmgr.idl:
11 | Oicf (OptLev=i2), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext
12 | error checks: allocation ref bounds_check enum stub_data
13 | VC __declspec() decoration level:
14 | __declspec(uuid()), __declspec(selectany), __declspec(novtable)
15 | DECLSPEC_UUID(), MIDL_INTERFACE()
16 | */
17 | //@@MIDL_FILE_HEADING( )
18 |
19 |
20 | /* verify that the version is high enough to compile this file*/
21 | #ifndef __REQUIRED_RPCNDR_H_VERSION__
22 | #define __REQUIRED_RPCNDR_H_VERSION__ 440
23 | #endif
24 |
25 | #include "rpc.h"
26 | #include "rpcndr.h"
27 |
28 | #ifndef __RPCNDR_H_VERSION__
29 | #error this stub requires an updated version of
30 | #endif // __RPCNDR_H_VERSION__
31 |
32 | #ifndef COM_NO_WINDOWS_H
33 | #include "windows.h"
34 | #include "ole2.h"
35 | #endif /*COM_NO_WINDOWS_H*/
36 |
37 | #ifndef __downloadmgr_h__
38 | #define __downloadmgr_h__
39 |
40 | /* Forward Declarations */
41 |
42 | #ifndef __IDownloadManager_FWD_DEFINED__
43 | #define __IDownloadManager_FWD_DEFINED__
44 | typedef interface IDownloadManager IDownloadManager;
45 | #endif /* __IDownloadManager_FWD_DEFINED__ */
46 |
47 |
48 | /* header files for imported files */
49 | #include "unknwn.h"
50 | #include "ocidl.h"
51 |
52 | #ifdef __cplusplus
53 | extern "C"{
54 | #endif
55 |
56 | void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
57 | void __RPC_USER MIDL_user_free( void __RPC_FAR * );
58 |
59 | /* interface __MIDL_itf_downloadmgr_0000 */
60 | /* [local] */
61 |
62 | //=--------------------------------------------------------------------------=
63 | // downloadmgr.h
64 | //=--------------------------------------------------------------------------=
65 | // (C) Copyright 2000 Microsoft Corporation. All Rights Reserved.
66 | //
67 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
68 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
69 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
70 | // PARTICULAR PURPOSE.
71 | //=--------------------------------------------------------------------------=
72 |
73 | #pragma comment(lib,"uuid.lib")
74 |
75 | //---------------------------------------------------------------------------=
76 | // Internet Explorer Download Manager Interfaces
77 |
78 | // --------------------------------------------------------------------------------
79 | // GUIDS
80 | // --------------------------------------------------------------------------------
81 | // {988934A4-064B-11D3-BB80-00104B35E7F9}
82 | DEFINE_GUID(IID_IDownloadManager, 0x988934a4, 0x064b, 0x11d3, 0xbb, 0x80, 0x0, 0x10, 0x4b, 0x35, 0xe7, 0xf9);
83 | #define SID_SDownloadManager IID_IDownloadManager
84 |
85 |
86 |
87 | extern RPC_IF_HANDLE __MIDL_itf_downloadmgr_0000_v0_0_c_ifspec;
88 | extern RPC_IF_HANDLE __MIDL_itf_downloadmgr_0000_v0_0_s_ifspec;
89 |
90 | #ifndef __IDownloadManager_INTERFACE_DEFINED__
91 | #define __IDownloadManager_INTERFACE_DEFINED__
92 |
93 | /* interface IDownloadManager */
94 | /* [local][unique][uuid][object][helpstring] */
95 |
96 |
97 | EXTERN_C const IID IID_IDownloadManager;
98 |
99 | #if defined(__cplusplus) && !defined(CINTERFACE)
100 |
101 | MIDL_INTERFACE("988934A4-064B-11D3-BB80-00104B35E7F9")
102 | IDownloadManager : public IUnknown
103 | {
104 | public:
105 | virtual HRESULT STDMETHODCALLTYPE Download(
106 | /* [in] */ IMoniker __RPC_FAR *pmk,
107 | /* [in] */ IBindCtx __RPC_FAR *pbc,
108 | /* [in] */ DWORD dwBindVerb,
109 | /* [in] */ LONG grfBINDF,
110 | /* [in] */ BINDINFO __RPC_FAR *pBindInfo,
111 | /* [in] */ LPCOLESTR pszHeaders,
112 | /* [in] */ LPCOLESTR pszRedir,
113 | /* [in] */ UINT uiCP) = 0;
114 |
115 | };
116 |
117 | #else /* C style interface */
118 |
119 | typedef struct IDownloadManagerVtbl
120 | {
121 | BEGIN_INTERFACE
122 |
123 | HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )(
124 | IDownloadManager __RPC_FAR * This,
125 | /* [in] */ REFIID riid,
126 | /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
127 |
128 | ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )(
129 | IDownloadManager __RPC_FAR * This);
130 |
131 | ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )(
132 | IDownloadManager __RPC_FAR * This);
133 |
134 | HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Download )(
135 | IDownloadManager __RPC_FAR * This,
136 | /* [in] */ IMoniker __RPC_FAR *pmk,
137 | /* [in] */ IBindCtx __RPC_FAR *pbc,
138 | /* [in] */ DWORD dwBindVerb,
139 | /* [in] */ LONG grfBINDF,
140 | /* [in] */ BINDINFO __RPC_FAR *pBindInfo,
141 | /* [in] */ LPCOLESTR pszHeaders,
142 | /* [in] */ LPCOLESTR pszRedir,
143 | /* [in] */ UINT uiCP);
144 |
145 | END_INTERFACE
146 | } IDownloadManagerVtbl;
147 |
148 | interface IDownloadManager
149 | {
150 | CONST_VTBL struct IDownloadManagerVtbl __RPC_FAR *lpVtbl;
151 | };
152 |
153 |
154 |
155 | #ifdef COBJMACROS
156 |
157 |
158 | #define IDownloadManager_QueryInterface(This,riid,ppvObject) \
159 | (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
160 |
161 | #define IDownloadManager_AddRef(This) \
162 | (This)->lpVtbl -> AddRef(This)
163 |
164 | #define IDownloadManager_Release(This) \
165 | (This)->lpVtbl -> Release(This)
166 |
167 |
168 | #define IDownloadManager_Download(This,pmk,pbc,dwBindVerb,grfBINDF,pBindInfo,pszHeaders,pszRedir,uiCP) \
169 | (This)->lpVtbl -> Download(This,pmk,pbc,dwBindVerb,grfBINDF,pBindInfo,pszHeaders,pszRedir,uiCP)
170 |
171 | #endif /* COBJMACROS */
172 |
173 |
174 | #endif /* C style interface */
175 |
176 |
177 |
178 | HRESULT STDMETHODCALLTYPE IDownloadManager_Download_Proxy(
179 | IDownloadManager __RPC_FAR * This,
180 | /* [in] */ IMoniker __RPC_FAR *pmk,
181 | /* [in] */ IBindCtx __RPC_FAR *pbc,
182 | /* [in] */ DWORD dwBindVerb,
183 | /* [in] */ LONG grfBINDF,
184 | /* [in] */ BINDINFO __RPC_FAR *pBindInfo,
185 | /* [in] */ LPCOLESTR pszHeaders,
186 | /* [in] */ LPCOLESTR pszRedir,
187 | /* [in] */ UINT uiCP);
188 |
189 |
190 | void __RPC_STUB IDownloadManager_Download_Stub(
191 | IRpcStubBuffer *This,
192 | IRpcChannelBuffer *_pRpcChannelBuffer,
193 | PRPC_MESSAGE _pRpcMessage,
194 | DWORD *_pdwStubPhase);
195 |
196 |
197 |
198 | #endif /* __IDownloadManager_INTERFACE_DEFINED__ */
199 |
200 |
201 | /* Additional Prototypes for ALL interfaces */
202 |
203 | /* end of Additional Prototypes */
204 |
205 | #ifdef __cplusplus
206 | }
207 | #endif
208 |
209 | #endif
210 |
211 |
212 |
--------------------------------------------------------------------------------
/ChatServer/IOCPBase.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/IOCPBase.cpp
--------------------------------------------------------------------------------
/ChatServer/IOCPBase.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/IOCPBase.h
--------------------------------------------------------------------------------
/ChatServer/Mian.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/Mian.cpp
--------------------------------------------------------------------------------
/ChatServer/NetwordModule.cpp:
--------------------------------------------------------------------------------
1 | #include "NetwordModule.h"
2 | #include "Server.h"
3 | #include "Task.h"
4 |
5 | NetwordModule::NetwordModule(Server *server)
6 | {
7 | this->server = server;
8 | }
9 |
10 |
11 | NetwordModule::~NetwordModule()
12 | {
13 | }
14 |
15 | void NetwordModule::OnConnectionEstablished(ULONG connectID)
16 | {
17 | }
18 |
19 | void NetwordModule::OnConnectionClosed(ULONG connectID)
20 | {
21 | server->threadPool->QueueTaskItem(Task::SetOffLineStatus, (WPARAM)connectID, (LPARAM)server);
22 | }
23 |
24 | void NetwordModule::OnConnectionError(ULONG connectID, int error)
25 | {
26 | server->threadPool->QueueTaskItem(Task::SetOffLineStatus, (WPARAM)connectID, (LPARAM)server);
27 | }
28 |
29 | void NetwordModule::OnRecvCompleted(RecvSendData *data)
30 | {
31 | server->threadPool->QueueTaskItem(Task::ProcessRecvData, (WPARAM)data, (LPARAM)server);
32 | }
33 |
34 | void NetwordModule::OnSendCompleted(ULONG connectID, ULONG dataID)
35 | {
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/ChatServer/NetwordModule.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/NetwordModule.h
--------------------------------------------------------------------------------
/ChatServer/Protocol.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/Protocol.h
--------------------------------------------------------------------------------
/ChatServer/SQLite.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/SQLite.cpp
--------------------------------------------------------------------------------
/ChatServer/SQLite.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/SQLite.h
--------------------------------------------------------------------------------
/ChatServer/Server.cpp:
--------------------------------------------------------------------------------
1 | #include "Server.h"
2 |
3 |
4 |
5 | Server::Server()
6 | {
7 |
8 | }
9 |
10 |
11 | Server::~Server()
12 | {
13 |
14 | }
15 |
16 | BOOL Server::Start(CDuiString DBpath, UINT port)
17 | {
18 | return 0;
19 | }
20 |
21 | BOOL Server::Init()
22 | {
23 | network = new NetwordModule(this);
24 | if (network == NULL || network->Start() == false)
25 | return false;
26 | //network->SetSever(this);
27 | db = new DBModule(this);
28 | if (db == NULL || db->Init() == false)
29 | return false;
30 | threadPool = new ThreadPool;
31 |
32 | return true;
33 | }
34 |
35 | void Server::DeInit()
36 | {
37 |
38 | }
39 |
40 | BOOL Server::Stop()
41 | {
42 | return 0;
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/ChatServer/Server.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "stdafx.h"
3 | #include "NetwordModule.h"
4 | #include "DBModule.h"
5 | #include "ThreadPool.h"
6 | #include
7 |
8 | using std::queue;
9 |
10 | class Server
11 | {
12 | public:
13 | Server();
14 | ~Server();
15 |
16 | BOOL Start(CDuiString DBpath, UINT port = 10086);
17 | BOOL Init();
18 | void DeInit();
19 | BOOL Stop();
20 |
21 | ThreadPool *threadPool;
22 | DBModule *db;
23 | NetwordModule *network;
24 |
25 | };
26 |
27 |
--------------------------------------------------------------------------------
/ChatServer/ServerMainWnd.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/ServerMainWnd.cpp
--------------------------------------------------------------------------------
/ChatServer/ServerMainWnd.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "stdafx.h"
3 | #include "Server.h"
4 |
5 | class ServerMainWnd : public WindowImplBase
6 | {
7 | public:
8 | ServerMainWnd();
9 | ~ServerMainWnd();
10 |
11 | virtual UILIB_RESOURCETYPE GetResourceType() const;
12 | virtual CDuiString GetSkinFolder();
13 | virtual CDuiString GetSkinFile();
14 | virtual CDuiString GetZIPFileName() const;
15 | virtual LPCTSTR GetWindowClassName() const;
16 |
17 | virtual void InitWindow();
18 | virtual void Notify(TNotifyUI &msg);
19 | virtual void OnFinalMessage(HWND hWnd);
20 |
21 | void ShowTip(CDuiString tips = L"", BOOL bBarning = FALSE);
22 | Server server;
23 |
24 |
25 | CLabelUI * lbTips;
26 | };
27 |
28 |
--------------------------------------------------------------------------------
/ChatServer/Task.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/Task.cpp
--------------------------------------------------------------------------------
/ChatServer/Task.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "stdafx.h"
3 | #include "Common.h"
4 |
5 | class Task
6 | {
7 | public:
8 | static int ProcessRecvData(WPARAM wParam, LPARAM lParam);
9 | static int GetFriends(WPARAM wParam, LPARAM lParam);
10 | static int SetOffLineStatus(WPARAM wParam, LPARAM lParam);
11 |
12 | static void Callback(int result);
13 |
14 |
15 | };
16 |
17 |
--------------------------------------------------------------------------------
/ChatServer/ThreadPool.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/ThreadPool.cpp
--------------------------------------------------------------------------------
/ChatServer/ThreadPool.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/ThreadPool.h
--------------------------------------------------------------------------------
/ChatServer/dll/DuiLib_u.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/dll/DuiLib_u.dll
--------------------------------------------------------------------------------
/ChatServer/dll/DuiLib_ud.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/dll/DuiLib_ud.dll
--------------------------------------------------------------------------------
/ChatServer/dll/Sqlite3.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/dll/Sqlite3.dll
--------------------------------------------------------------------------------
/ChatServer/dll/Sqlite3.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/dll/Sqlite3.lib
--------------------------------------------------------------------------------
/ChatServer/lib/DuiLib_u.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/lib/DuiLib_u.lib
--------------------------------------------------------------------------------
/ChatServer/lib/DuiLib_ud.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/lib/DuiLib_ud.lib
--------------------------------------------------------------------------------
/ChatServer/lib/Sqlite3.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TTGuoying/duilib_ChatServer/a7fdbb449b755c7d09982cb349ca34d9740d7a1c/ChatServer/lib/Sqlite3.lib
--------------------------------------------------------------------------------
/ChatServer/rapidjson/cursorstreamwrapper.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_CURSORSTREAMWRAPPER_H_
16 | #define RAPIDJSON_CURSORSTREAMWRAPPER_H_
17 |
18 | #include "stream.h"
19 |
20 | #if defined(__GNUC__)
21 | RAPIDJSON_DIAG_PUSH
22 | RAPIDJSON_DIAG_OFF(effc++)
23 | #endif
24 |
25 | #if defined(_MSC_VER) && _MSC_VER <= 1800
26 | RAPIDJSON_DIAG_PUSH
27 | RAPIDJSON_DIAG_OFF(4702) // unreachable code
28 | RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
29 | #endif
30 |
31 | RAPIDJSON_NAMESPACE_BEGIN
32 |
33 |
34 | //! Cursor stream wrapper for counting line and column number if error exists.
35 | /*!
36 | \tparam InputStream Any stream that implements Stream Concept
37 | */
38 | template >
39 | class CursorStreamWrapper : public GenericStreamWrapper {
40 | public:
41 | typedef typename Encoding::Ch Ch;
42 |
43 | CursorStreamWrapper(InputStream& is):
44 | GenericStreamWrapper(is), line_(1), col_(0) {}
45 |
46 | // counting line and column number
47 | Ch Take() {
48 | Ch ch = this->is_.Take();
49 | if(ch == '\n') {
50 | line_ ++;
51 | col_ = 0;
52 | } else {
53 | col_ ++;
54 | }
55 | return ch;
56 | }
57 |
58 | //! Get the error line number, if error exists.
59 | size_t GetLine() const { return line_; }
60 | //! Get the error column number, if error exists.
61 | size_t GetColumn() const { return col_; }
62 |
63 | private:
64 | size_t line_; //!< Current Line
65 | size_t col_; //!< Current Column
66 | };
67 |
68 | #if defined(_MSC_VER) && _MSC_VER <= 1800
69 | RAPIDJSON_DIAG_POP
70 | #endif
71 |
72 | #if defined(__GNUC__)
73 | RAPIDJSON_DIAG_POP
74 | #endif
75 |
76 | RAPIDJSON_NAMESPACE_END
77 |
78 | #endif // RAPIDJSON_CURSORSTREAMWRAPPER_H_
79 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/error/en.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_ERROR_EN_H_
16 | #define RAPIDJSON_ERROR_EN_H_
17 |
18 | #include "error.h"
19 |
20 | #ifdef __clang__
21 | RAPIDJSON_DIAG_PUSH
22 | RAPIDJSON_DIAG_OFF(switch-enum)
23 | RAPIDJSON_DIAG_OFF(covered-switch-default)
24 | #endif
25 |
26 | RAPIDJSON_NAMESPACE_BEGIN
27 |
28 | //! Maps error code of parsing into error message.
29 | /*!
30 | \ingroup RAPIDJSON_ERRORS
31 | \param parseErrorCode Error code obtained in parsing.
32 | \return the error message.
33 | \note User can make a copy of this function for localization.
34 | Using switch-case is safer for future modification of error codes.
35 | */
36 | inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErrorCode) {
37 | switch (parseErrorCode) {
38 | case kParseErrorNone: return RAPIDJSON_ERROR_STRING("No error.");
39 |
40 | case kParseErrorDocumentEmpty: return RAPIDJSON_ERROR_STRING("The document is empty.");
41 | case kParseErrorDocumentRootNotSingular: return RAPIDJSON_ERROR_STRING("The document root must not be followed by other values.");
42 |
43 | case kParseErrorValueInvalid: return RAPIDJSON_ERROR_STRING("Invalid value.");
44 |
45 | case kParseErrorObjectMissName: return RAPIDJSON_ERROR_STRING("Missing a name for object member.");
46 | case kParseErrorObjectMissColon: return RAPIDJSON_ERROR_STRING("Missing a colon after a name of object member.");
47 | case kParseErrorObjectMissCommaOrCurlyBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or '}' after an object member.");
48 |
49 | case kParseErrorArrayMissCommaOrSquareBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or ']' after an array element.");
50 |
51 | case kParseErrorStringUnicodeEscapeInvalidHex: return RAPIDJSON_ERROR_STRING("Incorrect hex digit after \\u escape in string.");
52 | case kParseErrorStringUnicodeSurrogateInvalid: return RAPIDJSON_ERROR_STRING("The surrogate pair in string is invalid.");
53 | case kParseErrorStringEscapeInvalid: return RAPIDJSON_ERROR_STRING("Invalid escape character in string.");
54 | case kParseErrorStringMissQuotationMark: return RAPIDJSON_ERROR_STRING("Missing a closing quotation mark in string.");
55 | case kParseErrorStringInvalidEncoding: return RAPIDJSON_ERROR_STRING("Invalid encoding in string.");
56 |
57 | case kParseErrorNumberTooBig: return RAPIDJSON_ERROR_STRING("Number too big to be stored in double.");
58 | case kParseErrorNumberMissFraction: return RAPIDJSON_ERROR_STRING("Miss fraction part in number.");
59 | case kParseErrorNumberMissExponent: return RAPIDJSON_ERROR_STRING("Miss exponent in number.");
60 |
61 | case kParseErrorTermination: return RAPIDJSON_ERROR_STRING("Terminate parsing due to Handler error.");
62 | case kParseErrorUnspecificSyntaxError: return RAPIDJSON_ERROR_STRING("Unspecific syntax error.");
63 |
64 | default: return RAPIDJSON_ERROR_STRING("Unknown error.");
65 | }
66 | }
67 |
68 | RAPIDJSON_NAMESPACE_END
69 |
70 | #ifdef __clang__
71 | RAPIDJSON_DIAG_POP
72 | #endif
73 |
74 | #endif // RAPIDJSON_ERROR_EN_H_
75 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/error/error.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_ERROR_ERROR_H_
16 | #define RAPIDJSON_ERROR_ERROR_H_
17 |
18 | #include "../rapidjson.h"
19 |
20 | #ifdef __clang__
21 | RAPIDJSON_DIAG_PUSH
22 | RAPIDJSON_DIAG_OFF(padded)
23 | #endif
24 |
25 | /*! \file error.h */
26 |
27 | /*! \defgroup RAPIDJSON_ERRORS RapidJSON error handling */
28 |
29 | ///////////////////////////////////////////////////////////////////////////////
30 | // RAPIDJSON_ERROR_CHARTYPE
31 |
32 | //! Character type of error messages.
33 | /*! \ingroup RAPIDJSON_ERRORS
34 | The default character type is \c char.
35 | On Windows, user can define this macro as \c TCHAR for supporting both
36 | unicode/non-unicode settings.
37 | */
38 | #ifndef RAPIDJSON_ERROR_CHARTYPE
39 | #define RAPIDJSON_ERROR_CHARTYPE char
40 | #endif
41 |
42 | ///////////////////////////////////////////////////////////////////////////////
43 | // RAPIDJSON_ERROR_STRING
44 |
45 | //! Macro for converting string literial to \ref RAPIDJSON_ERROR_CHARTYPE[].
46 | /*! \ingroup RAPIDJSON_ERRORS
47 | By default this conversion macro does nothing.
48 | On Windows, user can define this macro as \c _T(x) for supporting both
49 | unicode/non-unicode settings.
50 | */
51 | #ifndef RAPIDJSON_ERROR_STRING
52 | #define RAPIDJSON_ERROR_STRING(x) x
53 | #endif
54 |
55 | RAPIDJSON_NAMESPACE_BEGIN
56 |
57 | ///////////////////////////////////////////////////////////////////////////////
58 | // ParseErrorCode
59 |
60 | //! Error code of parsing.
61 | /*! \ingroup RAPIDJSON_ERRORS
62 | \see GenericReader::Parse, GenericReader::GetParseErrorCode
63 | */
64 | enum ParseErrorCode {
65 | kParseErrorNone = 0, //!< No error.
66 |
67 | kParseErrorDocumentEmpty, //!< The document is empty.
68 | kParseErrorDocumentRootNotSingular, //!< The document root must not follow by other values.
69 |
70 | kParseErrorValueInvalid, //!< Invalid value.
71 |
72 | kParseErrorObjectMissName, //!< Missing a name for object member.
73 | kParseErrorObjectMissColon, //!< Missing a colon after a name of object member.
74 | kParseErrorObjectMissCommaOrCurlyBracket, //!< Missing a comma or '}' after an object member.
75 |
76 | kParseErrorArrayMissCommaOrSquareBracket, //!< Missing a comma or ']' after an array element.
77 |
78 | kParseErrorStringUnicodeEscapeInvalidHex, //!< Incorrect hex digit after \\u escape in string.
79 | kParseErrorStringUnicodeSurrogateInvalid, //!< The surrogate pair in string is invalid.
80 | kParseErrorStringEscapeInvalid, //!< Invalid escape character in string.
81 | kParseErrorStringMissQuotationMark, //!< Missing a closing quotation mark in string.
82 | kParseErrorStringInvalidEncoding, //!< Invalid encoding in string.
83 |
84 | kParseErrorNumberTooBig, //!< Number too big to be stored in double.
85 | kParseErrorNumberMissFraction, //!< Miss fraction part in number.
86 | kParseErrorNumberMissExponent, //!< Miss exponent in number.
87 |
88 | kParseErrorTermination, //!< Parsing was terminated.
89 | kParseErrorUnspecificSyntaxError //!< Unspecific syntax error.
90 | };
91 |
92 | //! Result of parsing (wraps ParseErrorCode)
93 | /*!
94 | \ingroup RAPIDJSON_ERRORS
95 | \code
96 | Document doc;
97 | ParseResult ok = doc.Parse("[42]");
98 | if (!ok) {
99 | fprintf(stderr, "JSON parse error: %s (%u)",
100 | GetParseError_En(ok.Code()), ok.Offset());
101 | exit(EXIT_FAILURE);
102 | }
103 | \endcode
104 | \see GenericReader::Parse, GenericDocument::Parse
105 | */
106 | struct ParseResult {
107 | //!! Unspecified boolean type
108 | typedef bool (ParseResult::*BooleanType)() const;
109 | public:
110 | //! Default constructor, no error.
111 | ParseResult() : code_(kParseErrorNone), offset_(0) {}
112 | //! Constructor to set an error.
113 | ParseResult(ParseErrorCode code, size_t offset) : code_(code), offset_(offset) {}
114 |
115 | //! Get the error code.
116 | ParseErrorCode Code() const { return code_; }
117 | //! Get the error offset, if \ref IsError(), 0 otherwise.
118 | size_t Offset() const { return offset_; }
119 |
120 | //! Explicit conversion to \c bool, returns \c true, iff !\ref IsError().
121 | operator BooleanType() const { return !IsError() ? &ParseResult::IsError : NULL; }
122 | //! Whether the result is an error.
123 | bool IsError() const { return code_ != kParseErrorNone; }
124 |
125 | bool operator==(const ParseResult& that) const { return code_ == that.code_; }
126 | bool operator==(ParseErrorCode code) const { return code_ == code; }
127 | friend bool operator==(ParseErrorCode code, const ParseResult & err) { return code == err.code_; }
128 |
129 | bool operator!=(const ParseResult& that) const { return !(*this == that); }
130 | bool operator!=(ParseErrorCode code) const { return !(*this == code); }
131 | friend bool operator!=(ParseErrorCode code, const ParseResult & err) { return err != code; }
132 |
133 | //! Reset error code.
134 | void Clear() { Set(kParseErrorNone); }
135 | //! Update error code and offset.
136 | void Set(ParseErrorCode code, size_t offset = 0) { code_ = code; offset_ = offset; }
137 |
138 | private:
139 | ParseErrorCode code_;
140 | size_t offset_;
141 | };
142 |
143 | //! Function pointer type of GetParseError().
144 | /*! \ingroup RAPIDJSON_ERRORS
145 |
146 | This is the prototype for \c GetParseError_X(), where \c X is a locale.
147 | User can dynamically change locale in runtime, e.g.:
148 | \code
149 | GetParseErrorFunc GetParseError = GetParseError_En; // or whatever
150 | const RAPIDJSON_ERROR_CHARTYPE* s = GetParseError(document.GetParseErrorCode());
151 | \endcode
152 | */
153 | typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetParseErrorFunc)(ParseErrorCode);
154 |
155 | RAPIDJSON_NAMESPACE_END
156 |
157 | #ifdef __clang__
158 | RAPIDJSON_DIAG_POP
159 | #endif
160 |
161 | #endif // RAPIDJSON_ERROR_ERROR_H_
162 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/filereadstream.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_FILEREADSTREAM_H_
16 | #define RAPIDJSON_FILEREADSTREAM_H_
17 |
18 | #include "stream.h"
19 | #include
20 |
21 | #ifdef __clang__
22 | RAPIDJSON_DIAG_PUSH
23 | RAPIDJSON_DIAG_OFF(padded)
24 | RAPIDJSON_DIAG_OFF(unreachable-code)
25 | RAPIDJSON_DIAG_OFF(missing-noreturn)
26 | #endif
27 |
28 | RAPIDJSON_NAMESPACE_BEGIN
29 |
30 | //! File byte stream for input using fread().
31 | /*!
32 | \note implements Stream concept
33 | */
34 | class FileReadStream {
35 | public:
36 | typedef char Ch; //!< Character type (byte).
37 |
38 | //! Constructor.
39 | /*!
40 | \param fp File pointer opened for read.
41 | \param buffer user-supplied buffer.
42 | \param bufferSize size of buffer in bytes. Must >=4 bytes.
43 | */
44 | FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) {
45 | RAPIDJSON_ASSERT(fp_ != 0);
46 | RAPIDJSON_ASSERT(bufferSize >= 4);
47 | Read();
48 | }
49 |
50 | Ch Peek() const { return *current_; }
51 | Ch Take() { Ch c = *current_; Read(); return c; }
52 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); }
53 |
54 | // Not implemented
55 | void Put(Ch) { RAPIDJSON_ASSERT(false); }
56 | void Flush() { RAPIDJSON_ASSERT(false); }
57 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
58 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
59 |
60 | // For encoding detection only.
61 | const Ch* Peek4() const {
62 | return (current_ + 4 <= bufferLast_) ? current_ : 0;
63 | }
64 |
65 | private:
66 | void Read() {
67 | if (current_ < bufferLast_)
68 | ++current_;
69 | else if (!eof_) {
70 | count_ += readCount_;
71 | readCount_ = std::fread(buffer_, 1, bufferSize_, fp_);
72 | bufferLast_ = buffer_ + readCount_ - 1;
73 | current_ = buffer_;
74 |
75 | if (readCount_ < bufferSize_) {
76 | buffer_[readCount_] = '\0';
77 | ++bufferLast_;
78 | eof_ = true;
79 | }
80 | }
81 | }
82 |
83 | std::FILE* fp_;
84 | Ch *buffer_;
85 | size_t bufferSize_;
86 | Ch *bufferLast_;
87 | Ch *current_;
88 | size_t readCount_;
89 | size_t count_; //!< Number of characters read
90 | bool eof_;
91 | };
92 |
93 | RAPIDJSON_NAMESPACE_END
94 |
95 | #ifdef __clang__
96 | RAPIDJSON_DIAG_POP
97 | #endif
98 |
99 | #endif // RAPIDJSON_FILESTREAM_H_
100 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/filewritestream.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_FILEWRITESTREAM_H_
16 | #define RAPIDJSON_FILEWRITESTREAM_H_
17 |
18 | #include "stream.h"
19 | #include
20 |
21 | #ifdef __clang__
22 | RAPIDJSON_DIAG_PUSH
23 | RAPIDJSON_DIAG_OFF(unreachable-code)
24 | #endif
25 |
26 | RAPIDJSON_NAMESPACE_BEGIN
27 |
28 | //! Wrapper of C file stream for output using fwrite().
29 | /*!
30 | \note implements Stream concept
31 | */
32 | class FileWriteStream {
33 | public:
34 | typedef char Ch; //!< Character type. Only support char.
35 |
36 | FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) {
37 | RAPIDJSON_ASSERT(fp_ != 0);
38 | }
39 |
40 | void Put(char c) {
41 | if (current_ >= bufferEnd_)
42 | Flush();
43 |
44 | *current_++ = c;
45 | }
46 |
47 | void PutN(char c, size_t n) {
48 | size_t avail = static_cast(bufferEnd_ - current_);
49 | while (n > avail) {
50 | std::memset(current_, c, avail);
51 | current_ += avail;
52 | Flush();
53 | n -= avail;
54 | avail = static_cast(bufferEnd_ - current_);
55 | }
56 |
57 | if (n > 0) {
58 | std::memset(current_, c, n);
59 | current_ += n;
60 | }
61 | }
62 |
63 | void Flush() {
64 | if (current_ != buffer_) {
65 | size_t result = std::fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_);
66 | if (result < static_cast(current_ - buffer_)) {
67 | // failure deliberately ignored at this time
68 | // added to avoid warn_unused_result build errors
69 | }
70 | current_ = buffer_;
71 | }
72 | }
73 |
74 | // Not implemented
75 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; }
76 | char Take() { RAPIDJSON_ASSERT(false); return 0; }
77 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }
78 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
79 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
80 |
81 | private:
82 | // Prohibit copy constructor & assignment operator.
83 | FileWriteStream(const FileWriteStream&);
84 | FileWriteStream& operator=(const FileWriteStream&);
85 |
86 | std::FILE* fp_;
87 | char *buffer_;
88 | char *bufferEnd_;
89 | char *current_;
90 | };
91 |
92 | //! Implement specialized version of PutN() with memset() for better performance.
93 | template<>
94 | inline void PutN(FileWriteStream& stream, char c, size_t n) {
95 | stream.PutN(c, n);
96 | }
97 |
98 | RAPIDJSON_NAMESPACE_END
99 |
100 | #ifdef __clang__
101 | RAPIDJSON_DIAG_POP
102 | #endif
103 |
104 | #endif // RAPIDJSON_FILESTREAM_H_
105 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/fwd.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_FWD_H_
16 | #define RAPIDJSON_FWD_H_
17 |
18 | #include "rapidjson.h"
19 |
20 | RAPIDJSON_NAMESPACE_BEGIN
21 |
22 | // encodings.h
23 |
24 | template struct UTF8;
25 | template struct UTF16;
26 | template struct UTF16BE;
27 | template struct UTF16LE;
28 | template struct UTF32;
29 | template struct UTF32BE;
30 | template struct UTF32LE;
31 | template struct ASCII;
32 | template struct AutoUTF;
33 |
34 | template
35 | struct Transcoder;
36 |
37 | // allocators.h
38 |
39 | class CrtAllocator;
40 |
41 | template
42 | class MemoryPoolAllocator;
43 |
44 | // stream.h
45 |
46 | template
47 | struct GenericStringStream;
48 |
49 | typedef GenericStringStream > StringStream;
50 |
51 | template
52 | struct GenericInsituStringStream;
53 |
54 | typedef GenericInsituStringStream > InsituStringStream;
55 |
56 | // stringbuffer.h
57 |
58 | template
59 | class GenericStringBuffer;
60 |
61 | typedef GenericStringBuffer, CrtAllocator> StringBuffer;
62 |
63 | // filereadstream.h
64 |
65 | class FileReadStream;
66 |
67 | // filewritestream.h
68 |
69 | class FileWriteStream;
70 |
71 | // memorybuffer.h
72 |
73 | template
74 | struct GenericMemoryBuffer;
75 |
76 | typedef GenericMemoryBuffer MemoryBuffer;
77 |
78 | // memorystream.h
79 |
80 | struct MemoryStream;
81 |
82 | // reader.h
83 |
84 | template
85 | struct BaseReaderHandler;
86 |
87 | template
88 | class GenericReader;
89 |
90 | typedef GenericReader, UTF8, CrtAllocator> Reader;
91 |
92 | // writer.h
93 |
94 | template
95 | class Writer;
96 |
97 | // prettywriter.h
98 |
99 | template
100 | class PrettyWriter;
101 |
102 | // document.h
103 |
104 | template
105 | struct GenericMember;
106 |
107 | template
108 | class GenericMemberIterator;
109 |
110 | template
111 | struct GenericStringRef;
112 |
113 | template
114 | class GenericValue;
115 |
116 | typedef GenericValue, MemoryPoolAllocator > Value;
117 |
118 | template
119 | class GenericDocument;
120 |
121 | typedef GenericDocument, MemoryPoolAllocator, CrtAllocator> Document;
122 |
123 | // pointer.h
124 |
125 | template
126 | class GenericPointer;
127 |
128 | typedef GenericPointer Pointer;
129 |
130 | // schema.h
131 |
132 | template
133 | class IGenericRemoteSchemaDocumentProvider;
134 |
135 | template
136 | class GenericSchemaDocument;
137 |
138 | typedef GenericSchemaDocument SchemaDocument;
139 | typedef IGenericRemoteSchemaDocumentProvider IRemoteSchemaDocumentProvider;
140 |
141 | template <
142 | typename SchemaDocumentType,
143 | typename OutputHandler,
144 | typename StateAllocator>
145 | class GenericSchemaValidator;
146 |
147 | typedef GenericSchemaValidator, void>, CrtAllocator> SchemaValidator;
148 |
149 | RAPIDJSON_NAMESPACE_END
150 |
151 | #endif // RAPIDJSON_RAPIDJSONFWD_H_
152 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/internal/dtoa.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | // This is a C++ header-only implementation of Grisu2 algorithm from the publication:
16 | // Loitsch, Florian. "Printing floating-point numbers quickly and accurately with
17 | // integers." ACM Sigplan Notices 45.6 (2010): 233-243.
18 |
19 | #ifndef RAPIDJSON_DTOA_
20 | #define RAPIDJSON_DTOA_
21 |
22 | #include "itoa.h" // GetDigitsLut()
23 | #include "diyfp.h"
24 | #include "ieee754.h"
25 |
26 | RAPIDJSON_NAMESPACE_BEGIN
27 | namespace internal {
28 |
29 | #ifdef __GNUC__
30 | RAPIDJSON_DIAG_PUSH
31 | RAPIDJSON_DIAG_OFF(effc++)
32 | RAPIDJSON_DIAG_OFF(array-bounds) // some gcc versions generate wrong warnings https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124
33 | #endif
34 |
35 | inline void GrisuRound(char* buffer, int len, uint64_t delta, uint64_t rest, uint64_t ten_kappa, uint64_t wp_w) {
36 | while (rest < wp_w && delta - rest >= ten_kappa &&
37 | (rest + ten_kappa < wp_w || /// closer
38 | wp_w - rest > rest + ten_kappa - wp_w)) {
39 | buffer[len - 1]--;
40 | rest += ten_kappa;
41 | }
42 | }
43 |
44 | inline int CountDecimalDigit32(uint32_t n) {
45 | // Simple pure C++ implementation was faster than __builtin_clz version in this situation.
46 | if (n < 10) return 1;
47 | if (n < 100) return 2;
48 | if (n < 1000) return 3;
49 | if (n < 10000) return 4;
50 | if (n < 100000) return 5;
51 | if (n < 1000000) return 6;
52 | if (n < 10000000) return 7;
53 | if (n < 100000000) return 8;
54 | // Will not reach 10 digits in DigitGen()
55 | //if (n < 1000000000) return 9;
56 | //return 10;
57 | return 9;
58 | }
59 |
60 | inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int* len, int* K) {
61 | static const uint32_t kPow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
62 | const DiyFp one(uint64_t(1) << -Mp.e, Mp.e);
63 | const DiyFp wp_w = Mp - W;
64 | uint32_t p1 = static_cast(Mp.f >> -one.e);
65 | uint64_t p2 = Mp.f & (one.f - 1);
66 | int kappa = CountDecimalDigit32(p1); // kappa in [0, 9]
67 | *len = 0;
68 |
69 | while (kappa > 0) {
70 | uint32_t d = 0;
71 | switch (kappa) {
72 | case 9: d = p1 / 100000000; p1 %= 100000000; break;
73 | case 8: d = p1 / 10000000; p1 %= 10000000; break;
74 | case 7: d = p1 / 1000000; p1 %= 1000000; break;
75 | case 6: d = p1 / 100000; p1 %= 100000; break;
76 | case 5: d = p1 / 10000; p1 %= 10000; break;
77 | case 4: d = p1 / 1000; p1 %= 1000; break;
78 | case 3: d = p1 / 100; p1 %= 100; break;
79 | case 2: d = p1 / 10; p1 %= 10; break;
80 | case 1: d = p1; p1 = 0; break;
81 | default:;
82 | }
83 | if (d || *len)
84 | buffer[(*len)++] = static_cast('0' + static_cast(d));
85 | kappa--;
86 | uint64_t tmp = (static_cast(p1) << -one.e) + p2;
87 | if (tmp <= delta) {
88 | *K += kappa;
89 | GrisuRound(buffer, *len, delta, tmp, static_cast(kPow10[kappa]) << -one.e, wp_w.f);
90 | return;
91 | }
92 | }
93 |
94 | // kappa = 0
95 | for (;;) {
96 | p2 *= 10;
97 | delta *= 10;
98 | char d = static_cast(p2 >> -one.e);
99 | if (d || *len)
100 | buffer[(*len)++] = static_cast('0' + d);
101 | p2 &= one.f - 1;
102 | kappa--;
103 | if (p2 < delta) {
104 | *K += kappa;
105 | int index = -kappa;
106 | GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * (index < 9 ? kPow10[index] : 0));
107 | return;
108 | }
109 | }
110 | }
111 |
112 | inline void Grisu2(double value, char* buffer, int* length, int* K) {
113 | const DiyFp v(value);
114 | DiyFp w_m, w_p;
115 | v.NormalizedBoundaries(&w_m, &w_p);
116 |
117 | const DiyFp c_mk = GetCachedPower(w_p.e, K);
118 | const DiyFp W = v.Normalize() * c_mk;
119 | DiyFp Wp = w_p * c_mk;
120 | DiyFp Wm = w_m * c_mk;
121 | Wm.f++;
122 | Wp.f--;
123 | DigitGen(W, Wp, Wp.f - Wm.f, buffer, length, K);
124 | }
125 |
126 | inline char* WriteExponent(int K, char* buffer) {
127 | if (K < 0) {
128 | *buffer++ = '-';
129 | K = -K;
130 | }
131 |
132 | if (K >= 100) {
133 | *buffer++ = static_cast('0' + static_cast(K / 100));
134 | K %= 100;
135 | const char* d = GetDigitsLut() + K * 2;
136 | *buffer++ = d[0];
137 | *buffer++ = d[1];
138 | }
139 | else if (K >= 10) {
140 | const char* d = GetDigitsLut() + K * 2;
141 | *buffer++ = d[0];
142 | *buffer++ = d[1];
143 | }
144 | else
145 | *buffer++ = static_cast('0' + static_cast(K));
146 |
147 | return buffer;
148 | }
149 |
150 | inline char* Prettify(char* buffer, int length, int k, int maxDecimalPlaces) {
151 | const int kk = length + k; // 10^(kk-1) <= v < 10^kk
152 |
153 | if (0 <= k && kk <= 21) {
154 | // 1234e7 -> 12340000000
155 | for (int i = length; i < kk; i++)
156 | buffer[i] = '0';
157 | buffer[kk] = '.';
158 | buffer[kk + 1] = '0';
159 | return &buffer[kk + 2];
160 | }
161 | else if (0 < kk && kk <= 21) {
162 | // 1234e-2 -> 12.34
163 | std::memmove(&buffer[kk + 1], &buffer[kk], static_cast(length - kk));
164 | buffer[kk] = '.';
165 | if (0 > k + maxDecimalPlaces) {
166 | // When maxDecimalPlaces = 2, 1.2345 -> 1.23, 1.102 -> 1.1
167 | // Remove extra trailing zeros (at least one) after truncation.
168 | for (int i = kk + maxDecimalPlaces; i > kk + 1; i--)
169 | if (buffer[i] != '0')
170 | return &buffer[i + 1];
171 | return &buffer[kk + 2]; // Reserve one zero
172 | }
173 | else
174 | return &buffer[length + 1];
175 | }
176 | else if (-6 < kk && kk <= 0) {
177 | // 1234e-6 -> 0.001234
178 | const int offset = 2 - kk;
179 | std::memmove(&buffer[offset], &buffer[0], static_cast(length));
180 | buffer[0] = '0';
181 | buffer[1] = '.';
182 | for (int i = 2; i < offset; i++)
183 | buffer[i] = '0';
184 | if (length - kk > maxDecimalPlaces) {
185 | // When maxDecimalPlaces = 2, 0.123 -> 0.12, 0.102 -> 0.1
186 | // Remove extra trailing zeros (at least one) after truncation.
187 | for (int i = maxDecimalPlaces + 1; i > 2; i--)
188 | if (buffer[i] != '0')
189 | return &buffer[i + 1];
190 | return &buffer[3]; // Reserve one zero
191 | }
192 | else
193 | return &buffer[length + offset];
194 | }
195 | else if (kk < -maxDecimalPlaces) {
196 | // Truncate to zero
197 | buffer[0] = '0';
198 | buffer[1] = '.';
199 | buffer[2] = '0';
200 | return &buffer[3];
201 | }
202 | else if (length == 1) {
203 | // 1e30
204 | buffer[1] = 'e';
205 | return WriteExponent(kk - 1, &buffer[2]);
206 | }
207 | else {
208 | // 1234e30 -> 1.234e33
209 | std::memmove(&buffer[2], &buffer[1], static_cast(length - 1));
210 | buffer[1] = '.';
211 | buffer[length + 1] = 'e';
212 | return WriteExponent(kk - 1, &buffer[0 + length + 2]);
213 | }
214 | }
215 |
216 | inline char* dtoa(double value, char* buffer, int maxDecimalPlaces = 324) {
217 | RAPIDJSON_ASSERT(maxDecimalPlaces >= 1);
218 | Double d(value);
219 | if (d.IsZero()) {
220 | if (d.Sign())
221 | *buffer++ = '-'; // -0.0, Issue #289
222 | buffer[0] = '0';
223 | buffer[1] = '.';
224 | buffer[2] = '0';
225 | return &buffer[3];
226 | }
227 | else {
228 | if (value < 0) {
229 | *buffer++ = '-';
230 | value = -value;
231 | }
232 | int length, K;
233 | Grisu2(value, buffer, &length, &K);
234 | return Prettify(buffer, length, K, maxDecimalPlaces);
235 | }
236 | }
237 |
238 | #ifdef __GNUC__
239 | RAPIDJSON_DIAG_POP
240 | #endif
241 |
242 | } // namespace internal
243 | RAPIDJSON_NAMESPACE_END
244 |
245 | #endif // RAPIDJSON_DTOA_
246 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/internal/ieee754.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_IEEE754_
16 | #define RAPIDJSON_IEEE754_
17 |
18 | #include "../rapidjson.h"
19 |
20 | RAPIDJSON_NAMESPACE_BEGIN
21 | namespace internal {
22 |
23 | class Double {
24 | public:
25 | Double() {}
26 | Double(double d) : d_(d) {}
27 | Double(uint64_t u) : u_(u) {}
28 |
29 | double Value() const { return d_; }
30 | uint64_t Uint64Value() const { return u_; }
31 |
32 | double NextPositiveDouble() const {
33 | RAPIDJSON_ASSERT(!Sign());
34 | return Double(u_ + 1).Value();
35 | }
36 |
37 | bool Sign() const { return (u_ & kSignMask) != 0; }
38 | uint64_t Significand() const { return u_ & kSignificandMask; }
39 | int Exponent() const { return static_cast(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); }
40 |
41 | bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; }
42 | bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; }
43 | bool IsNanOrInf() const { return (u_ & kExponentMask) == kExponentMask; }
44 | bool IsNormal() const { return (u_ & kExponentMask) != 0 || Significand() == 0; }
45 | bool IsZero() const { return (u_ & (kExponentMask | kSignificandMask)) == 0; }
46 |
47 | uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); }
48 | int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; }
49 | uint64_t ToBias() const { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; }
50 |
51 | static int EffectiveSignificandSize(int order) {
52 | if (order >= -1021)
53 | return 53;
54 | else if (order <= -1074)
55 | return 0;
56 | else
57 | return order + 1074;
58 | }
59 |
60 | private:
61 | static const int kSignificandSize = 52;
62 | static const int kExponentBias = 0x3FF;
63 | static const int kDenormalExponent = 1 - kExponentBias;
64 | static const uint64_t kSignMask = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000);
65 | static const uint64_t kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000);
66 | static const uint64_t kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF);
67 | static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000);
68 |
69 | union {
70 | double d_;
71 | uint64_t u_;
72 | };
73 | };
74 |
75 | } // namespace internal
76 | RAPIDJSON_NAMESPACE_END
77 |
78 | #endif // RAPIDJSON_IEEE754_
79 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/internal/meta.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_INTERNAL_META_H_
16 | #define RAPIDJSON_INTERNAL_META_H_
17 |
18 | #include "../rapidjson.h"
19 |
20 | #ifdef __GNUC__
21 | RAPIDJSON_DIAG_PUSH
22 | RAPIDJSON_DIAG_OFF(effc++)
23 | #endif
24 | #if defined(_MSC_VER)
25 | RAPIDJSON_DIAG_PUSH
26 | RAPIDJSON_DIAG_OFF(6334)
27 | #endif
28 |
29 | #if RAPIDJSON_HAS_CXX11_TYPETRAITS
30 | #include
31 | #endif
32 |
33 | //@cond RAPIDJSON_INTERNAL
34 | RAPIDJSON_NAMESPACE_BEGIN
35 | namespace internal {
36 |
37 | // Helper to wrap/convert arbitrary types to void, useful for arbitrary type matching
38 | template struct Void { typedef void Type; };
39 |
40 | ///////////////////////////////////////////////////////////////////////////////
41 | // BoolType, TrueType, FalseType
42 | //
43 | template struct BoolType {
44 | static const bool Value = Cond;
45 | typedef BoolType Type;
46 | };
47 | typedef BoolType TrueType;
48 | typedef BoolType FalseType;
49 |
50 |
51 | ///////////////////////////////////////////////////////////////////////////////
52 | // SelectIf, BoolExpr, NotExpr, AndExpr, OrExpr
53 | //
54 |
55 | template struct SelectIfImpl { template struct Apply { typedef T1 Type; }; };
56 | template <> struct SelectIfImpl { template struct Apply { typedef T2 Type; }; };
57 | template struct SelectIfCond : SelectIfImpl::template Apply {};
58 | template struct SelectIf : SelectIfCond {};
59 |
60 | template struct AndExprCond : FalseType {};
61 | template <> struct AndExprCond : TrueType {};
62 | template struct OrExprCond : TrueType {};
63 | template <> struct OrExprCond : FalseType {};
64 |
65 | template struct BoolExpr : SelectIf::Type {};
66 | template struct NotExpr : SelectIf::Type {};
67 | template struct AndExpr : AndExprCond::Type {};
68 | template struct OrExpr : OrExprCond::Type {};
69 |
70 |
71 | ///////////////////////////////////////////////////////////////////////////////
72 | // AddConst, MaybeAddConst, RemoveConst
73 | template struct AddConst { typedef const T Type; };
74 | template struct MaybeAddConst : SelectIfCond {};
75 | template struct RemoveConst { typedef T Type; };
76 | template struct RemoveConst { typedef T Type; };
77 |
78 |
79 | ///////////////////////////////////////////////////////////////////////////////
80 | // IsSame, IsConst, IsMoreConst, IsPointer
81 | //
82 | template struct IsSame : FalseType {};
83 | template struct IsSame : TrueType {};
84 |
85 | template struct IsConst : FalseType {};
86 | template struct IsConst : TrueType {};
87 |
88 | template
89 | struct IsMoreConst
90 | : AndExpr::Type, typename RemoveConst::Type>,
91 | BoolType::Value >= IsConst::Value> >::Type {};
92 |
93 | template struct IsPointer : FalseType {};
94 | template struct IsPointer : TrueType {};
95 |
96 | ///////////////////////////////////////////////////////////////////////////////
97 | // IsBaseOf
98 | //
99 | #if RAPIDJSON_HAS_CXX11_TYPETRAITS
100 |
101 | template struct IsBaseOf
102 | : BoolType< ::std::is_base_of::value> {};
103 |
104 | #else // simplified version adopted from Boost
105 |
106 | template struct IsBaseOfImpl {
107 | RAPIDJSON_STATIC_ASSERT(sizeof(B) != 0);
108 | RAPIDJSON_STATIC_ASSERT(sizeof(D) != 0);
109 |
110 | typedef char (&Yes)[1];
111 | typedef char (&No) [2];
112 |
113 | template
114 | static Yes Check(const D*, T);
115 | static No Check(const B*, int);
116 |
117 | struct Host {
118 | operator const B*() const;
119 | operator const D*();
120 | };
121 |
122 | enum { Value = (sizeof(Check(Host(), 0)) == sizeof(Yes)) };
123 | };
124 |
125 | template struct IsBaseOf
126 | : OrExpr, BoolExpr > >::Type {};
127 |
128 | #endif // RAPIDJSON_HAS_CXX11_TYPETRAITS
129 |
130 |
131 | //////////////////////////////////////////////////////////////////////////
132 | // EnableIf / DisableIf
133 | //
134 | template struct EnableIfCond { typedef T Type; };
135 | template struct EnableIfCond { /* empty */ };
136 |
137 | template struct DisableIfCond { typedef T Type; };
138 | template struct DisableIfCond { /* empty */ };
139 |
140 | template
141 | struct EnableIf : EnableIfCond {};
142 |
143 | template
144 | struct DisableIf : DisableIfCond {};
145 |
146 | // SFINAE helpers
147 | struct SfinaeTag {};
148 | template struct RemoveSfinaeTag;
149 | template struct RemoveSfinaeTag { typedef T Type; };
150 |
151 | #define RAPIDJSON_REMOVEFPTR_(type) \
152 | typename ::RAPIDJSON_NAMESPACE::internal::RemoveSfinaeTag \
153 | < ::RAPIDJSON_NAMESPACE::internal::SfinaeTag&(*) type>::Type
154 |
155 | #define RAPIDJSON_ENABLEIF(cond) \
156 | typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \
157 | ::Type * = NULL
158 |
159 | #define RAPIDJSON_DISABLEIF(cond) \
160 | typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \
161 | ::Type * = NULL
162 |
163 | #define RAPIDJSON_ENABLEIF_RETURN(cond,returntype) \
164 | typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \
165 | ::Type
167 |
168 | #define RAPIDJSON_DISABLEIF_RETURN(cond,returntype) \
169 | typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \
170 | ::Type
172 |
173 | } // namespace internal
174 | RAPIDJSON_NAMESPACE_END
175 | //@endcond
176 |
177 | #if defined(__GNUC__) || defined(_MSC_VER)
178 | RAPIDJSON_DIAG_POP
179 | #endif
180 |
181 | #endif // RAPIDJSON_INTERNAL_META_H_
182 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/internal/pow10.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_POW10_
16 | #define RAPIDJSON_POW10_
17 |
18 | #include "../rapidjson.h"
19 |
20 | RAPIDJSON_NAMESPACE_BEGIN
21 | namespace internal {
22 |
23 | //! Computes integer powers of 10 in double (10.0^n).
24 | /*! This function uses lookup table for fast and accurate results.
25 | \param n non-negative exponent. Must <= 308.
26 | \return 10.0^n
27 | */
28 | inline double Pow10(int n) {
29 | static const double e[] = { // 1e-0...1e308: 309 * 8 bytes = 2472 bytes
30 | 1e+0,
31 | 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20,
32 | 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40,
33 | 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60,
34 | 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80,
35 | 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100,
36 | 1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120,
37 | 1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140,
38 | 1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160,
39 | 1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180,
40 | 1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200,
41 | 1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220,
42 | 1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240,
43 | 1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260,
44 | 1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280,
45 | 1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300,
46 | 1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308
47 | };
48 | RAPIDJSON_ASSERT(n >= 0 && n <= 308);
49 | return e[n];
50 | }
51 |
52 | } // namespace internal
53 | RAPIDJSON_NAMESPACE_END
54 |
55 | #endif // RAPIDJSON_POW10_
56 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/internal/stack.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_INTERNAL_STACK_H_
16 | #define RAPIDJSON_INTERNAL_STACK_H_
17 |
18 | #include "../allocators.h"
19 | #include "swap.h"
20 |
21 | #if defined(__clang__)
22 | RAPIDJSON_DIAG_PUSH
23 | RAPIDJSON_DIAG_OFF(c++98-compat)
24 | #endif
25 |
26 | RAPIDJSON_NAMESPACE_BEGIN
27 | namespace internal {
28 |
29 | ///////////////////////////////////////////////////////////////////////////////
30 | // Stack
31 |
32 | //! A type-unsafe stack for storing different types of data.
33 | /*! \tparam Allocator Allocator for allocating stack memory.
34 | */
35 | template
36 | class Stack {
37 | public:
38 | // Optimization note: Do not allocate memory for stack_ in constructor.
39 | // Do it lazily when first Push() -> Expand() -> Resize().
40 | Stack(Allocator* allocator, size_t stackCapacity) : allocator_(allocator), ownAllocator_(0), stack_(0), stackTop_(0), stackEnd_(0), initialCapacity_(stackCapacity) {
41 | }
42 |
43 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
44 | Stack(Stack&& rhs)
45 | : allocator_(rhs.allocator_),
46 | ownAllocator_(rhs.ownAllocator_),
47 | stack_(rhs.stack_),
48 | stackTop_(rhs.stackTop_),
49 | stackEnd_(rhs.stackEnd_),
50 | initialCapacity_(rhs.initialCapacity_)
51 | {
52 | rhs.allocator_ = 0;
53 | rhs.ownAllocator_ = 0;
54 | rhs.stack_ = 0;
55 | rhs.stackTop_ = 0;
56 | rhs.stackEnd_ = 0;
57 | rhs.initialCapacity_ = 0;
58 | }
59 | #endif
60 |
61 | ~Stack() {
62 | Destroy();
63 | }
64 |
65 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
66 | Stack& operator=(Stack&& rhs) {
67 | if (&rhs != this)
68 | {
69 | Destroy();
70 |
71 | allocator_ = rhs.allocator_;
72 | ownAllocator_ = rhs.ownAllocator_;
73 | stack_ = rhs.stack_;
74 | stackTop_ = rhs.stackTop_;
75 | stackEnd_ = rhs.stackEnd_;
76 | initialCapacity_ = rhs.initialCapacity_;
77 |
78 | rhs.allocator_ = 0;
79 | rhs.ownAllocator_ = 0;
80 | rhs.stack_ = 0;
81 | rhs.stackTop_ = 0;
82 | rhs.stackEnd_ = 0;
83 | rhs.initialCapacity_ = 0;
84 | }
85 | return *this;
86 | }
87 | #endif
88 |
89 | void Swap(Stack& rhs) RAPIDJSON_NOEXCEPT {
90 | internal::Swap(allocator_, rhs.allocator_);
91 | internal::Swap(ownAllocator_, rhs.ownAllocator_);
92 | internal::Swap(stack_, rhs.stack_);
93 | internal::Swap(stackTop_, rhs.stackTop_);
94 | internal::Swap(stackEnd_, rhs.stackEnd_);
95 | internal::Swap(initialCapacity_, rhs.initialCapacity_);
96 | }
97 |
98 | void Clear() { stackTop_ = stack_; }
99 |
100 | void ShrinkToFit() {
101 | if (Empty()) {
102 | // If the stack is empty, completely deallocate the memory.
103 | Allocator::Free(stack_);
104 | stack_ = 0;
105 | stackTop_ = 0;
106 | stackEnd_ = 0;
107 | }
108 | else
109 | Resize(GetSize());
110 | }
111 |
112 | // Optimization note: try to minimize the size of this function for force inline.
113 | // Expansion is run very infrequently, so it is moved to another (probably non-inline) function.
114 | template
115 | RAPIDJSON_FORCEINLINE void Reserve(size_t count = 1) {
116 | // Expand the stack if needed
117 | if (RAPIDJSON_UNLIKELY(stackTop_ + sizeof(T) * count > stackEnd_))
118 | Expand(count);
119 | }
120 |
121 | template
122 | RAPIDJSON_FORCEINLINE T* Push(size_t count = 1) {
123 | Reserve(count);
124 | return PushUnsafe(count);
125 | }
126 |
127 | template
128 | RAPIDJSON_FORCEINLINE T* PushUnsafe(size_t count = 1) {
129 | RAPIDJSON_ASSERT(stackTop_);
130 | RAPIDJSON_ASSERT(stackTop_ + sizeof(T) * count <= stackEnd_);
131 | T* ret = reinterpret_cast(stackTop_);
132 | stackTop_ += sizeof(T) * count;
133 | return ret;
134 | }
135 |
136 | template
137 | T* Pop(size_t count) {
138 | RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T));
139 | stackTop_ -= count * sizeof(T);
140 | return reinterpret_cast(stackTop_);
141 | }
142 |
143 | template
144 | T* Top() {
145 | RAPIDJSON_ASSERT(GetSize() >= sizeof(T));
146 | return reinterpret_cast(stackTop_ - sizeof(T));
147 | }
148 |
149 | template
150 | const T* Top() const {
151 | RAPIDJSON_ASSERT(GetSize() >= sizeof(T));
152 | return reinterpret_cast(stackTop_ - sizeof(T));
153 | }
154 |
155 | template
156 | T* End() { return reinterpret_cast(stackTop_); }
157 |
158 | template
159 | const T* End() const { return reinterpret_cast(stackTop_); }
160 |
161 | template
162 | T* Bottom() { return reinterpret_cast(stack_); }
163 |
164 | template
165 | const T* Bottom() const { return reinterpret_cast(stack_); }
166 |
167 | bool HasAllocator() const {
168 | return allocator_ != 0;
169 | }
170 |
171 | Allocator& GetAllocator() {
172 | RAPIDJSON_ASSERT(allocator_);
173 | return *allocator_;
174 | }
175 |
176 | bool Empty() const { return stackTop_ == stack_; }
177 | size_t GetSize() const { return static_cast(stackTop_ - stack_); }
178 | size_t GetCapacity() const { return static_cast(stackEnd_ - stack_); }
179 |
180 | private:
181 | template
182 | void Expand(size_t count) {
183 | // Only expand the capacity if the current stack exists. Otherwise just create a stack with initial capacity.
184 | size_t newCapacity;
185 | if (stack_ == 0) {
186 | if (!allocator_)
187 | ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
188 | newCapacity = initialCapacity_;
189 | } else {
190 | newCapacity = GetCapacity();
191 | newCapacity += (newCapacity + 1) / 2;
192 | }
193 | size_t newSize = GetSize() + sizeof(T) * count;
194 | if (newCapacity < newSize)
195 | newCapacity = newSize;
196 |
197 | Resize(newCapacity);
198 | }
199 |
200 | void Resize(size_t newCapacity) {
201 | const size_t size = GetSize(); // Backup the current size
202 | stack_ = static_cast(allocator_->Realloc(stack_, GetCapacity(), newCapacity));
203 | stackTop_ = stack_ + size;
204 | stackEnd_ = stack_ + newCapacity;
205 | }
206 |
207 | void Destroy() {
208 | Allocator::Free(stack_);
209 | RAPIDJSON_DELETE(ownAllocator_); // Only delete if it is owned by the stack
210 | }
211 |
212 | // Prohibit copy constructor & assignment operator.
213 | Stack(const Stack&);
214 | Stack& operator=(const Stack&);
215 |
216 | Allocator* allocator_;
217 | Allocator* ownAllocator_;
218 | char *stack_;
219 | char *stackTop_;
220 | char *stackEnd_;
221 | size_t initialCapacity_;
222 | };
223 |
224 | } // namespace internal
225 | RAPIDJSON_NAMESPACE_END
226 |
227 | #if defined(__clang__)
228 | RAPIDJSON_DIAG_POP
229 | #endif
230 |
231 | #endif // RAPIDJSON_STACK_H_
232 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/internal/strfunc.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_
16 | #define RAPIDJSON_INTERNAL_STRFUNC_H_
17 |
18 | #include "../stream.h"
19 | #include
20 |
21 | RAPIDJSON_NAMESPACE_BEGIN
22 | namespace internal {
23 |
24 | //! Custom strlen() which works on different character types.
25 | /*! \tparam Ch Character type (e.g. char, wchar_t, short)
26 | \param s Null-terminated input string.
27 | \return Number of characters in the string.
28 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints.
29 | */
30 | template
31 | inline SizeType StrLen(const Ch* s) {
32 | RAPIDJSON_ASSERT(s != 0);
33 | const Ch* p = s;
34 | while (*p) ++p;
35 | return SizeType(p - s);
36 | }
37 |
38 | template <>
39 | inline SizeType StrLen(const char* s) {
40 | return SizeType(std::strlen(s));
41 | }
42 |
43 | template <>
44 | inline SizeType StrLen(const wchar_t* s) {
45 | return SizeType(std::wcslen(s));
46 | }
47 |
48 | //! Returns number of code points in a encoded string.
49 | template
50 | bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) {
51 | RAPIDJSON_ASSERT(s != 0);
52 | RAPIDJSON_ASSERT(outCount != 0);
53 | GenericStringStream is(s);
54 | const typename Encoding::Ch* end = s + length;
55 | SizeType count = 0;
56 | while (is.src_ < end) {
57 | unsigned codepoint;
58 | if (!Encoding::Decode(is, &codepoint))
59 | return false;
60 | count++;
61 | }
62 | *outCount = count;
63 | return true;
64 | }
65 |
66 | } // namespace internal
67 | RAPIDJSON_NAMESPACE_END
68 |
69 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_
70 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/internal/swap.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_
16 | #define RAPIDJSON_INTERNAL_SWAP_H_
17 |
18 | #include "../rapidjson.h"
19 |
20 | #if defined(__clang__)
21 | RAPIDJSON_DIAG_PUSH
22 | RAPIDJSON_DIAG_OFF(c++98-compat)
23 | #endif
24 |
25 | RAPIDJSON_NAMESPACE_BEGIN
26 | namespace internal {
27 |
28 | //! Custom swap() to avoid dependency on C++ header
29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only.
30 | \note This has the same semantics as std::swap().
31 | */
32 | template
33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT {
34 | T tmp = a;
35 | a = b;
36 | b = tmp;
37 | }
38 |
39 | } // namespace internal
40 | RAPIDJSON_NAMESPACE_END
41 |
42 | #if defined(__clang__)
43 | RAPIDJSON_DIAG_POP
44 | #endif
45 |
46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_
47 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/istreamwrapper.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_ISTREAMWRAPPER_H_
16 | #define RAPIDJSON_ISTREAMWRAPPER_H_
17 |
18 | #include "stream.h"
19 | #include
20 |
21 | #ifdef __clang__
22 | RAPIDJSON_DIAG_PUSH
23 | RAPIDJSON_DIAG_OFF(padded)
24 | #endif
25 |
26 | #ifdef _MSC_VER
27 | RAPIDJSON_DIAG_PUSH
28 | RAPIDJSON_DIAG_OFF(4351) // new behavior: elements of array 'array' will be default initialized
29 | #endif
30 |
31 | RAPIDJSON_NAMESPACE_BEGIN
32 |
33 | //! Wrapper of \c std::basic_istream into RapidJSON's Stream concept.
34 | /*!
35 | The classes can be wrapped including but not limited to:
36 |
37 | - \c std::istringstream
38 | - \c std::stringstream
39 | - \c std::wistringstream
40 | - \c std::wstringstream
41 | - \c std::ifstream
42 | - \c std::fstream
43 | - \c std::wifstream
44 | - \c std::wfstream
45 |
46 | \tparam StreamType Class derived from \c std::basic_istream.
47 | */
48 |
49 | template
50 | class BasicIStreamWrapper {
51 | public:
52 | typedef typename StreamType::char_type Ch;
53 | BasicIStreamWrapper(StreamType& stream) : stream_(stream), count_(), peekBuffer_() {}
54 |
55 | Ch Peek() const {
56 | typename StreamType::int_type c = stream_.peek();
57 | return RAPIDJSON_LIKELY(c != StreamType::traits_type::eof()) ? static_cast(c) : static_cast('\0');
58 | }
59 |
60 | Ch Take() {
61 | typename StreamType::int_type c = stream_.get();
62 | if (RAPIDJSON_LIKELY(c != StreamType::traits_type::eof())) {
63 | count_++;
64 | return static_cast(c);
65 | }
66 | else
67 | return '\0';
68 | }
69 |
70 | // tellg() may return -1 when failed. So we count by ourself.
71 | size_t Tell() const { return count_; }
72 |
73 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
74 | void Put(Ch) { RAPIDJSON_ASSERT(false); }
75 | void Flush() { RAPIDJSON_ASSERT(false); }
76 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
77 |
78 | // For encoding detection only.
79 | const Ch* Peek4() const {
80 | RAPIDJSON_ASSERT(sizeof(Ch) == 1); // Only usable for byte stream.
81 | int i;
82 | bool hasError = false;
83 | for (i = 0; i < 4; ++i) {
84 | typename StreamType::int_type c = stream_.get();
85 | if (c == StreamType::traits_type::eof()) {
86 | hasError = true;
87 | stream_.clear();
88 | break;
89 | }
90 | peekBuffer_[i] = static_cast(c);
91 | }
92 | for (--i; i >= 0; --i)
93 | stream_.putback(peekBuffer_[i]);
94 | return !hasError ? peekBuffer_ : 0;
95 | }
96 |
97 | private:
98 | BasicIStreamWrapper(const BasicIStreamWrapper&);
99 | BasicIStreamWrapper& operator=(const BasicIStreamWrapper&);
100 |
101 | StreamType& stream_;
102 | size_t count_; //!< Number of characters read. Note:
103 | mutable Ch peekBuffer_[4];
104 | };
105 |
106 | typedef BasicIStreamWrapper IStreamWrapper;
107 | typedef BasicIStreamWrapper WIStreamWrapper;
108 |
109 | #if defined(__clang__) || defined(_MSC_VER)
110 | RAPIDJSON_DIAG_POP
111 | #endif
112 |
113 | RAPIDJSON_NAMESPACE_END
114 |
115 | #endif // RAPIDJSON_ISTREAMWRAPPER_H_
116 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/memorybuffer.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_MEMORYBUFFER_H_
16 | #define RAPIDJSON_MEMORYBUFFER_H_
17 |
18 | #include "stream.h"
19 | #include "internal/stack.h"
20 |
21 | RAPIDJSON_NAMESPACE_BEGIN
22 |
23 | //! Represents an in-memory output byte stream.
24 | /*!
25 | This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream.
26 |
27 | It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file.
28 |
29 | Differences between MemoryBuffer and StringBuffer:
30 | 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer.
31 | 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator.
32 |
33 | \tparam Allocator type for allocating memory buffer.
34 | \note implements Stream concept
35 | */
36 | template
37 | struct GenericMemoryBuffer {
38 | typedef char Ch; // byte
39 |
40 | GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}
41 |
42 | void Put(Ch c) { *stack_.template Push() = c; }
43 | void Flush() {}
44 |
45 | void Clear() { stack_.Clear(); }
46 | void ShrinkToFit() { stack_.ShrinkToFit(); }
47 | Ch* Push(size_t count) { return stack_.template Push(count); }
48 | void Pop(size_t count) { stack_.template Pop(count); }
49 |
50 | const Ch* GetBuffer() const {
51 | return stack_.template Bottom();
52 | }
53 |
54 | size_t GetSize() const { return stack_.GetSize(); }
55 |
56 | static const size_t kDefaultCapacity = 256;
57 | mutable internal::Stack stack_;
58 | };
59 |
60 | typedef GenericMemoryBuffer<> MemoryBuffer;
61 |
62 | //! Implement specialized version of PutN() with memset() for better performance.
63 | template<>
64 | inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) {
65 | std::memset(memoryBuffer.stack_.Push(n), c, n * sizeof(c));
66 | }
67 |
68 | RAPIDJSON_NAMESPACE_END
69 |
70 | #endif // RAPIDJSON_MEMORYBUFFER_H_
71 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/memorystream.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_MEMORYSTREAM_H_
16 | #define RAPIDJSON_MEMORYSTREAM_H_
17 |
18 | #include "stream.h"
19 |
20 | #ifdef __clang__
21 | RAPIDJSON_DIAG_PUSH
22 | RAPIDJSON_DIAG_OFF(unreachable-code)
23 | RAPIDJSON_DIAG_OFF(missing-noreturn)
24 | #endif
25 |
26 | RAPIDJSON_NAMESPACE_BEGIN
27 |
28 | //! Represents an in-memory input byte stream.
29 | /*!
30 | This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream.
31 |
32 | It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file.
33 |
34 | Differences between MemoryStream and StringStream:
35 | 1. StringStream has encoding but MemoryStream is a byte stream.
36 | 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source.
37 | 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4().
38 | \note implements Stream concept
39 | */
40 | struct MemoryStream {
41 | typedef char Ch; // byte
42 |
43 | MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {}
44 |
45 | Ch Peek() const { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_; }
46 | Ch Take() { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; }
47 | size_t Tell() const { return static_cast(src_ - begin_); }
48 |
49 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
50 | void Put(Ch) { RAPIDJSON_ASSERT(false); }
51 | void Flush() { RAPIDJSON_ASSERT(false); }
52 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
53 |
54 | // For encoding detection only.
55 | const Ch* Peek4() const {
56 | return Tell() + 4 <= size_ ? src_ : 0;
57 | }
58 |
59 | const Ch* src_; //!< Current read position.
60 | const Ch* begin_; //!< Original head of the string.
61 | const Ch* end_; //!< End of stream.
62 | size_t size_; //!< Size of the stream.
63 | };
64 |
65 | RAPIDJSON_NAMESPACE_END
66 |
67 | #ifdef __clang__
68 | RAPIDJSON_DIAG_POP
69 | #endif
70 |
71 | #endif // RAPIDJSON_MEMORYBUFFER_H_
72 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/ostreamwrapper.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_OSTREAMWRAPPER_H_
16 | #define RAPIDJSON_OSTREAMWRAPPER_H_
17 |
18 | #include "stream.h"
19 | #include
20 |
21 | #ifdef __clang__
22 | RAPIDJSON_DIAG_PUSH
23 | RAPIDJSON_DIAG_OFF(padded)
24 | #endif
25 |
26 | RAPIDJSON_NAMESPACE_BEGIN
27 |
28 | //! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept.
29 | /*!
30 | The classes can be wrapped including but not limited to:
31 |
32 | - \c std::ostringstream
33 | - \c std::stringstream
34 | - \c std::wpstringstream
35 | - \c std::wstringstream
36 | - \c std::ifstream
37 | - \c std::fstream
38 | - \c std::wofstream
39 | - \c std::wfstream
40 |
41 | \tparam StreamType Class derived from \c std::basic_ostream.
42 | */
43 |
44 | template
45 | class BasicOStreamWrapper {
46 | public:
47 | typedef typename StreamType::char_type Ch;
48 | BasicOStreamWrapper(StreamType& stream) : stream_(stream) {}
49 |
50 | void Put(Ch c) {
51 | stream_.put(c);
52 | }
53 |
54 | void Flush() {
55 | stream_.flush();
56 | }
57 |
58 | // Not implemented
59 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; }
60 | char Take() { RAPIDJSON_ASSERT(false); return 0; }
61 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }
62 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
63 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
64 |
65 | private:
66 | BasicOStreamWrapper(const BasicOStreamWrapper&);
67 | BasicOStreamWrapper& operator=(const BasicOStreamWrapper&);
68 |
69 | StreamType& stream_;
70 | };
71 |
72 | typedef BasicOStreamWrapper OStreamWrapper;
73 | typedef BasicOStreamWrapper WOStreamWrapper;
74 |
75 | #ifdef __clang__
76 | RAPIDJSON_DIAG_POP
77 | #endif
78 |
79 | RAPIDJSON_NAMESPACE_END
80 |
81 | #endif // RAPIDJSON_OSTREAMWRAPPER_H_
82 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/stream.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #include "rapidjson.h"
16 |
17 | #ifndef RAPIDJSON_STREAM_H_
18 | #define RAPIDJSON_STREAM_H_
19 |
20 | #include "encodings.h"
21 |
22 | RAPIDJSON_NAMESPACE_BEGIN
23 |
24 | ///////////////////////////////////////////////////////////////////////////////
25 | // Stream
26 |
27 | /*! \class rapidjson::Stream
28 | \brief Concept for reading and writing characters.
29 |
30 | For read-only stream, no need to implement PutBegin(), Put(), Flush() and PutEnd().
31 |
32 | For write-only stream, only need to implement Put() and Flush().
33 |
34 | \code
35 | concept Stream {
36 | typename Ch; //!< Character type of the stream.
37 |
38 | //! Read the current character from stream without moving the read cursor.
39 | Ch Peek() const;
40 |
41 | //! Read the current character from stream and moving the read cursor to next character.
42 | Ch Take();
43 |
44 | //! Get the current read cursor.
45 | //! \return Number of characters read from start.
46 | size_t Tell();
47 |
48 | //! Begin writing operation at the current read pointer.
49 | //! \return The begin writer pointer.
50 | Ch* PutBegin();
51 |
52 | //! Write a character.
53 | void Put(Ch c);
54 |
55 | //! Flush the buffer.
56 | void Flush();
57 |
58 | //! End the writing operation.
59 | //! \param begin The begin write pointer returned by PutBegin().
60 | //! \return Number of characters written.
61 | size_t PutEnd(Ch* begin);
62 | }
63 | \endcode
64 | */
65 |
66 | //! Provides additional information for stream.
67 | /*!
68 | By using traits pattern, this type provides a default configuration for stream.
69 | For custom stream, this type can be specialized for other configuration.
70 | See TEST(Reader, CustomStringStream) in readertest.cpp for example.
71 | */
72 | template
73 | struct StreamTraits {
74 | //! Whether to make local copy of stream for optimization during parsing.
75 | /*!
76 | By default, for safety, streams do not use local copy optimization.
77 | Stream that can be copied fast should specialize this, like StreamTraits.
78 | */
79 | enum { copyOptimization = 0 };
80 | };
81 |
82 | //! Reserve n characters for writing to a stream.
83 | template
84 | inline void PutReserve(Stream& stream, size_t count) {
85 | (void)stream;
86 | (void)count;
87 | }
88 |
89 | //! Write character to a stream, presuming buffer is reserved.
90 | template
91 | inline void PutUnsafe(Stream& stream, typename Stream::Ch c) {
92 | stream.Put(c);
93 | }
94 |
95 | //! Put N copies of a character to a stream.
96 | template
97 | inline void PutN(Stream& stream, Ch c, size_t n) {
98 | PutReserve(stream, n);
99 | for (size_t i = 0; i < n; i++)
100 | PutUnsafe(stream, c);
101 | }
102 |
103 | ///////////////////////////////////////////////////////////////////////////////
104 | // GenericStreamWrapper
105 |
106 | //! A Stream Wrapper
107 | /*! \tThis string stream is a wrapper for any stream by just forwarding any
108 | \treceived message to the origin stream.
109 | \note implements Stream concept
110 | */
111 |
112 | #if defined(_MSC_VER) && _MSC_VER <= 1800
113 | RAPIDJSON_DIAG_PUSH
114 | RAPIDJSON_DIAG_OFF(4702) // unreachable code
115 | RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
116 | #endif
117 |
118 | template >
119 | class GenericStreamWrapper {
120 | public:
121 | typedef typename Encoding::Ch Ch;
122 | GenericStreamWrapper(InputStream& is): is_(is) {}
123 |
124 | Ch Peek() const { return is_.Peek(); }
125 | Ch Take() { return is_.Take(); }
126 | size_t Tell() { return is_.Tell(); }
127 | Ch* PutBegin() { return is_.PutBegin(); }
128 | void Put(Ch ch) { is_.Put(ch); }
129 | void Flush() { is_.Flush(); }
130 | size_t PutEnd(Ch* ch) { return is_.PutEnd(ch); }
131 |
132 | // wrapper for MemoryStream
133 | const Ch* Peek4() const { return is_.Peek4(); }
134 |
135 | // wrapper for AutoUTFInputStream
136 | UTFType GetType() const { return is_.GetType(); }
137 | bool HasBOM() const { return is_.HasBOM(); }
138 |
139 | protected:
140 | InputStream& is_;
141 | };
142 |
143 | #if defined(_MSC_VER) && _MSC_VER <= 1800
144 | RAPIDJSON_DIAG_POP
145 | #endif
146 |
147 | ///////////////////////////////////////////////////////////////////////////////
148 | // StringStream
149 |
150 | //! Read-only string stream.
151 | /*! \note implements Stream concept
152 | */
153 | template
154 | struct GenericStringStream {
155 | typedef typename Encoding::Ch Ch;
156 |
157 | GenericStringStream(const Ch *src) : src_(src), head_(src) {}
158 |
159 | Ch Peek() const { return *src_; }
160 | Ch Take() { return *src_++; }
161 | size_t Tell() const { return static_cast(src_ - head_); }
162 |
163 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
164 | void Put(Ch) { RAPIDJSON_ASSERT(false); }
165 | void Flush() { RAPIDJSON_ASSERT(false); }
166 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
167 |
168 | const Ch* src_; //!< Current read position.
169 | const Ch* head_; //!< Original head of the string.
170 | };
171 |
172 | template
173 | struct StreamTraits > {
174 | enum { copyOptimization = 1 };
175 | };
176 |
177 | //! String stream with UTF8 encoding.
178 | typedef GenericStringStream > StringStream;
179 |
180 | ///////////////////////////////////////////////////////////////////////////////
181 | // InsituStringStream
182 |
183 | //! A read-write string stream.
184 | /*! This string stream is particularly designed for in-situ parsing.
185 | \note implements Stream concept
186 | */
187 | template
188 | struct GenericInsituStringStream {
189 | typedef typename Encoding::Ch Ch;
190 |
191 | GenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {}
192 |
193 | // Read
194 | Ch Peek() { return *src_; }
195 | Ch Take() { return *src_++; }
196 | size_t Tell() { return static_cast(src_ - head_); }
197 |
198 | // Write
199 | void Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; }
200 |
201 | Ch* PutBegin() { return dst_ = src_; }
202 | size_t PutEnd(Ch* begin) { return static_cast(dst_ - begin); }
203 | void Flush() {}
204 |
205 | Ch* Push(size_t count) { Ch* begin = dst_; dst_ += count; return begin; }
206 | void Pop(size_t count) { dst_ -= count; }
207 |
208 | Ch* src_;
209 | Ch* dst_;
210 | Ch* head_;
211 | };
212 |
213 | template
214 | struct StreamTraits > {
215 | enum { copyOptimization = 1 };
216 | };
217 |
218 | //! Insitu string stream with UTF8 encoding.
219 | typedef GenericInsituStringStream > InsituStringStream;
220 |
221 | RAPIDJSON_NAMESPACE_END
222 |
223 | #endif // RAPIDJSON_STREAM_H_
224 |
--------------------------------------------------------------------------------
/ChatServer/rapidjson/stringbuffer.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_STRINGBUFFER_H_
16 | #define RAPIDJSON_STRINGBUFFER_H_
17 |
18 | #include "stream.h"
19 | #include "internal/stack.h"
20 |
21 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
22 | #include // std::move
23 | #endif
24 |
25 | #include "internal/stack.h"
26 |
27 | #if defined(__clang__)
28 | RAPIDJSON_DIAG_PUSH
29 | RAPIDJSON_DIAG_OFF(c++98-compat)
30 | #endif
31 |
32 | RAPIDJSON_NAMESPACE_BEGIN
33 |
34 | //! Represents an in-memory output stream.
35 | /*!
36 | \tparam Encoding Encoding of the stream.
37 | \tparam Allocator type for allocating memory buffer.
38 | \note implements Stream concept
39 | */
40 | template
41 | class GenericStringBuffer {
42 | public:
43 | typedef typename Encoding::Ch Ch;
44 |
45 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}
46 |
47 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
48 | GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {}
49 | GenericStringBuffer& operator=(GenericStringBuffer&& rhs) {
50 | if (&rhs != this)
51 | stack_ = std::move(rhs.stack_);
52 | return *this;
53 | }
54 | #endif
55 |
56 | void Put(Ch c) { *stack_.template Push() = c; }
57 | void PutUnsafe(Ch c) { *stack_.template PushUnsafe() = c; }
58 | void Flush() {}
59 |
60 | void Clear() { stack_.Clear(); }
61 | void ShrinkToFit() {
62 | // Push and pop a null terminator. This is safe.
63 | *stack_.template Push() = '\0';
64 | stack_.ShrinkToFit();
65 | stack_.template Pop(1);
66 | }
67 |
68 | void Reserve(size_t count) { stack_.template Reserve(count); }
69 | Ch* Push(size_t count) { return stack_.template Push(count); }
70 | Ch* PushUnsafe(size_t count) { return stack_.template PushUnsafe(count); }
71 | void Pop(size_t count) { stack_.template Pop(count); }
72 |
73 | const Ch* GetString() const {
74 | // Push and pop a null terminator. This is safe.
75 | *stack_.template Push() = '\0';
76 | stack_.template Pop(1);
77 |
78 | return stack_.template Bottom();
79 | }
80 |
81 | //! Get the size of string in bytes in the string buffer.
82 | size_t GetSize() const { return stack_.GetSize(); }
83 |
84 | //! Get the length of string in Ch in the string buffer.
85 | size_t GetLength() const { return stack_.GetSize() / sizeof(Ch); }
86 |
87 | static const size_t kDefaultCapacity = 256;
88 | mutable internal::Stack stack_;
89 |
90 | private:
91 | // Prohibit copy constructor & assignment operator.
92 | GenericStringBuffer(const GenericStringBuffer&);
93 | GenericStringBuffer& operator=(const GenericStringBuffer&);
94 | };
95 |
96 | //! String buffer with UTF8 encoding
97 | typedef GenericStringBuffer > StringBuffer;
98 |
99 | template
100 | inline void PutReserve(GenericStringBuffer& stream, size_t count) {
101 | stream.Reserve(count);
102 | }
103 |
104 | template