1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmNewLineStyle.h"
7 cmNewLineStyle::cmNewLineStyle() = default;
9 bool cmNewLineStyle::IsValid() const
11 return this->NewLineStyle != Invalid;
14 bool cmNewLineStyle::ReadFromArguments(const std::vector<std::string>& args,
15 std::string& errorString)
17 this->NewLineStyle = Invalid;
19 for (size_t i = 0; i < args.size(); i++) {
20 if (args[i] == "NEWLINE_STYLE") {
21 size_t const styleIndex = i + 1;
22 if (args.size() > styleIndex) {
23 std::string const& eol = args[styleIndex];
24 if (eol == "LF" || eol == "UNIX") {
25 this->NewLineStyle = LF;
28 if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") {
29 this->NewLineStyle = CRLF;
32 errorString = "NEWLINE_STYLE sets an unknown style, only LF, "
33 "CRLF, UNIX, DOS, and WIN32 are supported";
36 errorString = "NEWLINE_STYLE must set a style: "
37 "LF, CRLF, UNIX, DOS, or WIN32";
44 std::string cmNewLineStyle::GetCharacters() const
46 switch (this->NewLineStyle) {
57 void cmNewLineStyle::SetStyle(Style style)
59 this->NewLineStyle = style;
62 cmNewLineStyle::Style cmNewLineStyle::GetStyle() const
64 return this->NewLineStyle;