Macaulay2 Engine
Loading...
Searching...
No Matches
util.hpp File Reference

Conversion helpers between M2 boundary types and standard C++ containers. More...

#include <string>
#include <vector>
#include <iostream>
#include "interface/m2-mem.h"
#include "interface/m2-types.h"

Go to the source code of this file.

Functions

M2_string string_std_to_M2 (const std::string &s)
std::string string_M2_to_std (const M2_string s)
void M2_ArrayString_to_stdvector (M2_ArrayString strs, std::vector< std::string > &result)
std::vector< std::string > M2_ArrayString_to_stdvector (M2_ArrayString strs)
M2_ArrayString stdvector_to_M2_ArrayString (const std::vector< std::string > &strs)
template<typename T>
M2_arrayint stdvector_to_M2_arrayint (const std::vector< T > &v)
template<typename T>
std::vector< TM2_arrayint_to_stdvector (M2_arrayint arr)
template<typename T>
std::ostream & operator<< (std::ostream &o, const std::vector< T > &ts)

Detailed Description

Conversion helpers between M2 boundary types and standard C++ containers.

Note
AI-generated documentation. Verify against the source before relying on it.

Provides the bidirectional converters every engine boundary needs, all inline so call sites stay free. Strings: string_std_to_M2 / string_M2_to_std marshal between std::string and M2_string (the engine's length-prefixed type). String arrays: M2_ArrayString_to_stdvector (in two overloads — one filling a caller-supplied std::vector<std::string>&, one returning a fresh vector) and stdvector_to_M2_ArrayString. Integer arrays: stdvector_to_M2_arrayint is templated on the element type T (with overloads for both std::vector<T> and gc_vector<T>), static_cast-ing each entry to int; the inverse M2_arrayint_to_stdvector<T> produces a fresh std::vector<T>. A trailing templated operator<<(std::ostream&, const std::vector<T>&) overload provides a [a b c ]-style debug dump for any printable element type.

See also
interface/m2-types.h

Definition in file util.hpp.