File: ValidFileExtensions.h

package info (click to toggle)
ausaxs 1.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 72,592 kB
  • sloc: cpp: 49,853; ansic: 6,901; python: 730; makefile: 18
file content (34 lines) | stat: -rw-r--r-- 1,327 bytes parent folder | download | duplicates (2)
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
// SPDX-License-Identifier: LGPL-3.0-or-later
// Author: Kristian Lytje

#pragma once

#include <io/IOFwd.h>

#include <array>

namespace ausaxs::constants::filetypes {
    namespace detail {
        template<std::size_t N>
        class FileType {
            public:
                consteval FileType(std::array<const char*, N> extensions) : extensions(std::move(extensions)) {}

                /**
                * @brief Check if a file exists and has one of the allowed extensions for this file type.
                */
                bool check(const io::File& path) const;

            private:
                std::array<const char*, N> extensions;
        };
    }

    constexpr detail::FileType structure = {std::array{".pdb",    ".ent",  ".cif", ".xyz" }};
    constexpr detail::FileType saxs_data = {std::array{".dat",    ".rsr",  ".xvg"         }};
    constexpr detail::FileType em_map    = {std::array{".map",    ".ccp4", ".mrc", ".rec" }};
    constexpr detail::FileType unit_cell = {std::array{".cell",   ".uc"                   }};
    constexpr detail::FileType grid      = {std::array{".grid"                            }};
    constexpr detail::FileType config    = {std::array{".config", ".conf", ".txt"         }};
    // * remember to correct cpp file if more than 4 possible extensions are added
}