2003-02-28 09:49:49 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file format.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Dekel Tsur
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-28 09:49:49 +00:00
|
|
|
*/
|
|
|
|
|
2003-08-23 00:17:00 +00:00
|
|
|
#ifndef FORMAT_H
|
|
|
|
#define FORMAT_H
|
2003-02-28 09:49:49 +00:00
|
|
|
|
|
|
|
#include <vector>
|
2003-10-06 15:43:21 +00:00
|
|
|
#include <string>
|
2003-02-28 09:49:49 +00:00
|
|
|
|
2003-05-23 13:54:09 +00:00
|
|
|
class Buffer;
|
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
class Format {
|
|
|
|
public:
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
Format(std::string const & n, std::string const & e, std::string const & p,
|
|
|
|
std::string const & s, std::string const & v);
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
|
|
|
bool dummy() const;
|
|
|
|
///
|
|
|
|
bool isChildFormat() const;
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const parentFormat() const;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & name() const {
|
2003-02-28 09:49:49 +00:00
|
|
|
return name_;
|
|
|
|
}
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & extension() const {
|
2003-02-28 09:49:49 +00:00
|
|
|
return extension_;
|
|
|
|
}
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & prettyname() const {
|
2003-02-28 09:49:49 +00:00
|
|
|
return prettyname_;
|
|
|
|
}
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & shortcut() const {
|
2003-02-28 09:49:49 +00:00
|
|
|
return shortcut_;
|
|
|
|
}
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const & viewer() const {
|
2003-02-28 09:49:49 +00:00
|
|
|
return viewer_;
|
|
|
|
}
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
void setViewer(std::string const & v) {
|
2003-02-28 09:49:49 +00:00
|
|
|
viewer_ = v;
|
|
|
|
}
|
|
|
|
private:
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string name_;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string extension_;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string prettyname_;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string shortcut_;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string viewer_;
|
2003-02-28 09:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
bool operator<(Format const & a, Format const & b);
|
|
|
|
|
|
|
|
///
|
|
|
|
class Formats {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
typedef std::vector<Format> FormatList;
|
|
|
|
///
|
|
|
|
typedef FormatList::const_iterator const_iterator;
|
|
|
|
///
|
|
|
|
Format const & get(FormatList::size_type i) const {
|
|
|
|
return formatlist[i];
|
|
|
|
}
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
Format const * getFormat(std::string const & name) const;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
int getNumber(std::string const & name) const;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
void add(std::string const & name);
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
void add(std::string const & name, std::string const & extension,
|
|
|
|
std::string const & prettyname, std::string const & shortcut);
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
void erase(std::string const & name);
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
|
|
|
void sort();
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
void setViewer(std::string const & name, std::string const & command);
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
bool view(Buffer const & buffer, std::string const & filename,
|
|
|
|
std::string const & format_name) const;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const prettyName(std::string const & name) const;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const extension(std::string const & name) const;
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
|
|
|
const_iterator begin() const {
|
|
|
|
return formatlist.begin();
|
|
|
|
}
|
|
|
|
///
|
|
|
|
const_iterator end() const {
|
|
|
|
return formatlist.end();
|
|
|
|
}
|
|
|
|
///
|
|
|
|
FormatList::size_type size() const {
|
|
|
|
return formatlist.size();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
FormatList formatlist;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern Formats formats;
|
|
|
|
|
|
|
|
extern Formats system_formats;
|
|
|
|
|
|
|
|
#endif //FORMAT_H
|