Lines Matching defs:style

41   inline Style real_style(Style style) {
42 if (style != Style::native)
43 return style;
44 if (is_style_posix(style))
50 inline const char *separators(Style style) {
51 if (is_style_windows(style))
56 inline char preferred_separator(Style style) {
57 if (real_style(style) == Style::windows)
62 StringRef find_first_component(StringRef path, Style style) {
72 if (is_style_windows(style)) {
80 if ((path.size() > 2) && is_separator(path[0], style) &&
81 path[0] == path[1] && !is_separator(path[2], style)) {
83 size_t end = path.find_first_of(separators(style), 2);
88 if (is_separator(path[0], style))
92 size_t end = path.find_first_of(separators(style));
98 size_t filename_pos(StringRef str, Style style) {
99 if (str.size() > 0 && is_separator(str[str.size() - 1], style))
102 size_t pos = str.find_last_of(separators(style), str.size() - 1);
104 if (is_style_windows(style)) {
109 if (pos == StringRef::npos || (pos == 1 && is_separator(str[0], style)))
117 size_t root_dir_start(StringRef str, Style style) {
119 if (is_style_windows(style)) {
120 if (str.size() > 2 && str[1] == ':' && is_separator(str[2], style))
125 if (str.size() > 3 && is_separator(str[0], style) && str[0] == str[1] &&
126 !is_separator(str[2], style)) {
127 return str.find_first_of(separators(style), 2);
131 if (str.size() > 0 && is_separator(str[0], style))
140 size_t parent_path_end(StringRef path, Style style) {
141 size_t end_pos = filename_pos(path, style);
144 path.size() > 0 && is_separator(path[end_pos], style);
147 size_t root_dir_pos = root_dir_start(path, style);
150 is_separator(path[end_pos - 1], style))
227 const_iterator begin(StringRef path, Style style) {
230 i.Component = find_first_component(path, style);
232 i.S = style;
298 reverse_iterator rbegin(StringRef Path, Style style) {
302 I.S = style;
349 StringRef root_path(StringRef path, Style style) {
350 const_iterator b = begin(path, style), pos = b, e = end(path);
353 b->size() > 2 && is_separator((*b)[0], style) && (*b)[1] == (*b)[0];
354 bool has_drive = is_style_windows(style) && b->ends_with(":");
357 if ((++pos != e) && is_separator((*pos)[0], style)) {
365 // POSIX style root directory.
366 if (is_separator((*b)[0], style)) {
374 StringRef root_name(StringRef path, Style style) {
375 const_iterator b = begin(path, style), e = end(path);
378 b->size() > 2 && is_separator((*b)[0], style) && (*b)[1] == (*b)[0];
379 bool has_drive = is_style_windows(style) && b->ends_with(":");
391 StringRef root_directory(StringRef path, Style style) {
392 const_iterator b = begin(path, style), pos = b, e = end(path);
395 b->size() > 2 && is_separator((*b)[0], style) && (*b)[1] == (*b)[0];
396 bool has_drive = is_style_windows(style) && b->ends_with(":");
400 (++pos != e) && is_separator((*pos)[0], style)) {
404 // POSIX style root directory.
405 if (!has_net && is_separator((*b)[0], style)) {
414 StringRef relative_path(StringRef path, Style style) {
415 StringRef root = root_path(path, style);
419 void append(SmallVectorImpl<char> &path, Style style, const Twine &a,
434 !path.empty() && is_separator(path[path.size() - 1], style);
437 size_t loc = component.find_first_not_of(separators(style));
446 !component.empty() && is_separator(component[0], style);
448 !(path.empty() || has_root_name(component, style))) {
450 path.push_back(preferred_separator(style));
463 const_iterator end, Style style) {
465 path::append(path, style, *begin);
468 StringRef parent_path(StringRef path, Style style) {
469 size_t end_pos = parent_path_end(path, style);
475 void remove_filename(SmallVectorImpl<char> &path, Style style) {
476 size_t end_pos = parent_path_end(StringRef(path.begin(), path.size()), style);
482 Style style) {
489 if (pos != StringRef::npos && pos >= filename_pos(p, style))
501 Style style = Style::native) {
503 if (is_style_windows(style)) {
507 bool SepPath = is_separator(Path[I], style);
508 bool SepPrefix = is_separator(Prefix[I], style);
520 StringRef NewPrefix, Style style) {
525 if (!starts_with(OrigPath, OldPrefix, style))
541 void native(const Twine &path, SmallVectorImpl<char> &result, Style style) {
548 native(result, style);
551 void native(SmallVectorImpl<char> &Path, Style style) {
554 if (is_style_windows(style)) {
556 if (is_separator(Ch, style))
557 Ch = preferred_separator(style);
558 if (Path[0] == '~' && (Path.size() == 1 || is_separator(Path[1], style))) {
569 std::string convert_to_slash(StringRef path, Style style) {
570 if (is_style_posix(style))
578 StringRef filename(StringRef path, Style style) { return *rbegin(path, style); }
580 StringRef stem(StringRef path, Style style) {
581 StringRef fname = filename(path, style);
591 StringRef extension(StringRef path, Style style) {
592 StringRef fname = filename(path, style);
602 bool is_separator(char value, Style style) {
605 if (is_style_windows(style))
610 StringRef get_separator(Style style) {
611 if (real_style(style) == Style::windows)
616 bool has_root_name(const Twine &path, Style style) {
620 return !root_name(p, style).empty();
623 bool has_root_directory(const Twine &path, Style style) {
627 return !root_directory(p, style).empty();
630 bool has_root_path(const Twine &path, Style style) {
634 return !root_path(p, style).empty();
637 bool has_relative_path(const Twine &path, Style style) {
641 return !relative_path(p, style).empty();
644 bool has_filename(const Twine &path, Style style) {
648 return !filename(p, style).empty();
651 bool has_parent_path(const Twine &path, Style style) {
655 return !parent_path(p, style).empty();
658 bool has_stem(const Twine &path, Style style) {
662 return !stem(p, style).empty();
665 bool has_extension(const Twine &path, Style style) {
669 return !extension(p, style).empty();
672 bool is_absolute(const Twine &path, Style style) {
676 bool rootDir = has_root_directory(p, style);
677 bool rootName = is_style_posix(style) || has_root_name(p, style);
682 bool is_absolute_gnu(const Twine &path, Style style) {
688 if (!p.empty() && is_separator(p.front(), style))
691 if (is_style_windows(style)) {
700 bool is_relative(const Twine &path, Style style) {
701 return !is_absolute(path, style);
704 StringRef remove_leading_dotslash(StringRef Path, Style style) {
706 while (Path.size() > 2 && Path[0] == '.' && is_separator(Path[1], style)) {
708 while (Path.size() > 0 && is_separator(Path[0], style))
717 Style style) {
718 style = real_style(style);
724 StringRef root = path::root_path(remaining, style);
732 size_t next_slash = remaining.find_first_of(separators(style));
740 needs_change |= remaining.front() != preferred_separator(style);
766 make_preferred(buffer, style);
776 buffer += preferred_separator(style);