Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RCM – Resource Compiler & Manager

RCM is a lightweight C++17 library that embeds binary resources (files, strings, images, etc.) directly into your executable and provides a simple, cached interface to load them at runtime.

  • Windows uses native Win32 resources (.rc file) – resources are embedded in the PE resource section.
  • Other OS (Linux, macOS, etc.) generates a .h / .cpp pair containing byte arrays of the files – resources are linked as plain data.

The manager caches loaded resources so repeated requests are instant.


Features

  • ✅ Embed any file as a resource (binary or text)
  • ✅ Cross‑platform API: same RCM::Read() call on all OS
  • ✅ Automatic caching – load once, reuse many times
  • ✅ Convenience wrappers: ReadChars()std::vector<char>, ReadString()std::string
  • ✅ No external dependencies beyond the C++ standard library

How It Works

1. Embedding resources (build step)

You run a resource compiler tool (not included – see “Integration” below) that reads a list of files and generates:

Platform Generated files How it’s linked
Windows resources.rc + resource.h Compiled by rc.exe and linked into the executable
Other resources.h + resources.cpp Compiled and linked directly (byte arrays)

Each resource is assigned a unique integer ID.

2. Runtime loading (RCM namespace)

  • On Windows: RCM::Read(id, type) uses FindResourceW / LoadResource / LockResource to fetch the raw data.
  • On other OS: the generated GetResourceData(id, size) function is called, returning a pointer to the embedded byte array.

All successfully loaded resources are stored in an internal unordered_map<int, shared_ptr<VFile>> cache.


Requirements

  • C++17 compiler (tested with MSVC, GCC, Clang)
  • The VFile class must be defined elsewhere (see below)

The VFile class

RCM expects a simple VFile type with at least:

class VFile {
public:
    VFile();                               // invalid empty file
    VFile(const void* data, size_t size);  // copies or references data (implementation defined)
    bool isValid() const;
    const void* data;
    size_t size;
};

how to use

if you are in windows use this. (if not just use normal add_executable)

add_executable(... ${CMAKE_CURRENT_BINARY_DIR}/${RCM_PROJECT_PATH}/resources.rc)

then add the files which you want and then add the project as a subproject

set(RCM_FILES
    "id_number|${CMAKE_CURRENT_SOURCE_DIR}/path/to/file"

    #example
    "4000|${CMAKE_CURRENT_SOURCE_DIR}/Assets/themes.json"
    CACHE INTERNAL "RCM resource list"
)

add_subdirectory(thirdparty/RCM)

target_link_libraries(project PRIVATE RCM)

About

a resource manager by cpp

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages