Skip to content

A lightweight C++ string handling class with built-in Undo and Redo functionality using stacks. Ideal for text-based tools, editors, and educational projects. Implements clean property-style access and efficient history tracking.

Notifications You must be signed in to change notification settings

AmrTamerTech/clsString_With_Undo_Redo_Feature-CPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Œ clsMyString – Custom Stack with REDO & UNDO Feature ⚑

A C++ class for managing strings with built-in undo/redo functionality using stacks. πŸš€


🌟 Project Overview

The clsMyString class provides a powerful string management system with the ability to undo and redo changes. It uses two internal stacks to track modifications, allowing users to revert or reapply changes efficientlyβ€”perfect for command-based interfaces, mini text editors, and learning projects.


πŸ”Ή Core Functionalities

  • ✏️ Set and Get String Values
  • βͺ Undo Last Change
  • ⏩ Redo Last Undone Change

This class makes it easy to maintain a history of string changes while offering a clean interface using property-style accessors in C++.


✨ Features

πŸ”Ή Basic String Operations

  • SetValue(string): Updates the string and saves the old value for undo.
  • GetValue(): Retrieves the current string value.
  • Value property: Provides clean access using __declspec(property).

πŸ”Ή Undo/Redo Functionality

  • Undo(): Restores the previous string state.
  • Redo(): Reapplies the last undone change.

πŸš€ How It Works

πŸ”Ή Managing String Changes

  • When SetValue() is called, the current value is pushed onto the undo stack.
  • Undo() pushes the current value to the redo stack and restores the top of the undo stack.
  • Redo() pushes the current value to the undo stack and restores the top of the redo stack.

πŸ”Ή Memory Management

  • Stack-based operations are fast and efficient.
  • Only necessary values are stored, avoiding memory bloat.

πŸ“š Potential Enhancements

  • πŸ— History Limit: Add a configurable limit to undo/redo history.
  • πŸ” Change Tracking: Store diffs instead of full strings.
  • πŸ“‚ Persistence: Save and load history from files.
  • πŸš€ Thread Safety: Add support for multithreaded environments.

βš™οΈ Technologies Used

  • Language: C++
  • Stacks: std::stack for undo/redo history
  • Strings: std::string for value storage
  • Property Access: __declspec(property) for clean getter/setter usage

🎯 Learning Outcomes

This project demonstrates:

βœ… Stack-based undo/redo implementation
βœ… Property-style encapsulation in C++
βœ… Efficient and reversible state management
βœ… Clean, modular class design


πŸ“œ License

This project is open-source. Feel free to modify and enhance it! πŸš€


🀝 Contributing

Pull requests and improvements are welcome. If you have ideas, feel free to fork the repo and submit a PR!


🏁 Ready to Explore?

πŸš€ How to Run

  1. Clone or download the repository.
  2. Include clsMyString.h in your project.
  3. Create a simple main.cpp and compile:
    g++ main.cpp -o run
    ./run

About

A lightweight C++ string handling class with built-in Undo and Redo functionality using stacks. Ideal for text-based tools, editors, and educational projects. Implements clean property-style access and efficient history tracking.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages