Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
d02a99d9
Commit
d02a99d9
authored
Aug 06, 2019
by
Sebastian Holtermann
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autogen: Modernize code to use cm::string_view for the info writer
parent
bbf4a577
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
27 deletions
+23
-27
Source/cmQtAutoGenInitializer.cxx
Source/cmQtAutoGenInitializer.cxx
+14
-19
Source/cmQtAutoGenInitializer.h
Source/cmQtAutoGenInitializer.h
+9
-8
No files found.
Source/cmQtAutoGenInitializer.cxx
View file @
d02a99d9
...
...
@@ -156,30 +156,27 @@ std::string cmQtAutoGenInitializer::InfoWriter::ListJoin(IT it_begin,
return
res
;
}
std
::
string
cmQtAutoGenInitializer
::
InfoWriter
::
ConfigKey
(
c
onst
char
*
key
,
std
::
string
const
&
config
)
inline
std
::
string
cmQtAutoGenInitializer
::
InfoWriter
::
ConfigKey
(
c
m
::
string_view
key
,
std
::
string
const
&
config
)
{
std
::
string
ckey
=
key
;
ckey
+=
'_'
;
ckey
+=
config
;
return
ckey
;
return
cmStrCat
(
key
,
"_"
,
config
);
}
void
cmQtAutoGenInitializer
::
InfoWriter
::
Write
(
c
onst
char
*
key
,
void
cmQtAutoGenInitializer
::
InfoWriter
::
Write
(
c
m
::
string_view
key
,
std
::
string
const
&
value
)
{
Ofs_
<<
"set("
<<
key
<<
" "
<<
cmOutputConverter
::
EscapeForCMake
(
value
)
<<
")
\n
"
;
};
void
cmQtAutoGenInitializer
::
InfoWriter
::
WriteUInt
(
c
onst
char
*
key
,
void
cmQtAutoGenInitializer
::
InfoWriter
::
WriteUInt
(
c
m
::
string_view
key
,
unsigned
int
value
)
{
Ofs_
<<
"set("
<<
key
<<
" "
<<
value
<<
")
\n
"
;
};
template
<
class
C
>
void
cmQtAutoGenInitializer
::
InfoWriter
::
WriteStrings
(
c
onst
char
*
key
,
void
cmQtAutoGenInitializer
::
InfoWriter
::
WriteStrings
(
c
m
::
string_view
key
,
C
const
&
container
)
{
Ofs_
<<
"set("
<<
key
<<
"
\"
"
...
...
@@ -187,31 +184,29 @@ void cmQtAutoGenInitializer::InfoWriter::WriteStrings(const char* key,
}
void
cmQtAutoGenInitializer
::
InfoWriter
::
WriteConfig
(
c
onst
char
*
key
,
std
::
map
<
std
::
string
,
std
::
string
>
const
&
map
)
c
m
::
string_view
key
,
std
::
map
<
std
::
string
,
std
::
string
>
const
&
map
)
{
for
(
auto
const
&
item
:
map
)
{
Write
(
ConfigKey
(
key
,
item
.
first
)
.
c_str
()
,
item
.
second
);
Write
(
ConfigKey
(
key
,
item
.
first
),
item
.
second
);
}
};
template
<
class
C
>
void
cmQtAutoGenInitializer
::
InfoWriter
::
WriteConfigStrings
(
c
onst
char
*
key
,
std
::
map
<
std
::
string
,
C
>
const
&
map
)
c
m
::
string_view
key
,
std
::
map
<
std
::
string
,
C
>
const
&
map
)
{
for
(
auto
const
&
item
:
map
)
{
WriteStrings
(
ConfigKey
(
key
,
item
.
first
)
.
c_str
()
,
item
.
second
);
WriteStrings
(
ConfigKey
(
key
,
item
.
first
),
item
.
second
);
}
}
void
cmQtAutoGenInitializer
::
InfoWriter
::
WriteNestedLists
(
c
onst
char
*
key
,
std
::
vector
<
std
::
vector
<
std
::
string
>>
const
&
lists
)
c
m
::
string_view
key
,
std
::
vector
<
std
::
vector
<
std
::
string
>>
const
&
lists
)
{
std
::
vector
<
std
::
string
>
seplist
;
for
(
const
std
::
vector
<
std
::
string
>&
list
:
lists
)
{
std
::
string
blist
=
"{"
;
blist
+=
ListJoin
(
list
.
begin
(),
list
.
end
());
blist
+=
"}"
;
seplist
.
push_back
(
std
::
move
(
blist
));
seplist
.
reserve
(
lists
.
size
());
for
(
std
::
vector
<
std
::
string
>
const
&
list
:
lists
)
{
seplist
.
push_back
(
cmStrCat
(
"{"
,
ListJoin
(
list
.
begin
(),
list
.
end
()),
"}"
));
}
Write
(
key
,
cmJoin
(
seplist
,
cmQtAutoGen
::
ListSep
));
};
...
...
Source/cmQtAutoGenInitializer.h
View file @
d02a99d9
...
...
@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmGeneratedFileStream.h"
#include "cmQtAutoGen.h"
#include "cm_string_view.hxx"
#include <map>
#include <memory>
...
...
@@ -85,24 +86,24 @@ public:
/// @return True if the file is open
explicit
operator
bool
()
const
{
return
static_cast
<
bool
>
(
Ofs_
);
}
void
Write
(
c
onst
char
*
text
)
{
Ofs_
<<
text
;
}
void
Write
(
c
onst
char
*
key
,
std
::
string
const
&
value
);
void
WriteUInt
(
c
onst
char
*
key
,
unsigned
int
value
);
void
Write
(
c
m
::
string_view
text
)
{
Ofs_
<<
text
;
}
void
Write
(
c
m
::
string_view
,
std
::
string
const
&
value
);
void
WriteUInt
(
c
m
::
string_view
,
unsigned
int
value
);
template
<
class
C
>
void
WriteStrings
(
c
onst
char
*
key
,
C
const
&
container
);
void
WriteConfig
(
c
onst
char
*
key
,
void
WriteStrings
(
c
m
::
string_view
,
C
const
&
container
);
void
WriteConfig
(
c
m
::
string_view
,
std
::
map
<
std
::
string
,
std
::
string
>
const
&
map
);
template
<
class
C
>
void
WriteConfigStrings
(
c
onst
char
*
key
,
void
WriteConfigStrings
(
c
m
::
string_view
,
std
::
map
<
std
::
string
,
C
>
const
&
map
);
void
WriteNestedLists
(
c
onst
char
*
key
,
void
WriteNestedLists
(
c
m
::
string_view
,
std
::
vector
<
std
::
vector
<
std
::
string
>>
const
&
lists
);
private:
template
<
class
IT
>
static
std
::
string
ListJoin
(
IT
it_begin
,
IT
it_end
);
static
std
::
string
ConfigKey
(
c
onst
char
*
key
,
std
::
string
const
&
config
);
static
std
::
string
ConfigKey
(
c
m
::
string_view
,
std
::
string
const
&
config
);
private:
cmGeneratedFileStream
Ofs_
;
...
...
Brad King
@brad.king
mentioned in commit
7891f69c
·
Aug 09, 2019
mentioned in commit
7891f69c
mentioned in commit 7891f69c67122eca2cba9f2c58fa0f1d49eba9bc
Toggle commit list
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