Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
b048aec5
Commit
b048aec5
authored
Jul 08, 2020
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
version add force_update
parent
5fc667db
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
1 deletion
+52
-1
version.h
jlib/util/version.h
+8
-1
test_version.cpp
test/test_version/test_version.cpp
+21
-0
test_version.vcxproj
test/test_version/test_version.vcxproj
+6
-0
test_version.vcxproj.filters
test/test_version/test_version.vcxproj.filters
+17
-0
No files found.
jlib/util/version.h
View file @
b048aec5
...
...
@@ -156,12 +156,16 @@ struct DownLoadLink {
struct
Release
{
Branch
branch
=
Branch
::
InvalidBranch
;
Version
version
=
{};
bool
force_update
=
false
;
//! 版本更新说明
std
::
string
change
=
{};
std
::
vector
<
DownLoadLink
>
dllinks
=
{};
std
::
string
toString
()
const
{
auto
s
=
std
::
string
(
branchName
(
branch
))
+
" "
+
version
.
toString
()
+
"
\n
change="
+
change
+
"
\n
download_links=
\n
"
;
auto
s
=
std
::
string
(
branchName
(
branch
))
+
" "
+
version
.
toString
()
+
"
\n
force_update="
+
(
force_update
?
"true"
:
"false"
)
+
"
\n
change="
+
change
+
"
\n
download_links=
\n
"
;
if
(
!
dllinks
.
empty
())
{
for
(
const
auto
&
link
:
dllinks
)
{
s
+=
link
.
host
+
" : link="
+
link
.
link
+
" md5="
+
link
.
md5
+
"
\n
"
;
}
}
else
{
s
+=
"empty"
;
}
...
...
@@ -196,6 +200,7 @@ struct LatestRelease {
* {
* "test": {
* "version": "2.2.11.13262",
* "force_update": true,
* "release_note": "测试;",
* "download_links": {
* "local": {
...
...
@@ -206,6 +211,7 @@ struct LatestRelease {
* },
* "stable": {
* "version": "2.2.12.13282",
* "force_update": false,
* "release_note": "测试稳定",
* "download_links": {
* "local": {
...
...
@@ -230,6 +236,7 @@ int resolveLatestRelease(const JsonValue& value, LatestRelease& latestRelease) {
const
auto
&
detail
=
value
[
branchName
(
branch
)];
Release
release
;
release
.
branch
=
branch
;
release
.
force_update
=
detail
.
isMember
(
"force_update"
)
?
detail
[
"force_update"
].
asBool
()
:
false
;
release
.
version
=
detail
[
"version"
].
asString
();
release
.
change
=
detail
[
"release_note"
].
asString
();
if
(
detail
[
"download_links"
].
isMember
(
"local"
))
{
...
...
test/test_version/test_version.cpp
View file @
b048aec5
#include "../../jlib/util/version.h"
#include "../../jlib/util/curl_wrapper.h"
#include "../../jlib/3rdparty/json/jsoncpp/json.h"
#include <stdio.h>
#include <assert.h>
...
...
@@ -35,5 +37,24 @@ int main()
assert
(
!
(
v4
<
v3
));
assert
(
!
(
v4
<=
v3
));
Curl
curl
;
curl
.
init
();
auto
url
=
"https://jcenter.captainwong.cn/api/v1/apps/latest?name=test"
;
curl
.
get
(
url
);
printf
(
"HTTP %ld
\n
"
,
curl
.
lastHttpCode
());
printf
(
"error %d
\n
"
,
curl
.
lastError
());
printf
(
"error msg %s
\n
"
,
curl
.
lastErrorMsg
().
data
());
printf
(
"%s
\n
"
,
curl
.
lastHttpContent
().
data
());
Json
::
Value
value
;
Json
::
Reader
parser
;
if
(
parser
.
parse
(
curl
.
lastHttpContent
(),
value
))
{
LatestRelease
latestRelease
;
resolveLatestRelease
(
value
,
latestRelease
);
printf
(
"%s
\n
"
,
latestRelease
.
toString
().
data
());
}
system
(
"pause"
);
}
test/test_version/test_version.vcxproj
View file @
b048aec5
...
...
@@ -124,8 +124,14 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_reader.cpp"
/>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_value.cpp"
/>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_writer.cpp"
/>
<ClCompile
Include=
"test_version.cpp"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
...
...
test/test_version/test_version.vcxproj.filters
View file @
b048aec5
...
...
@@ -13,10 +13,27 @@
<UniqueIdentifier>
{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
</UniqueIdentifier>
<Extensions>
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
</Extensions>
</Filter>
<Filter
Include=
"jsoncpp"
>
<UniqueIdentifier>
{5d498929-b47b-463e-a7d5-4c71896ef989}
</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"test_version.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_reader.cpp"
>
<Filter>
jsoncpp
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_value.cpp"
>
<Filter>
jsoncpp
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json_writer.cpp"
>
<Filter>
jsoncpp
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\..\jlib\3rdparty\json\jsoncpp\json.h"
>
<Filter>
jsoncpp
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment