diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-08-03 15:56:10 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2011-08-03 16:58:17 +0800 |
commit | 248faf7d8ad085e237973aa4a4145793cfc3345e (patch) | |
tree | 7ba1a478541ef20e0972051c9dd4bfc470ed8a68 /include | |
parent | Parser: improve the rule for regular expression (diff) | |
download | libbash-248faf7d8ad085e237973aa4a4145793cfc3345e.tar.gz libbash-248faf7d8ad085e237973aa4a4145793cfc3345e.tar.bz2 libbash-248faf7d8ad085e237973aa4a4145793cfc3345e.zip |
Build: install public headers
We need to put all public headers into the include directory.
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 32 | ||||
-rw-r--r-- | include/divide_by_zero_error.h | 49 | ||||
-rw-r--r-- | include/exceptions.h | 35 | ||||
-rw-r--r-- | include/illegal_argument_exception.h | 49 | ||||
-rw-r--r-- | include/interpreter_exception.h | 48 | ||||
-rw-r--r-- | include/libbash.h | 62 | ||||
-rw-r--r-- | include/parse_exception.h | 49 | ||||
-rw-r--r-- | include/readonly_exception.h | 49 | ||||
-rw-r--r-- | include/runtime_exception.h | 49 | ||||
-rw-r--r-- | include/unsupported_exception.h | 49 |
10 files changed, 471 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h new file mode 100644 index 0000000..7203f02 --- /dev/null +++ b/include/common.h @@ -0,0 +1,32 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. +*/ +/// +/// \file common.h +/// \brief common macros and includes +/// + +#ifndef LIBBASH_COMMON_H_ +#define LIBBASH_COMMON_H_ + +/// compiler hint for public symbols +#define LIBBASH_API __attribute__((visibility("default"))) +/// compiler hint for hidden symbols +#define LIBBASH_LOCAL __attribute__((visibility("hidden"))) + +#endif diff --git a/include/divide_by_zero_error.h b/include/divide_by_zero_error.h new file mode 100644 index 0000000..59e0fcb --- /dev/null +++ b/include/divide_by_zero_error.h @@ -0,0 +1,49 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. +*/ +/// +/// \file divide_by_zero_error.h +/// \brief implementation for divide_by_zero_error +/// + +#ifndef LIBBASH_CORE_DIVIDE_BY_ZERO_ERROR_H_ +#define LIBBASH_CORE_DIVIDE_BY_ZERO_ERROR_H_ + +#include <stdexcept> +#include <string> + +#include "common.h" +#include "interpreter_exception.h" + +namespace libbash +{ + /// + /// \class divide_by_zero_error + /// \brief exception for dividing by zero error + /// + class LIBBASH_API divide_by_zero_error: public libbash::interpreter_exception + { + public: + /// \brief the constructor + /// \param err_msg the error message + explicit divide_by_zero_error(const std::string& err_msg): + libbash::interpreter_exception(err_msg){} + }; +} + +#endif diff --git a/include/exceptions.h b/include/exceptions.h new file mode 100644 index 0000000..07c203c --- /dev/null +++ b/include/exceptions.h @@ -0,0 +1,35 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. + */ +/// +/// \file exceptions.h +/// \author Mu Qiao +/// \brief headers for all exceptions +/// +#ifndef LIBBASH_CORE_EXCEPTIOND_H_ +#define LIBBASH_CORE_EXCEPTIOND_H_ + +#include "divide_by_zero_error.h" +#include "illegal_argument_exception.h" +#include "interpreter_exception.h" +#include "parse_exception.h" +#include "readonly_exception.h" +#include "runtime_exception.h" +#include "unsupported_exception.h" + +#endif diff --git a/include/illegal_argument_exception.h b/include/illegal_argument_exception.h new file mode 100644 index 0000000..847b6a8 --- /dev/null +++ b/include/illegal_argument_exception.h @@ -0,0 +1,49 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. +*/ +/// +/// \file illegal_argument_exception.h +/// \brief implementation for illegal_argument_exception +/// + +#ifndef LIBBASH_CORE_ILLEGAL_ARGUMENT_EXCEPTION_H_ +#define LIBBASH_CORE_ILLEGAL_ARGUMENT_EXCEPTION_H_ + +#include <stdexcept> +#include <string> + +#include "common.h" +#include "interpreter_exception.h" + +namespace libbash +{ + /// + /// \class illegal_argument_exception + /// \brief exception for parsing errors + /// + class LIBBASH_API illegal_argument_exception: public libbash::interpreter_exception + { + public: + /// \brief the constructor + /// \param err_msg the error message + explicit illegal_argument_exception(const std::string& err_msg): + libbash::interpreter_exception(err_msg){} + }; +} + +#endif diff --git a/include/interpreter_exception.h b/include/interpreter_exception.h new file mode 100644 index 0000000..11f909f --- /dev/null +++ b/include/interpreter_exception.h @@ -0,0 +1,48 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. +*/ +/// +/// \file interpreter_exception.h +/// \brief implementation for interpreter_exception +/// + +#ifndef LIBBASH_CORE_INTERPRETER_EXCEPTION_H_ +#define LIBBASH_CORE_INTERPRETER_EXCEPTION_H_ + +#include <stdexcept> +#include <string> + +#include "common.h" + +namespace libbash +{ + /// + /// \class interpreter_exception + /// \brief runtime exception occured during interpreting + /// + class LIBBASH_API interpreter_exception: public std::runtime_error + { + public: + /// \brief the constructor + /// \param err_msg the error message + explicit interpreter_exception(const std::string& err_msg): + runtime_error(err_msg){} + }; +} + +#endif diff --git a/include/libbash.h b/include/libbash.h new file mode 100644 index 0000000..bc065f3 --- /dev/null +++ b/include/libbash.h @@ -0,0 +1,62 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. +*/ +/// +/// \file libbash.h +/// \brief public interface for libbash +/// + +#ifndef LIBBASH_LIBBASH_H_ +#define LIBBASH_LIBBASH_H_ + +#include <memory> +#include <string> +#include <unordered_map> +#include <vector> + +#include "common.h" +#include "exceptions.h" + +namespace libbash +{ + /// + /// \brief interpret a script specifid by path, return a map filled with + /// variables defined in the script + /// \param the path of target script + /// \param[in, out] we use the map to initialize bash environment and store the result + /// \param[out] store the names of the functions defined in the script + /// \return the return status of the script + int LIBBASH_API interpret(const std::string& target_path, + std::unordered_map<std::string, std::vector<std::string>>& variables, + std::vector<std::string>& functions); + + /// + /// \brief interpret a script specifid by path, return a map filled with + /// variables defined in the script + /// \param the path of target script + /// \param the path of a script that you want to source before interpreting + /// \param[in, out] we use the map to initialize bash environment and store the result. The environment will be initialized after preloading. + /// \param[out] store the names of the functions defined in the script + /// \return the return status of the script + int LIBBASH_API interpret(const std::string& target_path, + const std::string& preload_path, + std::unordered_map<std::string, std::vector<std::string>>& variables, + std::vector<std::string>& functions); +} + +#endif diff --git a/include/parse_exception.h b/include/parse_exception.h new file mode 100644 index 0000000..6f19bff --- /dev/null +++ b/include/parse_exception.h @@ -0,0 +1,49 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. +*/ +/// +/// \file parse_exception.h +/// \brief implementation for parse_exception +/// + +#ifndef LIBBASH_CORE_PARSE_EXCEPTION_H_ +#define LIBBASH_CORE_PARSE_EXCEPTION_H_ + +#include <stdexcept> +#include <string> + +#include "common.h" +#include "interpreter_exception.h" + +namespace libbash +{ + /// + /// \class parse_exception + /// \brief exception for parsing errors + /// + class LIBBASH_API parse_exception: public libbash::interpreter_exception + { + public: + /// \brief the constructor + /// \param err_msg the error message + explicit parse_exception(const std::string& err_msg): + libbash::interpreter_exception(err_msg){} + }; +} + +#endif diff --git a/include/readonly_exception.h b/include/readonly_exception.h new file mode 100644 index 0000000..16d1106 --- /dev/null +++ b/include/readonly_exception.h @@ -0,0 +1,49 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. +*/ +/// +/// \file readonly_exception.h +/// \brief implementation for readonly_exception +/// + +#ifndef LIBBASH_CORE_READONLY_EXCEPTION_H_ +#define LIBBASH_CORE_READONLY_EXCEPTION_H_ + +#include <stdexcept> +#include <string> + +#include "common.h" +#include "interpreter_exception.h" + +namespace libbash +{ + /// + /// \class readonly_exception + /// \brief exception for modifying readonly symbols + /// + class LIBBASH_API readonly_exception: public libbash::interpreter_exception + { + public: + /// \brief the constructor + /// \param err_msg the error message + explicit readonly_exception(const std::string& err_msg): + libbash::interpreter_exception(err_msg){} + }; +} + +#endif diff --git a/include/runtime_exception.h b/include/runtime_exception.h new file mode 100644 index 0000000..ed87655 --- /dev/null +++ b/include/runtime_exception.h @@ -0,0 +1,49 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. +*/ +/// +/// \file runtime_exception.h +/// \brief implementation for runtime_exception +/// + +#ifndef LIBBASH_CORE_RUNTIME_EXCEPTION_H_ +#define LIBBASH_CORE_RUNTIME_EXCEPTION_H_ + +#include <stdexcept> +#include <string> + +#include "common.h" +#include "interpreter_exception.h" + +namespace libbash +{ + /// + /// \class runtime_exception + /// \brief exception for runtime errors + /// + class LIBBASH_API runtime_exception: public libbash::interpreter_exception + { + public: + /// \brief the constructor + /// \param err_msg the error message + explicit runtime_exception(const std::string& err_msg): + libbash::interpreter_exception(err_msg){} + }; +} + +#endif diff --git a/include/unsupported_exception.h b/include/unsupported_exception.h new file mode 100644 index 0000000..9920a5c --- /dev/null +++ b/include/unsupported_exception.h @@ -0,0 +1,49 @@ +/* + Please use git log for copyright holder and year information + + This file is part of libbash. + + libbash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + libbash is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libbash. If not, see <http://www.gnu.org/licenses/>. +*/ +/// +/// \file unsupported_exception.h +/// \brief implementation for unsupported_exception +/// + +#ifndef LIBBASH_CORE_UNSUPPORTED_EXCEPTION_H_ +#define LIBBASH_CORE_UNSUPPORTED_EXCEPTION_H_ + +#include <stdexcept> +#include <string> + +#include "common.h" +#include "interpreter_exception.h" + +namespace libbash +{ + /// + /// \class unsupported_exception + /// \brief exception for unsupported features + /// + class LIBBASH_API unsupported_exception: public libbash::interpreter_exception + { + public: + /// \brief the constructor + /// \param err_msg the error message + explicit unsupported_exception(const std::string& err_msg): + libbash::interpreter_exception(err_msg){} + }; +} + +#endif |