Namespace ostream and endl into std::
[oweals/cde.git] / cde / programs / dtsearchpath / dtsp / SearchPath.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: SearchPath.h /main/4 1996/03/27 14:39:41 barstow $ */
24 /*******************************************************************
25 **  (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992, 1993.
26 **  All rights are reserved.  Copying or other reproduction of this
27 **  program except for archival purposes is prohibited without prior
28 **  written consent of Hewlett-Packard Company.
29 ********************************************************************
30 ****************************<+>*************************************/
31
32 #ifndef _SEARCHPATH_H_
33 #define _SEARCHPATH_H_
34
35 #include "Environ.h"
36 #include "cstring.h"
37 #if defined(linux)
38 #include <iostream>
39 #else
40 #include <iostream.h>
41 #endif
42 #include <stdio.h>
43
44 class SearchPath {
45  public:
46   SearchPath() {}
47   SearchPath (CDEEnvironment *, const char *, const char *);
48   virtual ~SearchPath();
49
50   virtual void ExportPath();
51   virtual void Print();
52   virtual void AddPredefinedPath();
53
54 #if defined(linux)
55   virtual void PrettyPrint (std::ostream &) const;
56
57   friend std::ostream & operator<< (std::ostream &, const SearchPath &);
58 #else
59   virtual void PrettyPrint (ostream &) const;
60
61   friend ostream & operator<< (ostream &, const SearchPath &);
62 #endif
63
64   const char *  GetEnvVar() const    { return environment_var; }
65   CString       GetSearchPath() const { return final_search_path; }
66
67  protected:
68   void  AssembleString (const CString &);
69   void  NormalizePath();
70   void  AddToPath (const CString &);
71   void  TraversePath();
72
73   virtual void    MakePath (const CString &) {}
74   virtual CString ConstructPath (const CString &, const CString *,
75                                  unsigned char useTT = 1);
76
77   int     ParseState() const   { return parse_state; }
78   CString Separator() const    { return separator; }
79
80   virtual int validSearchPath (const CString &) const;
81
82   void    setSeparator (const char * sep) { separator = sep; }
83
84   CString          search_path;
85   CString          norm_search_path;
86   CString          final_search_path;
87   CDEEnvironment * user;
88
89  private:
90   const char *     environment_var;
91   int              parse_state;
92   CString          save_host;
93   CString          separator;
94 };
95
96
97 class AppSearchPath : public SearchPath {
98  public:
99   AppSearchPath (CDEEnvironment *, 
100                  const char * = "DTAPP",
101                  const char * = ",");
102   virtual ~AppSearchPath() {}
103
104   void FixUp();
105
106  protected:
107   virtual void    MakePath (const CString &);
108
109  private:
110 };
111
112
113 class IconSearchPath : public SearchPath {
114  public:
115   IconSearchPath (CDEEnvironment *,
116                   const char * = "XMICON",
117                   const char * = ".pm",
118                   const char * = ".bm",
119                   const char * = ":");
120   virtual ~IconSearchPath() {}
121
122  protected:
123   virtual void    MakePath (const CString &);
124   virtual int     validSearchPath (const CString &) const;
125
126  private:
127   CString first;
128   CString second;
129 };
130
131
132 class DatabaseSearchPath : public SearchPath {
133  public:
134   DatabaseSearchPath (CDEEnvironment *,
135                       const char * = "DTDATABASE",
136                       const char * = ",");
137   virtual ~DatabaseSearchPath() {}
138
139  protected:
140   virtual void    MakePath (const CString &);
141   virtual CString ConstructPath (const CString &, const CString *,
142                                  unsigned char useTT = 0);
143
144  private:
145 };
146
147
148 class HelpSearchPath : public SearchPath {
149  public:
150   HelpSearchPath (CDEEnvironment *, 
151                   const char * = "DTHELP",
152                   const char * = ":");
153   virtual ~HelpSearchPath() {}
154
155  protected:
156   virtual void    MakePath (const CString &);
157   virtual int     validSearchPath (const CString &) const;
158
159  private:
160 };
161
162
163 class InfoLibSearchPath : public SearchPath {
164  public:
165   InfoLibSearchPath (CDEEnvironment *, 
166                   const char * = "DTINFOLIB",
167                   const char * = ":");
168   virtual ~InfoLibSearchPath() {}
169
170  protected:
171   virtual void    MakePath (const CString &);
172   virtual int     validSearchPath (const CString &) const;
173
174  private:
175 };
176
177
178 class ManSearchPath : public SearchPath {
179  public:
180   ManSearchPath (CDEEnvironment *, 
181                  const char * = "MANPATH",
182                  const char * = ":");
183   virtual ~ManSearchPath() {}
184
185   virtual void    ExportPath ();
186   virtual void    Print();
187
188 #if defined(linux)
189   friend std::ostream & operator<< (std::ostream &, const ManSearchPath &);
190 #else
191   friend ostream & operator<< (ostream &, const ManSearchPath &);
192 #endif
193
194  protected:
195   virtual void    MakePath (const CString &);
196
197  private:
198 };
199
200 #endif