Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/extensions/spellcheck/hunspell/glue/mozHunspellFileMgr.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozHunspellFileMgr_h
8
#define mozHunspellFileMgr_h
9
10
#include <string>
11
12
#include "mozilla/Result.h"
13
#include "mozilla/ResultExtensions.h"
14
#include "nsIInputStream.h"
15
#include "nsReadLine.h"
16
17
// Note: This class name and lack of namespacing terrible, but are necessary
18
// for Hunspell compatibility.
19
class FileMgr final
20
{
21
public:
22
  /**
23
   * aFilename must be a local file/jar URI for the file to load.
24
   *
25
   * aKey is the decription key for encrypted Hunzip files, and is
26
   * unsupported. The argument is there solely for compatibility.
27
   */
28
  explicit FileMgr(const char* aFilename, const char* aKey = nullptr);
29
0
  ~FileMgr() = default;
30
31
  // Note: The nonstandard naming conventions of these methods are necessary for
32
  // Hunspell compatibility.
33
  bool getline(std::string& aLine);
34
0
  int getlinenum() const { return mLineNum; }
35
36
private:
37
  mozilla::Result<mozilla::Ok, nsresult> Open(const nsACString& aPath);
38
39
  mozilla::Result<mozilla::Ok, nsresult> ReadLine(nsACString& aLine);
40
41
  int mLineNum = 0;
42
  nsCOMPtr<nsIInputStream> mStream;
43
  nsLineBuffer<char> mLineBuffer;
44
};
45
46
#endif // mozHunspellFileMgr_h