חזור לתיקייה: files

TextFile

חיפוש בתיקיה
Ctrl K
לחץ כאן או הקש Ctrl K כדי לחפש בכל התיקיה

    TextFile

    02340124

    מבוא לתכנות מערכות

    רשימות הרצאה לקריאה בשבת

    TextFile

    הופק מתוך תקיית התואר של שקד

    uni-folder.vercel.app

    textfile.h

    הערה (קובץ קוד)

    קובץ זה הוא קובץ קוד מסוג C.

    #pragma once
    
    #include "File.h"
    
    #include <string>
    #include <list>
    #include <memory>
    #include <vector>
    
    /**
     * @class TextFile
     * A subtype of File, it provides a way to save text in the system. it's a file :)
     */
    class TextFile : public File {
    public:
        /**
         * Creates a new empty text file with no text in it.
         * @param name the name of the file.
         * @param parent the parent folder of this file.
         * (I really want to write the location where the file is at but
         * that is not the really what that is.)
         */
        TextFile(const std::string& name, Directory* parent);
    
        virtual ~TextFile() = default;
    
        using File::operator[];
    
        /**
         * This operator returns the file that is in the given relative path from this file.
         * @param path The relative path to search at.
         * @return A reference to the file in the relative path.
         */
        virtual File& operator[](std::list<std::string> path) override;
    
        /**
         * This operator returns the file that is in the given relative path from this file.
         * @param path The relative path to search at.
         * @return A reference to the file in the relative path.
         */
        virtual const File& operator[](std::list<std::string> path) const override;
    
        /**
         * Creates a ReadAction of a fitting type to the inputted user data.
         * @param request The data to send to create the action.
         * @return The action created.
         */
        virtual std::unique_ptr<Action> CreateReadAction(ReadRequest& request) const override;
    
        /**
         * Creates a WriteAction of a fitting type to the inputted user data.
         * @param request The data to send to create the action.
         * @return The action created.
         */
        virtual std::unique_ptr<Action> CreateWriteAction(WriteRequest& request) override;
    
        /**
         * Creates a SearchAction of a fitting type to the inputted user data.
         * @param request The data to send to create the action.
         * @return The action created.
         */
        virtual std::unique_ptr<Action> CreateSearchAction(SearchRequest& request) const override;
    
        /**
         * Adds lines of text to the file.
         * @param fileContent The lines of text to add
         *                    (each line is a string in the vector(proof. Obvious))
         */
        void addFileText(const std::vector<std::string>& fileContent);
    
    private:
        std::vector<std::string> lines;
    
        // returns a copy of the lines in the file.
        std::vector<std::string> getLinesInFile(const std::string& wordToSearch) const;
    };