GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
comment-list.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2000-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_comment_list_h)
27#define octave_comment_list_h 1
28
29#include "octave-config.h"
30
31#include <string>
32
33#include "base-list.h"
34
35namespace octave
36{
37 extern std::string get_comment_text (void);
38
39 extern char * get_comment_text_c_str (void);
40
41 extern void save_comment_text (const std::string& text);
42
43 class
45 {
46 public:
47
49 {
55 copyright
56 };
57
58 comment_elt (const std::string& s = "", comment_type t = unknown)
59 : m_text (s), m_type (t) { }
60
62 : m_text (oc.m_text), m_type (oc.m_type) { }
63
64 comment_elt& operator = (const comment_elt& oc)
65 {
66 if (this != &oc)
67 {
68 m_text = oc.m_text;
69 m_type = oc.m_type;
70 }
71
72 return *this;
73 }
74
75 std::string text (void) const { return m_text; }
76
77 comment_type type (void) const { return m_type; }
78
79 bool is_block (void) const { return m_type == block; }
80 bool is_full_line (void) const { return m_type == full_line; }
81 bool is_end_of_line (void) const { return m_type == end_of_line; }
82 bool is_doc_string (void) const { return m_type == doc_string; }
83 bool is_copyright (void) const { return m_type == copyright; }
84
85 ~comment_elt (void) = default;
86
87 private:
88
89 // The text of the comment.
90 std::string m_text;
91
92 // The type of comment.
94 };
95
96 class
98 {
99 public:
100
101 comment_list (void) { }
102
103 void append (const comment_elt& elt)
105
106 void append (const std::string& s,
108 { append (comment_elt (s, t)); }
109
110 comment_list * dup (void) const;
111 };
112}
113
114#endif
void append(const elt_type &s)
Definition: base-list.h:92
comment_elt(const comment_elt &oc)
Definition: comment-list.h:61
bool is_doc_string(void) const
Definition: comment-list.h:82
std::string m_text
Definition: comment-list.h:90
~comment_elt(void)=default
std::string text(void) const
Definition: comment-list.h:75
bool is_full_line(void) const
Definition: comment-list.h:80
bool is_copyright(void) const
Definition: comment-list.h:83
comment_elt(const std::string &s="", comment_type t=unknown)
Definition: comment-list.h:58
bool is_block(void) const
Definition: comment-list.h:79
comment_type type(void) const
Definition: comment-list.h:77
comment_type m_type
Definition: comment-list.h:93
bool is_end_of_line(void) const
Definition: comment-list.h:81
void append(const std::string &s, comment_elt::comment_type t=comment_elt::unknown)
Definition: comment-list.h:106
void append(const comment_elt &elt)
Definition: comment-list.h:103
char * get_comment_text_c_str(void)
std::string get_comment_text(void)
void save_comment_text(const std::string &text)