File: reffile.h

package info (click to toggle)
aoflagger 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,476 kB
  • sloc: cpp: 51,868; python: 152; sh: 25; makefile: 17
file content (84 lines) | stat: -rw-r--r-- 1,392 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef AO_REFFILE_H
#define AO_REFFILE_H

#include <fstream>
#include <string>
#include <vector>

#include "reffileentry.h"
#include "reffileexception.h"

namespace AOTools
{
	class RefFile
	{
		public:
			typedef std::vector<RefFileEntry>::const_iterator const_iterator;

			RefFile()
			{
			}

			explicit RefFile(const std::string &refFilePath)
			{
				Read(refFilePath);
			}

			void Read(const std::string &refFilePath)
			{
				_entries.clear();
				_refFilePath = refFilePath;
				std::ifstream file(_refFilePath.c_str());
				RefFileEntry entry;
				while(entry.read(file))
				{
					_entries.push_back(entry);
				}
			}

			void Write(std::ostream &destination) const
			{
				for(const_iterator i=begin();i!=end();++i)
					i->write(destination);
			}

			size_t Count() const
			{
				return _entries.size();
			}

			const RefFileEntry &operator[](const size_t index) const
			{
				return _entries[index];
			}

			void Add(const RefFileEntry &entry)
			{
				_entries.push_back(entry);
			}
	
			const_iterator begin() const
			{
				return _entries.begin();
			}

			const_iterator end() const
			{
				return _entries.end();
			}

		private:
			RefFile(const RefFile &) // don't allow copy
			{
			}

			void operator=(const RefFile &) // don't allow assignment
			{
			}

			std::vector<RefFileEntry> _entries;
			std::string _refFilePath;
	};
}

#endif //AO_REFFILE_H