SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
projectFile.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026. Giulio Cocconi
3
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
#pragma once
18
19
#include <filesystem>
20
#include <string>
21
#include <string_view>
22
#include <vector>
23
24
#include <
core/projectDocument.hpp
>
25
26
namespace
SILICON::project
{
27
35
inline
constexpr
std::string_view
MIME_TYPE
=
"application/vnd.silicon.project+zip"
;
36
43
inline
constexpr
int
FORMAT_VERSION
= 1;
44
60
inline
const
std::string
DEFAULT_CIRCUIT_PATH
=
61
documentPathForSlug
(
DocumentType::Circuit
,
"untitled"
);
62
66
struct
ProjectMetadata
{
68
int
formatVersion
=
FORMAT_VERSION
;
70
std::string
siliconVersion
;
72
std::string
creationDate
;
74
std::string
lastModify
;
75
};
76
80
struct
ProjectInfo
{
82
std::string
name
;
84
std::string
description
;
85
};
86
93
struct
ProjectFile
{
94
ProjectMetadata
metadata
;
95
ProjectInfo
project
;
97
std::vector<Document>
documents
;
98
};
99
109
[[nodiscard]]
ProjectFile
readProjectFile
(
const
std::filesystem::path& path);
110
119
void
writeProjectFile
(
const
std::filesystem::path& path,
const
ProjectFile
& projectFile);
120
124
[[nodiscard]] std::string
currentUtcTimestamp
();
125
129
[[nodiscard]]
ProjectMetadata
metadataForNewFile
();
130
131
}
// namespace SILICON::project
SILICON::project
Definition
circuitDependencyGraph.cpp:30
SILICON::project::documentPathForSlug
std::string documentPathForSlug(const DocumentType type, const std::string_view slug)
Definition
projectDocument.cpp:191
SILICON::project::currentUtcTimestamp
std::string currentUtcTimestamp()
Returns the current UTC timestamp formatted as YYYY-MM-DDTHH\:MM\:SSZ.
Definition
projectFile.cpp:256
SILICON::project::FORMAT_VERSION
constexpr int FORMAT_VERSION
Current version of the Silicon project archive schema.
Definition
projectFile.hpp:43
SILICON::project::MIME_TYPE
constexpr std::string_view MIME_TYPE
MIME marker stored in Silicon project archives.
Definition
projectFile.hpp:35
SILICON::project::readProjectFile
ProjectFile readProjectFile(const std::filesystem::path &path)
Reads and validates a Silicon .sil project archive.
Definition
projectFile.cpp:272
SILICON::project::writeProjectFile
void writeProjectFile(const std::filesystem::path &path, const ProjectFile &projectFile)
Writes a Silicon .sil project archive.
Definition
projectFile.cpp:300
SILICON::project::metadataForNewFile
ProjectMetadata metadataForNewFile()
Creates default metadata for a new project file.
Definition
projectFile.cpp:263
SILICON::project::DocumentType::Circuit
@ Circuit
Definition
projectDocument.hpp:37
SILICON::project::DEFAULT_CIRCUIT_PATH
const std::string DEFAULT_CIRCUIT_PATH
Default path of the initial circuit JSON file.
Definition
projectFile.hpp:60
projectDocument.hpp
SILICON::project::ProjectFile
In-memory representation of a .sil project archive.
Definition
projectFile.hpp:93
SILICON::project::ProjectFile::project
ProjectInfo project
Definition
projectFile.hpp:95
SILICON::project::ProjectFile::metadata
ProjectMetadata metadata
Definition
projectFile.hpp:94
SILICON::project::ProjectFile::documents
std::vector< Document > documents
Authoritative ordered collection of project documents.
Definition
projectFile.hpp:97
SILICON::project::ProjectInfo
Project-level data stored in project.json.
Definition
projectFile.hpp:80
SILICON::project::ProjectInfo::description
std::string description
Optional human-readable project description.
Definition
projectFile.hpp:84
SILICON::project::ProjectInfo::name
std::string name
Human-readable project name.
Definition
projectFile.hpp:82
SILICON::project::ProjectMetadata
Metadata stored in metadata.json.
Definition
projectFile.hpp:66
SILICON::project::ProjectMetadata::formatVersion
int formatVersion
Project archive schema version.
Definition
projectFile.hpp:68
SILICON::project::ProjectMetadata::siliconVersion
std::string siliconVersion
Silicon application version that wrote the file.
Definition
projectFile.hpp:70
SILICON::project::ProjectMetadata::creationDate
std::string creationDate
UTC timestamp for the first save, formatted as YYYY-MM-DDTHH\:MM\:SSZ.
Definition
projectFile.hpp:72
SILICON::project::ProjectMetadata::lastModify
std::string lastModify
UTC timestamp for the latest save, formatted as YYYY-MM-DDTHH\:MM\:SSZ.
Definition
projectFile.hpp:74
src
core
serialization
projectFile.hpp
Generated by
1.17.0