Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / netwerk / streamconv / converters / nsDirIndexParser.h
blob291a86337ebce6c102631176688664dae6b86189
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef __NSDIRINDEX_H_
7 #define __NSDIRINDEX_H_
9 #include "nsString.h"
10 #include "nsCOMPtr.h"
11 #include "nsIDirIndexListener.h"
12 #include "mozilla/RefPtr.h"
14 class nsIDirIndex;
15 class nsITextToSubURI;
17 /* CID: {a0d6ad32-1dd1-11b2-aa55-a40187b54036} */
19 class nsDirIndexParser : public nsIDirIndexParser {
20 private:
21 virtual ~nsDirIndexParser() = default;
23 nsDirIndexParser() = default;
24 void Init();
26 public:
27 NS_DECL_ISUPPORTS
28 NS_DECL_NSISTREAMLISTENER
29 NS_DECL_NSIREQUESTOBSERVER
30 NS_DECL_NSIDIRINDEXPARSER
32 static already_AddRefed<nsIDirIndexParser> CreateInstance() {
33 RefPtr<nsDirIndexParser> parser = new nsDirIndexParser();
34 parser->Init();
35 return parser.forget();
38 enum fieldType {
39 FIELD_UNKNOWN = 0, // MUST be 0
40 FIELD_FILENAME,
41 FIELD_CONTENTLENGTH,
42 FIELD_LASTMODIFIED,
43 FIELD_FILETYPE
46 protected:
47 nsCOMPtr<nsIDirIndexListener> mListener;
49 nsCString mBuf;
50 int32_t mLineStart{0};
51 int mFormat[8]{-1};
53 nsresult ProcessData(nsIRequest* aRequest);
54 void ParseFormat(const char* aFormatStr);
55 void ParseData(nsIDirIndex* aIdx, char* aDataStr, int32_t lineLen);
57 struct Field {
58 const char* mName;
59 fieldType mType;
62 static Field gFieldTable[];
65 #endif