File: getdata.hpp

package info (click to toggle)
aspell 0.60.6-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 10,000 kB
  • ctags: 4,862
  • sloc: sh: 48,145; cpp: 22,153; perl: 1,546; ansic: 1,535; makefile: 684; sed: 16
file content (68 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// This file is part of The New Aspell
// Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license
// version 2.0 or 2.1.  You should have received a copy of the LGPL
// license along with this library if you did not you can find
// it at http://www.gnu.org/.

#ifndef ASPELL_GET_DATA__HPP
#define ASPELL_GET_DATA__HPP

#include <stddef.h>
#include <limits.h>
#include "string.hpp"
#include "mutable_string.hpp"

namespace acommon {

  class IStream;
  class String;

  // NOTE: getdata_pair WILL NOT unescape a string

  struct DataPair {
    MutableString key;
    MutableString value;
    size_t line_num;
    DataPair() : line_num(0) {}
  };

  bool getdata_pair(IStream & in, DataPair & d, String & buf);

  char * unescape(char * dest, const char * src);
  static inline char * unescape(char * dest) {return unescape(dest, dest);}
  static inline void unescape(MutableString & d) {
    char * e = unescape(d.str, d.str);
    d.size = e - d.str;
  }
  static inline void unescape(String & d) {
    d.ensure_null_end();
    char * e = unescape(d.data(), d.data());
    d.resize(e - d.data());
  }

  // if limit is not given than dest should have enough space for 
  // twice the number of characters of src
  bool escape(char * dest, const char * src, 
	      size_t limit = INT_MAX, const char * others = 0);

  void to_lower(char *);
  void to_lower(String &, const char *);

  // extract the first whitespace delimited word from d.value and put
  // it in d.key.  d.value is expected not to have any leading
  // whitespace. The string is modified in place so that d.key will be
  // null terminated.  d.value is modified to point to any additional
  // data after key with any leading white space removed.  Returns
  // false when there are no more words to extract
  bool split(DataPair & d);

  // preps a string for split
  void init(ParmString str, DataPair & d, String & buf);

  bool getline(IStream & in, DataPair & d, String & buf);

  char * get_nb_line(IStream & in, String & buf);
  void remove_comments(String & buf);

}
#endif