Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/StoneToolbox.cpp @ 2174:2410a171ebfb
refactoring using DicomWebDataset and OrthancNativeDataset
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 Oct 2024 21:52:34 +0200 |
parents | 32bfccdc030f |
children |
rev | line source |
---|---|
2153
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * the License, or (at your option) any later version. |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * Lesser General Public License for more details. |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * License along with this program. If not, see |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "StoneToolbox.h" |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 namespace OrthancStone |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 { |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 namespace StoneToolbox |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 std::string JoinUrl(const std::string& base, |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 const std::string& path) |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 { |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 size_t end = base.size(); |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 while (end > 0 && |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 base[end - 1] == '/') |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 { |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 end--; |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 } |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 size_t start = 0; |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 while (start < path.size() && |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 path[start] == '/') |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 start++; |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 } |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 return base.substr(0, end) + "/" + path.substr(start); |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 } |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 } |
32bfccdc030f
consistency in the way URLs are concatenated
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 } |