Revision control
Copy as Markdown
<svg
viewBox="-410 -30 540 540"
version="1.1"
<style>
svg path.node { fill: inherit; stroke: inherit; }
svg .node-style { fill: #56E59D; stroke: #333333; }
svg #footnotes { fill: #333333; }
svg #arrow-tip { fill: #333333; }
svg .arrow-style { stroke: #333333; }
svg .text-style { font: 12px arial; fill: #333333; }
svg .text-style-arrows { font: 12px arial; fill: #333333; }
svg .small-style { font: 8px arial; fill: #333333; }
svg.dark .node-style { fill: #1A8550; stroke: #F2F2F2; }
svg.dark #footnotes { fill: #F2F2F2; }
svg.dark #arrow-tip { fill: #F2F2F2; }
svg.dark .arrow-style { stroke: #F2F2F2; }
svg.dark .text-style { font: 12px arial; fill: #F2F2F2; }
svg.dark .text-style-arrows { font: 12px arial; fill: #F2F2F2; }
svg.dark .small-style { font: 8px arial; fill: #F2F2F2; }
[data-theme="dark"] svg .node-style { fill: #1A8550; stroke: #F2F2F2; }
[data-theme="dark"] svg #footnotes { fill: #F2F2F2; }
[data-theme="dark"] svg #arrow-tip { fill: #F2F2F2; }
[data-theme="dark"] svg .arrow-style { stroke: #F2F2F2; }
[data-theme="dark"] svg .text-style { font: 12px arial; fill: #F2F2F2; }
[data-theme="dark"] svg .text-style-arrows { font: 12px arial; fill: #F2F2F2; }
[data-theme="dark"] svg .small-style { font: 8px arial; fill: #F2F2F2; }
[data-theme="light"] svg .node-style { fill: #56E59D; stroke: #333333; }
[data-theme="light"] svg #footnotes { fill: #333333; }
[data-theme="light"] svg #arrow-tip { fill: #333333; }
[data-theme="light"] svg .arrow-style { stroke: #333333; }
[data-theme="light"] svg .text-style { font: 12px arial; fill: #333333; }
[data-theme="light"] svg .text-style-arrows { font: 12px arial; fill: #333333; }
[data-theme="light"] svg .small-style { font: 8px arial; fill: #333333; }
</style>
<defs>
<path id="raute" class="node"
stroke-width="1px"
d="m 0 -40 L 80 0 L 0 40 L -80 0 z" />
<path id="lozenge" class="node"
stroke-width="1px"
d="M -60,-20
h 120
a 20,20 0 0 1 20,20
v 0
a 20,20 0 0 1 -20,20
h -120
a 20,20 0 0 1 -20,-20
v 0
a 20,20 0 0 1 20,-20
Z"/>
<path id="lozenge_small" class="node"
stroke-width="1px"
d="M -40,-20
h 80
a 20,20 0 0 1 20,20
v 0
a 20,20 0 0 1 -20,20
h -80
a 20,20 0 0 1 -20,-20
v 0
a 20,20 0 0 1 20,-20
Z"/>
<marker
id="triangle"
viewBox="0 0 10 10"
refX="1"
refY="5"
markerUnits="strokeWidth"
markerWidth="10"
markerHeight="10"
orient="auto">
<path id="arrow-tip" d="M 0 0 L 10 5 L 0 10 z" fill="#333333" />
</marker>
</defs>
<g id="start" transform="translate(-160, 0)">
<use class="node-style" href="#lozenge" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-3"
class="text-style">Choosing a string class</text>
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="11"
class="text-style">for calling Qt functions</text>
</g>
<g id="param_or_return" transform="translate(-160, 100)">
<use class="node-style" href="#raute" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-10" class="text-style">Is your string</text>
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="4" class="text-style">known at compile time</text>
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="18" class="text-style">(a literal)?</text>
</g>
<g id="ref_or_perm" transform="translate(-320, 200)">
<use class="node-style" href="#raute" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-5" class="text-style">Is the parameter a</text>
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="9" class="text-style">QString or a Q*View?</text>
</g>
<g id="ref_or_perm" transform="translate(-320, 330)">
<use class="node-style" href="#raute" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-3" class="text-style">Has the parameter a</text>
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="11" class="text-style">preferred² encoding?</text>
</g>
<g id="make_copy" transform="translate(-100, 330)">
<use class="node-style" href="#raute" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-3" class="text-style">Is your string</text>
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="11" class="text-style">ASCII?</text>
</g>
<g transform="translate(40, 150)">
<use class="node-style" href="#lozenge" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-3" class="text-style">QString¹</text>
<text font-size="8" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="11" class="small-style">or any other owning string</text>
</g>
<g transform="translate(-100, 200)">
<use class="node-style" href="#lozenge" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-3" class="text-style">QStringLiteral</text>
<text font-size="8" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="11" class="small-style">same as u"foo"_s</text>
</g>
<g transform="translate(40, 390)">
<use class="node-style" href="#lozenge" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-3" class="text-style">QLatin1StringView</text>
<text font-size="8" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="11" class="small-style">create with "foo"_L1</text>
</g>
<g transform="translate(-100, 430)">
<use class="node-style" href="#lozenge" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-3" class="text-style">QStringView</text>
<text font-size="8" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="11" class="small-style">create with u"foo"</text>
</g>
<g transform="translate(-320, 430)">
<use class="node-style" href="#lozenge" fill="#56E59D" stroke="#333333" />
<text font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="-6" class="text-style">Q*StringView</text>
<text font-size="8" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="5" class="small-style">of the preferred encoding,</text>
<text font-size="8" font-family="Arial" fill="#333333"
text-anchor="middle" x="0" y="15" class="small-style">create with u"foo", u8"foo" or "foo"_L1</text>
</g>
<g transform="translate(-160, 20)">
<path
fill="none" stroke="#333333" marker-end="url(#triangle)"
class="arrow-style"
d="M 0 0 l 0 30" />
</g>
<g transform="translate(-240, 100)">
<path
fill="none" stroke="#333333" marker-end="url(#triangle)"
class="arrow-style"
d="M 0 0 l -80 0 l 0 50" />
<text x="-40" y="-5"
font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" dominant-baseline="auto"
class="text-style-arrows">
yes
</text>
</g>
<g transform="translate(-80, 100)">
<path
fill="none" stroke="#333333" marker-end="url(#triangle)"
class="arrow-style"
d="M 0 0 l 120 0 l 0 20" />
<text x="60" y="-5"
font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" dominant-baseline="auto"
class="text-style-arrows">
no
</text>
</g>
<g transform="translate(-240, 200)">
<path
fill="none" stroke="#333333" marker-end="url(#triangle)"
class="arrow-style"
d="M 0 0 l 50 0 " />
<text x="25" y="-5"
font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" dominant-baseline="auto"
class="text-style-arrows">
QString
</text>
</g>
<g transform="translate(-320, 240)">
<path
fill="none" stroke="#333333" marker-end="url(#triangle)"
class="arrow-style"
d="M 0 0 l 0 40 " />
<text x="5" y="20"
font-size="12" font-family="Arial" fill="#333333"
text-anchor="left" dominant-baseline="middle"
class="text-style-arrows">
Q*View
</text>
</g>
<g transform="translate(-240, 330)">
<path
fill="none" stroke="#333333" marker-end="url(#triangle)"
class="arrow-style"
d="M 0 0 l 50 0" />
<text x="30" y="-5"
font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" dominant-baseline="auto"
class="text-style-arrows">
no
</text>
</g>
<g transform="translate(-320, 370)">
<path
fill="none" stroke="#333333" marker-end="url(#triangle)"
class="arrow-style"
d="M 0 0 l 0 30" />
<text x="5" y="15"
font-size="12" font-family="Arial" fill="#333333"
text-anchor="left" dominant-baseline="middle"
class="text-style-arrows">
yes
</text>
</g>
<g transform="translate(-20, 330)">
<path
fill="none" stroke="#333333" marker-end="url(#triangle)"
class="arrow-style"
d="M 0 0 l 60 0 l 0 30" />
<text x="30" y="-5"
font-size="12" font-family="Arial" fill="#333333"
text-anchor="middle" dominant-baseline="auto"
class="text-style-arrows">
yes
</text>
</g>
<g transform="translate(-100, 370)">
<path
fill="none" stroke="#333333" marker-end="url(#triangle)"
class="arrow-style"
d="M 0 0 l 0 30" />
<text x="5" y="15"
font-size="12" font-family="Arial" fill="#333333"
text-anchor="left" dominant-baseline="middle"
class="text-style-arrows">
no
</text>
</g>
<g transform="translate(-405, 465)">
<text id="footnotes" x="5" y="5"
font-size="9" font-family="Arial" fill="#333333"
text-anchor="left">1:</text>
<text id="footnotes" x="15" y="5"
font-size="9" font-family="Arial" fill="#333333"
text-anchor="left">An owning string is required to assemble or store
a string at runtime, if it is not known at compile time. This can be
QString or any</text>
<text id="footnotes" x="15" y="15"
font-size="9" font-family="Arial" fill="#333333"
text-anchor="left">other owning string, such as std::string. The correct
choice depends on the required encoding.</text>
<text id="footnotes" x="5" y="29"
font-size="9" font-family="Arial" fill="#333333"
text-anchor="left">2:</text>
<text id="footnotes" x="15" y="29"
font-size="9" font-family="Arial" fill="#333333"
text-anchor="left">Some functions are more effective when using the
preferred encoding. For example, QUtf8StringView::compare is fastest
with</text>
<text id="footnotes" x="15" y="39"
font-size="9" font-family="Arial" fill="#333333"
text-anchor="left">QUtf8StringView. If you are unsure, proceed as
if there were no preferred encoding.</text>
</g>
</svg>