Lines Matching defs:style
40 inline Style real_style(Style style) {
41 if (style != Style::native)
42 return style;
43 if (is_style_posix(style))
49 inline const char *separators(Style style) {
50 if (is_style_windows(style))
55 inline char preferred_separator(Style style) {
56 if (real_style(style) == Style::windows)
61 StringRef find_first_component(StringRef path, Style style) {
71 if (is_style_windows(style)) {
79 if ((path.size() > 2) && is_separator(path[0], style) &&
80 path[0] == path[1] && !is_separator(path[2], style)) {
82 size_t end = path.find_first_of(separators(style), 2);
87 if (is_separator(path[0], style))
91 size_t end = path.find_first_of(separators(style));
97 size_t filename_pos(StringRef str, Style style) {
98 if (str.size() > 0 && is_separator(str[str.size() - 1], style))
101 size_t pos = str.find_last_of(separators(style), str.size() - 1);
103 if (is_style_windows(style)) {
108 if (pos == StringRef::npos || (pos == 1 && is_separator(str[0], style)))
116 size_t root_dir_start(StringRef str, Style style) {
118 if (is_style_windows(style)) {
119 if (str.size() > 2 && str[1] == ':' && is_separator(str[2], style))
124 if (str.size() > 3 && is_separator(str[0], style) && str[0] == str[1] &&
125 !is_separator(str[2], style)) {
126 return str.find_first_of(separators(style), 2);
130 if (str.size() > 0 && is_separator(str[0], style))
139 size_t parent_path_end(StringRef path, Style style) {
140 size_t end_pos = filename_pos(path, style);
143 path.size() > 0 && is_separator(path[end_pos], style);
146 size_t root_dir_pos = root_dir_start(path, style);
149 is_separator(path[end_pos - 1], style))
226 const_iterator begin(StringRef path, Style style) {
229 i.Component = find_first_component(path, style);
231 i.S = style;
297 reverse_iterator rbegin(StringRef Path, Style style) {
301 I.S = style;
348 StringRef root_path(StringRef path, Style style) {
349 const_iterator b = begin(path, style), pos = b, e = end(path);
352 b->size() > 2 && is_separator((*b)[0], style) && (*b)[1] == (*b)[0];
353 bool has_drive = is_style_windows(style) && b->ends_with(":");
356 if ((++pos != e) && is_separator((*pos)[0], style)) {
364 // POSIX style root directory.
365 if (is_separator((*b)[0], style)) {
373 StringRef root_name(StringRef path, Style style) {
374 const_iterator b = begin(path, style), e = end(path);
377 b->size() > 2 && is_separator((*b)[0], style) && (*b)[1] == (*b)[0];
378 bool has_drive = is_style_windows(style) && b->ends_with(":");
390 StringRef root_directory(StringRef path, Style style) {
391 const_iterator b = begin(path, style), pos = b, e = end(path);
394 b->size() > 2 && is_separator((*b)[0], style) && (*b)[1] == (*b)[0];
395 bool has_drive = is_style_windows(style) && b->ends_with(":");
399 (++pos != e) && is_separator((*pos)[0], style)) {
403 // POSIX style root directory.
404 if (!has_net && is_separator((*b)[0], style)) {
413 StringRef relative_path(StringRef path, Style style) {
414 StringRef root = root_path(path, style);
418 void append(SmallVectorImpl<char> &path, Style style, const Twine &a,
433 !path.empty() && is_separator(path[path.size() - 1], style);
436 size_t loc = component.find_first_not_of(separators(style));
445 !component.empty() && is_separator(component[0], style);
447 !(path.empty() || has_root_name(component, style))) {
449 path.push_back(preferred_separator(style));
462 const_iterator end, Style style) {
464 path::append(path, style, *begin);
467 StringRef parent_path(StringRef path, Style style) {
468 size_t end_pos = parent_path_end(path, style);
474 void remove_filename(SmallVectorImpl<char> &path, Style style) {
475 size_t end_pos = parent_path_end(StringRef(path.begin(), path.size()), style);
481 Style style) {
488 if (pos != StringRef::npos && pos >= filename_pos(p, style))
500 Style style = Style::native) {
502 if (is_style_windows(style)) {
506 bool SepPath = is_separator(Path[I], style);
507 bool SepPrefix = is_separator(Prefix[I], style);
519 StringRef NewPrefix, Style style) {
524 if (!starts_with(OrigPath, OldPrefix, style))
540 void native(const Twine &path, SmallVectorImpl<char> &result, Style style) {
547 native(result, style);
550 void native(SmallVectorImpl<char> &Path, Style style) {
553 if (is_style_windows(style)) {
555 if (is_separator(Ch, style))
556 Ch = preferred_separator(style);
557 if (Path[0] == '~' && (Path.size() == 1 || is_separator(Path[1], style))) {
568 std::string convert_to_slash(StringRef path, Style style) {
569 if (is_style_posix(style))
577 StringRef filename(StringRef path, Style style) { return *rbegin(path, style); }
579 StringRef stem(StringRef path, Style style) {
580 StringRef fname = filename(path, style);
590 StringRef extension(StringRef path, Style style) {
591 StringRef fname = filename(path, style);
601 bool is_separator(char value, Style style) {
604 if (is_style_windows(style))
609 StringRef get_separator(Style style) {
610 if (real_style(style) == Style::windows)
615 bool has_root_name(const Twine &path, Style style) {
619 return !root_name(p, style).empty();
622 bool has_root_directory(const Twine &path, Style style) {
626 return !root_directory(p, style).empty();
629 bool has_root_path(const Twine &path, Style style) {
633 return !root_path(p, style).empty();
636 bool has_relative_path(const Twine &path, Style style) {
640 return !relative_path(p, style).empty();
643 bool has_filename(const Twine &path, Style style) {
647 return !filename(p, style).empty();
650 bool has_parent_path(const Twine &path, Style style) {
654 return !parent_path(p, style).empty();
657 bool has_stem(const Twine &path, Style style) {
661 return !stem(p, style).empty();
664 bool has_extension(const Twine &path, Style style) {
668 return !extension(p, style).empty();
671 bool is_absolute(const Twine &path, Style style) {
675 bool rootDir = has_root_directory(p, style);
676 bool rootName = is_style_posix(style) || has_root_name(p, style);
681 bool is_absolute_gnu(const Twine &path, Style style) {
687 if (!p.empty() && is_separator(p.front(), style))
690 if (is_style_windows(style)) {
699 bool is_relative(const Twine &path, Style style) {
700 return !is_absolute(path, style);
703 StringRef remove_leading_dotslash(StringRef Path, Style style) {
705 while (Path.size() > 2 && Path[0] == '.' && is_separator(Path[1], style)) {
707 while (Path.size() > 0 && is_separator(Path[0], style))
716 Style style) {
717 style = real_style(style);
723 StringRef root = path::root_path(remaining, style);
731 size_t next_slash = remaining.find_first_of(separators(style));
739 needs_change |= remaining.front() != preferred_separator(style);
765 make_preferred(buffer, style);
775 buffer += preferred_separator(style);