* lyx_1_6.py:
[lyx.git] / src / CmdDef.h
blobfa24fe76152121925f4490e15a23a6824053d9d8
1 // -*- C++ -*-
2 /**
3 * \file CmdDef.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Bernhard Roider
9 * Full author contact details are available in file CREDITS.
12 #ifndef CMDDEF_H
13 #define CMDDEF_H
15 #include "FuncRequest.h"
17 #include "support/strfwd.h"
19 #include <map>
20 #include <set>
22 namespace lyx {
24 /// Creates command definitions
25 class CmdDef {
26 private:
27 /// type for map between a macro name and its info
28 typedef std::map<std::string, FuncRequest> CmdDefMap;
29 /// type for a set containing all locked definitions
30 typedef std::set<std::string> LockSet;
31 public:
33 /// Parse a def file
34 bool read(std::string const & def_file);
36 /**
37 * Look up a definition, lock it and return the
38 * associated action if it is not locked.
39 * @param name the name of the command
40 * @param func contains the action on success
41 * @return true if lock was successful
43 bool lock(std::string const & name, FuncRequest & func);
45 /// release a locked definition
46 void release(std::string const & name);
48 private:
50 /// possible reasons for not allowed definitions
51 enum newCmdDefResult {
52 CmdDefOk,
53 CmdDefNameEmpty,
54 CmdDefInvalid,
55 CmdDefExists
58 /**
59 * Add a new command definition.
60 * @param name internal recursion level
62 newCmdDefResult newCmdDef(std::string const & name,
63 std::string const & def);
65 ///
66 CmdDefMap cmdDefMap;
67 ///
68 LockSet lockSet;
71 /// Implementation is in LyX.cpp
72 extern CmdDef & theTopLevelCmdDef();
75 } // namespace lyx
77 #endif // CMDDEF_H