Change next_proto member type.
[chromium-blink-merge.git] / tools / gn / visibility.h
blob2e1b680fc48733551681a8b54fdff7ac22bc1ff8
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef TOOLS_GN_VISIBILITY_H_
6 #define TOOLS_GN_VISIBILITY_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/strings/string_piece.h"
12 #include "tools/gn/label_pattern.h"
13 #include "tools/gn/source_dir.h"
15 class Err;
16 class Item;
17 class Label;
18 class Scope;
19 class Value;
21 class Visibility {
22 public:
23 // Defaults to private visibility (only the current file).
24 Visibility();
25 ~Visibility();
27 // Set the visibility to the thing specified by the given value. On failure,
28 // returns false and sets the error.
29 bool Set(const SourceDir& current_dir, const Value& value, Err* err);
31 // Sets the visibility to be public.
32 void SetPublic();
34 // Sets the visibility to be private to the given directory.
35 void SetPrivate(const SourceDir& current_dir);
37 // Returns true if the target with the given label can depend on one with the
38 // current visibility.
39 bool CanSeeMe(const Label& label) const;
41 // Returns a string listing the visibility. |indent| number of spaces will
42 // be added on the left side of the output. If |include_brackets| is set, the
43 // result will be wrapped in "[ ]" and the contents further indented. The
44 // result will end in a newline.
45 std::string Describe(int indent, bool include_brackets) const;
47 // Helper function to check visibility between the given two items. If
48 // to is invisible to from, returns false and sets the error.
49 static bool CheckItemVisibility(const Item* from, const Item* to, Err* err);
51 // Helper function to fill an item's visibility from the "visibility" value
52 // in the current scope.
53 static bool FillItemVisibility(Item* item, Scope* scope, Err* err);
55 private:
56 std::vector<LabelPattern> patterns_;
58 DISALLOW_COPY_AND_ASSIGN(Visibility);
61 #endif // TOOLS_GN_VISIBILITY_H_