Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSAOS.h
1 /* ===================================================================
2 *
3 * T R A D I N G S Y S T E M A P I ™
4 * Copyright © 1999 - 2014 by Peter Ritter ( TradingSystemAPI.com )
5 * A L L R I G H T S R E S E R V E D
6 *
7 * Consult your license regarding permissions and restrictions.
8 * You may obtain a copy of the License at:
9 * http://www.TradingSystemAPI.com/licenses/LICENSE-TSAPI-3.0.html
10 *
11 * ====================================================================
12 */
13 
14 #ifndef TSA_OS__INCLUDED
15 #define TSA_OS__INCLUDED
16 
17 #include <vector>
18 
19 #include "TSAString.h"
20 
21 namespace tsa {
22  namespace os {
27  /*
28  ** ====================================================
29  ** >>> class path <<<
30  ** ====================================================
31  */
35 
36  class dll_export path : public tsa::object {
37  private:
38  void init(const std::string&);
39  public:
41  static path join(const os::path& a, const os::path& b);
42  static path cwd(void);
43  public:
44  std::string m_sPath;
45  public:
47  path(void);
49  path(const tsa::string& p);
51  path(const std::string& p);
53  path(const char* p);
55  path(const os::path&);
57  ~path(void);
59  const std::string& to_string(void)const;
61  const char* c_str()const;
63  void operator=(const os::path&);
65  void append(const tsa::string& s);
68  std::string right(size_t n)const;
71  bool exists(void)const;
74  path find_unique_numbered(void)const;
75  //Throws an exception if the file does not exist.
76  void verify_exists(void)const;
78  bool defined(void)const;
80  bool is_dir(void)const;
82  void join(const os::path& other);
84  void operator/=(const os::path& other);
85  // @brief Creates a directory at the path represented by @b self.
86  void create_as_dir(void)const;
88  void set_to_cwd(void);
90  void set_as_cwd(void);
92  bool is_cwd(void)const;
95  bool is_absolute(void)const;
97  path as_absolute(void)const;
100  void remove_from_disk(bool missing_OK = false)const;
102  operator const char* (void)const;
104  bool operator==(const os::path& other);
106  int64_t file_size(void)const;
107  //
108  path parent(void)const;
109  };
111  path operator/(const os::path& a, const os::path& b);
113  std::ostream& operator<<(std::ostream& s, const os::path& p);
114 
115  /*
116  ** ====================================================
117  ** >>> class file <<<
118  ** ====================================================
119  */
120  // Internal use
121  class dll_export file {
122  public:
123  static bool exists(const os::path& path);
124  static bool exists(const os::path& name, int);
125  static bool unlink(const os::path& name);
126  static bool is_dir(const os::path&);
127  static void remove(const os::path& path, bool ignore_missing = false);
128  static void remove_if_exists(const os::path& path);
129  static void verify_exists(const os::path&);
130  static void copy(const os::path& from, const os::path& to, bool replace = true);
131  static int64_t size(const os::path& file);
132  static bool have_identical_content(const os::path& a, const os::path& b);
133  };
134 
135  /*
136  ** ====================================================
137  ** >>> class directory <<<
138  ** ====================================================
139  */
140  //Internal use
141  class dll_export directory {
142  public:
143  static void remove_recursive(const os::path& dir);
144  static void copy_recursive(const os::path& from, const os::path& to, bool replace = true);
145  static void fetch_content(const os::path& dir, std::vector<path>&, bool abs_path = false);
146  static void create(const os::path& dir);
147  };
148 
149  // Returns the operating system's current directory.
150  string cwd(void);
151  // Changes the operating system's current directory to @b p.
152  void chdir(const char* p);
153  // Executes @a command.
154  void system(const tsa::string& command);
155 
157 
158  /*********************************************************************
159  Copyright Kevlin Henney, 1997, 2003. All rights reserved.
160 
161  Permission to use, copy, modify, and distribute this software and its
162  documentation for any purpose is hereby granted without fee, provided
163  that this copyright and permissions notice appear in all copies and
164  derivatives.
165  This software is supplied "as is" without express or implied warranty.
166  But that said, if there are any problems please get in touch.
167  **********************************************************************/
168 
169 #ifdef __cplusplus
170  extern "C"
171  {
172 #endif
173  typedef struct DIR DIR;
174  struct dirent {
175  char* d_name;
176  };
177 
178  DIR* opendir(const char*);
179  int closedir(DIR*);
180  struct dirent* readdir(DIR*);
181  void rewinddir(DIR*);
182 
183 #ifdef __cplusplus
184  }
185 #endif
186  }//namspace os
187 } //namespace tsa
188 
189 #endif
Utility class to manipulate file system paths. This class is intended to fulfil the requirements of t...
Definition: TSAOS.h:36
Namespace for the &#39;Trading System API&#39; library.
Definition: original1.TSA3Core.cpp:20
Replace existing target if it already exists.
Definition: TSAStreams.h:533
Parent class for many library classes.
Definition: TSATypeDef.h:462
sref< bool > operator==(numeric_series_cref a, numeric_series_cref b)
comparison.
Definition: TSADSLBase.cpp:130
sref< double > operator/(numeric_series_cref a, numeric_series_cref b)
Divides a by b.
Definition: TSADSLBase.cpp:47