coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
hash_include.h
Go to the documentation of this file.
1 #ifndef HASH_INCLUDE_H
2 #define HASH_INCLUDE_H
3 #pragma once
4 /***************************************************************************
5  * Copyright (C) 2007-2013 Mike Kinghan, imk@burroingroingjoing.com *
6  * All rights reserved. *
7  * *
8  * Contributed originally by Mike Kinghan, imk@burroingroingjoing.com *
9  * *
10  * Redistribution and use in source and binary forms, with or without *
11  * modification, are permitted provided that the following conditions *
12  * are met: *
13  * *
14  * Redistributions of source code must retain the above copyright *
15  * notice, this list of conditions and the following disclaimer. *
16  * *
17  * Redistributions in binary form must reproduce the above copyright *
18  * notice, this list of conditions and the following disclaimer in the *
19  * documentation and/or other materials provided with the distribution. *
20  * *
21  * Neither the name of Mike Kinghan nor the names of its contributors *
22  * may be used to endorse or promote products derived from this software *
23  * without specific prior written permission. *
24  * *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS *
32  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED *
33  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,*
34  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
35  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
36  * DAMAGE. *
37  * *
38  **************************************************************************/
39 #include "prohibit.h"
40 #include "reference.h"
41 #include "directive.h"
42 
47 struct reference;
48 
50 struct hash_include : private no_copy {
51 
52  hash_include() = delete;
53 
58  explicit hash_include(std::string const & arg)
59  : _directive(arg) {}
60 
68  : _directive(read(chew)) {}
69 
70 
77  std::shared_ptr<reference> symbolic_argument() const {
78  return _ref;
79  }
80 
88  std::string filename() const {
89  return _ref ? _ref->expansion() : _directive.argument();
90  }
91 
92 
98  bool system_header() const {
99  return filename()[0] == '<';
100  }
101 
111  bool local_header() const {
112  return filename()[0] == '\"';
113  }
114 
116  bool valid() const;
117 
118 
120  void report();
121 
122 private:
123 
131  std::string read(chewer<parse_buffer> & chew);
132 
136  std::shared_ptr<reference> _ref;
139 
140 };
141 
142 #endif /* EOF*/
bool local_header() const
Test whether the #include specifies a local header, i.e. "headername".
Definition: hash_include.h:111
void report()
Report the #include directive.
struct hash_include encapsulates an #include directive.
Definition: hash_include.h:50
std::shared_ptr< reference > _ref
A pointer to the #include argument as a reference, if it one, else a null pointer.
Definition: hash_include.h:136
bool system_header() const
Test whether the #include specifies a system header, i.e. <headername>
Definition: hash_include.h:98
A utility class to prevent copying of containing class.
Definition: prohibit.h:68
std::string filename() const
Return the header file expression.
Definition: hash_include.h:88
bool valid() const
Say whether the #include directive is valid.
hash_include(std::string const &arg)
Explicitly construct from the argument of an #include directive.
Definition: hash_include.h:58
std::shared_ptr< reference > symbolic_argument() const
Say whether the body of an #include directive is a macro-reference.
Definition: hash_include.h:77
`template struct chewer<CharSeq> is a cursor-like type that is associated with a character-sequence t...
Definition: chew.h:248
std::string const & argument() const
Get the body of the directive.
Definition: directive.h:158
std::string read(chewer< parse_buffer > &chew)
Read the body of an #include directive.
hash_include(chewer< parse_buffer > &chew)
Explicitly construct from the argument of an #include directive.
Definition: hash_include.h:67
directive< HASH_INCLUDE > _directive
The member handles reporting the #include directive.
Definition: hash_include.h:138