Program Listing for File entry.h

Return to documentation for file (include/zim/entry.h)

/*
 * Copyright (C) 2020 Matthieu Gautier <mgautier@kymeria.fr>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and
 * NON-INFRINGEMENT.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 */

#ifndef ZIM_ENTRY_H
#define ZIM_ENTRY_H

#include "zim.h"

#include <string>
#include <memory>

namespace zim
{
  class Item;
  class Dirent;
  class FileImpl;

  class LIBZIM_API Entry
  {
    public:
      explicit Entry(std::shared_ptr<const FileImpl> file_, entry_index_type idx_);

      bool isRedirect() const;
      std::string getTitle() const;
      std::string getPath() const;

      Item getItem(bool follow=false) const;

      Item getRedirect() const;

      Entry getRedirectEntry() const;

      entry_index_type getRedirectEntryIndex() const;

      entry_index_type getIndex() const   { return m_idx; }

    protected: // so that Item can be implemented as a wrapper over Entry
      std::shared_ptr<const FileImpl> m_file;
      entry_index_type m_idx;
      std::shared_ptr<const Dirent> m_dirent;
  };

}

#endif // ZIM_ENTRY_H