NSStruct.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33 
34 #ifndef NS_STRUCT
35 # define NS_STRUCT
36 
37 #include <iostream>
38 #include <vector>
39 
40 #include "libmwaw_internal.hxx"
41 
42 #include "MWAWEntry.hxx"
43 
44 class NSParser;
45 
47 namespace NSStruct
48 {
51 
54 
56 struct Position {
58  Position() : m_paragraph(0), m_word(0), m_char(0) {
59  }
61  friend std::ostream &operator<< (std::ostream &o, Position const &pos);
62 
64  bool operator==(Position const &p2) const {
65  return cmp(p2)==0;
66  }
68  bool operator!=(Position const &p2) const {
69  return cmp(p2)!=0;
70  }
72  int cmp(Position const &p2) const {
73  if (m_paragraph < p2.m_paragraph) return -1;
74  if (m_paragraph > p2.m_paragraph) return 1;
75  if (m_word < p2.m_word) return -1;
76  if (m_word > p2.m_word) return 1;
77  if (m_char < p2.m_char) return -1;
78  if (m_char > p2.m_char) return 1;
79  return 0;
80  }
84  int m_word;
86  int m_char;
87 
89  struct Compare {
91  bool operator()(Position const &p1, Position const &p2) const {
92  return p1.cmp(p2) < 0;
93  }
94  };
95 };
96 
98 // Internal: low level
99 
101 struct FootnoteInfo {
104  m_separatorLength(108), m_unknown(0) {
105  }
107  friend std::ostream &operator<< (std::ostream &o, FootnoteInfo const &fnote);
108 
110  bool endNotes() const {
111  return (m_flags&0x8);
112  }
114  bool resetNumberOnNewPage() const {
115  return (m_flags&0x8)==0 && (m_flags&0x10);
116  }
118  int m_flags;
127 };
128 
130 struct RecursifData {
131  struct Node;
132  struct Info;
135  m_info(new Info(zone, vType)), m_level(level), m_childList() {
136  }
138  RecursifData(RecursifData const &orig) :
139  m_info(orig.m_info), m_level(-1), m_childList() {
140  }
143  if (this != &orig) {
144  m_info = orig.m_info;
145  m_level = orig.m_level;
146  m_childList = orig.m_childList;
147  }
148  return *this;
149  }
151  bool read(NSParser &parser, MWAWEntry const &entry);
152 
154  shared_ptr<Info> m_info;
156  int m_level;
158  std::vector<Node> m_childList;
159 
161  struct Info {
164  m_zoneType(zType), m_variableType(vType) {
165  }
170  };
172  struct Node {
174  Node() : m_type(0), m_entry(), m_data() {
175  }
177  bool isLeaf() const {
178  return !m_data;
179  }
180 
182  int m_type;
186  shared_ptr<RecursifData> m_data;
187  };
188 };
189 }
190 
191 #endif
192 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Wed May 7 2014 00:30:22 for libmwaw by doxygen 1.8.3.1