2021-12-08 14:52:15 +00:00
|
|
|
//
|
2025-03-16 21:16:12 +00:00
|
|
|
// Fluid Project File Writer header for the Fast Light Tool Kit (FLTK).
|
2021-12-08 14:52:15 +00:00
|
|
|
//
|
2025-03-16 21:16:12 +00:00
|
|
|
// Copyright 1998-2025 by Bill Spitzak and others.
|
2021-12-08 14:52:15 +00:00
|
|
|
//
|
|
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
|
//
|
|
|
|
|
// https://www.fltk.org/COPYING.php
|
|
|
|
|
//
|
|
|
|
|
// Please see the following page on how to report bugs and issues:
|
|
|
|
|
//
|
|
|
|
|
// https://www.fltk.org/bugs.php
|
|
|
|
|
//
|
|
|
|
|
|
2025-03-07 23:14:09 +00:00
|
|
|
#ifndef FLUID_IO_PROJECT_WRITER_H
|
|
|
|
|
#define FLUID_IO_PROJECT_WRITER_H
|
2021-12-11 18:43:00 +00:00
|
|
|
|
2021-12-08 14:52:15 +00:00
|
|
|
#include <FL/fl_attr.h>
|
|
|
|
|
|
2025-03-07 23:14:09 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2025-03-16 21:16:12 +00:00
|
|
|
class Node;
|
2023-01-26 14:23:43 +00:00
|
|
|
|
2025-03-07 23:14:09 +00:00
|
|
|
namespace fld {
|
2025-03-16 21:16:12 +00:00
|
|
|
|
|
|
|
|
class Project;
|
|
|
|
|
|
2025-03-07 23:14:09 +00:00
|
|
|
namespace io {
|
2021-12-08 14:52:15 +00:00
|
|
|
|
2025-03-16 21:16:12 +00:00
|
|
|
int write_file(Project &proj, const char *, int selected_only = 0, bool to_codeview = false);
|
2021-12-08 14:52:15 +00:00
|
|
|
|
2025-03-07 23:14:09 +00:00
|
|
|
class Project_Writer
|
2023-01-26 14:23:43 +00:00
|
|
|
{
|
|
|
|
|
protected:
|
2025-03-16 21:16:12 +00:00
|
|
|
/// Link Project_Writer class to the project.
|
|
|
|
|
Project &proj_;
|
|
|
|
|
|
2023-11-06 10:36:02 +00:00
|
|
|
// Project output file, always opened in "wb" mode
|
2025-03-16 21:16:12 +00:00
|
|
|
FILE *fout = nullptr;
|
2023-10-27 14:09:01 +00:00
|
|
|
/// If set, one space is written before text unless the format starts with a newline character
|
2025-03-16 21:16:12 +00:00
|
|
|
int needspace = 0;
|
2024-04-17 15:51:32 +00:00
|
|
|
/// Set if this file will be used in the codeview dialog
|
2025-03-16 21:16:12 +00:00
|
|
|
bool write_codeview_ = false;
|
2023-01-26 14:23:43 +00:00
|
|
|
|
|
|
|
|
public:
|
2025-03-16 21:16:12 +00:00
|
|
|
Project_Writer(Project &proj);
|
2025-03-07 23:14:09 +00:00
|
|
|
~Project_Writer();
|
2023-01-26 14:23:43 +00:00
|
|
|
int open_write(const char *s);
|
|
|
|
|
int close_write();
|
2024-04-17 15:51:32 +00:00
|
|
|
int write_project(const char *filename, int selected_only, bool codeview);
|
2023-01-26 14:23:43 +00:00
|
|
|
void write_word(const char *);
|
|
|
|
|
void write_string(const char *,...) __fl_attr((__format__ (__printf__, 2, 3)));
|
|
|
|
|
void write_indent(int n);
|
2023-10-27 14:09:01 +00:00
|
|
|
void write_open();
|
2023-01-26 14:23:43 +00:00
|
|
|
void write_close(int n);
|
2023-10-24 12:28:56 +00:00
|
|
|
FILE *file() const { return fout; }
|
2024-04-17 15:51:32 +00:00
|
|
|
bool write_codeview() const { return write_codeview_; }
|
2023-01-26 14:23:43 +00:00
|
|
|
};
|
2021-12-08 14:52:15 +00:00
|
|
|
|
2025-03-07 23:14:09 +00:00
|
|
|
} // namespace io
|
|
|
|
|
} // namespace fld
|
|
|
|
|
|
|
|
|
|
#endif // FLUID_IO_PROJECT_WRITER_H
|