Skip to content

szaghi/StringiFor

Repository files navigation

StringiFor

Strings Fortran Manipulator with steroids

a pure Fortran 2003+ library providing an OOP string type with Python-like methods for modern Fortran projects.

GitHub tag GitHub issues CI coverage License

🔤 Rich String API
upper, lower, camelcase, snakecase, split, join, replace, search, unique — Python-like methods on modern Fortran strings
🔢 Number Casting
Assign any PENF integer or real kind directly to a string; cast back with to_number(kind=...) at compile-time
📁 File & Path I/O
read_file, write_file, read_line, write_line, basedir, basename, extension, glob — batteries included
🎨 Encoding & Color
Base64 encode/decode via BeFoR64; ANSI terminal colorize via FACE
Pure & Elemental
Almost all methods are pure or elemental — thread-safe, no side effects
🔗 Seamless Interop
Overloaded =, //, and comparison operators — string is a drop-in for standard character
🔓 Multi-licensed
GPL v3 · BSD 2/3-Clause · MIT
📦 Multiple build systems
fpm, FoBiS, CMake, Make

For full documentations (guide, tutorial, examples, etc...) see the StringiFor website.


Authors

Contributions are welcome — see the Contributing page.

Copyrights

This project is distributed under a multi-licensing system:

Anyone interested in using, developing, or contributing to this project is welcome — pick the license that best fits your needs.


Quick start

use stringifor
implicit none
type(string) :: s

s = 'Hello, World!'
print "(A)", s%upper()//''      ! HELLO, WORLD!
print "(A)", s%replace(old='World', new='Fortran')//''  ! Hello, Fortran!
print "(A)", s%camelcase()//''  ! Hello,World!

s = 3.14159_R8P
print "(A)", s//''              ! +3.14159000000000E+00
print "(L1)", s%is_real()       ! T

Install

FoBiS

Standalone — clone, fetch dependencies, and build:

git clone https://github.com/szaghi/StringiFor && cd StringiFor
FoBiS.py fetch                                    # fetch PENF, FACE, BeFoR64
FoBiS.py build -mode stringifor-static-gnu        # build static library

Or install directly in one command:

FoBiS.py install szaghi/StringiFor -mode static-gnu
FoBiS.py install szaghi/StringiFor -mode static-gnu --prefix /path/to/prefix

As a project dependency — declare StringiFor in your fobos and run fetch:

[dependencies]
deps_dir = src/third_party
StringiFor   = https://github.com/szaghi/StringiFor
FoBiS.py fetch           # fetch and build
FoBiS.py fetch --update  # re-fetch and rebuild

fpm

Add to your fpm.toml:

[dependencies]
StringiFor = { git = "https://github.com/szaghi/StringiFor" }
fpm build
fpm test

CMake

cmake -B build && cmake --build build

Makefile

make              # static library
make TESTS=yes    # build and run tests

About

Strings Fortran Manipulator with steroids

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors