adb3473ddec64b0c1358605761b866d7ae1a2271
[ardour.git] / libs / glibmm2 / glibmm / shell.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <glibmm/shell.h>
4 #include <glibmm/private/shell_p.h>
5
6 // -*- c++ -*-
7 /* $Id$ */
8
9 /* Copyright (C) 2002 The gtkmm Development Team
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the Free
23  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25
26 #include <glibmm/utility.h>
27
28
29 namespace Glib
30 {
31
32 /**** shell utility functions **********************************************/
33
34 Glib::ArrayHandle<std::string> shell_parse_argv(const std::string& command_line)
35 {
36   char**  argv  = 0;
37   int     argc  = 0;
38   GError* error = 0;
39
40   g_shell_parse_argv(command_line.c_str(), &argc, &argv, &error);
41
42   if(error)
43     Glib::Error::throw_exception(error);
44
45   return Glib::ArrayHandle<std::string>(argv, argc, Glib::OWNERSHIP_DEEP);
46 }
47
48 std::string shell_quote(const std::string& unquoted_string)
49 {
50   const ScopedPtr<char> buf (g_shell_quote(unquoted_string.c_str()));
51   return std::string(buf.get());
52 }
53
54 std::string shell_unquote(const std::string& quoted_string)
55 {
56   GError* error = 0;
57   char *const buf = g_shell_unquote(quoted_string.c_str(), &error);
58
59   if(error)
60     Glib::Error::throw_exception(error);
61
62   return std::string(ScopedPtr<char>(buf).get());
63 }
64
65 } // namespace Glib
66
67
68 namespace
69 {
70 } // anonymous namespace
71
72
73 Glib::ShellError::ShellError(Glib::ShellError::Code error_code, const Glib::ustring& error_message)
74 :
75   Glib::Error (G_SHELL_ERROR, error_code, error_message)
76 {}
77
78 Glib::ShellError::ShellError(GError* gobject)
79 :
80   Glib::Error (gobject)
81 {}
82
83 Glib::ShellError::Code Glib::ShellError::code() const
84 {
85   return static_cast<Code>(Glib::Error::code());
86 }
87
88 void Glib::ShellError::throw_func(GError* gobject)
89 {
90   throw Glib::ShellError(gobject);
91 }
92
93