MeshLib C++ Docs
Loading...
Searching...
No Matches
MRIOParsing.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#include "MRExpected.h"
4#include "MRBuffer.h"
5#include "MRPch/MRBindingMacros.h"
6#include <istream>
7
8namespace MR
9{
10
11// returns offsets for each new line in monolith char block
12MRMESH_API std::vector<size_t> splitByLines( const char* data, size_t size );
13
14// get the size of the remaining data in the input stream
15// This has `MR_BIND_IGNORE` for now because it doesn't look very useful in C, since our `istream` bindings are minimal (the only istream you
16// can access is `std::cin`). If we expand them later, this can be added back.
17// Note that if you decide to un-ignore this, the return type has to be changed to our `Int64` typedef to avoid issues on Mac.
18MRMESH_API MR_BIND_IGNORE std::streamoff getStreamSize( std::istream& in );
19
20// reads input stream to string
21// This has `MR_BIND_IGNORE` for now because it doesn't look very useful in C, since our `istream` bindings are minimal (the only istream you
22// can access is `std::cin`). If we expand them later, this can be added back.
24
25// reads input stream to monolith char block
27
28// read coordinates to `v` separated by space
29template<typename T>
30Expected<void> parseTextCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* n = nullptr, Color* c = nullptr );
31template<typename T>
32Expected<void> parseObjCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* c = nullptr );
33template<typename T>
34Expected<void> parsePtsCoordinate( const std::string_view& str, Vector3<T>& v, Color& c );
35
36// reads the first integer number in the line
37MRMESH_API Expected<void> parseFirstNum( const std::string_view& str, int& num );
38// reads the polygon points and optional number of polygon points
39// example
40// N vertex0 vertex1 ... vertexN
41MRMESH_API Expected<void> parsePolygon( const std::string_view& str, VertId* vertId, int* numPoints );
42
43template<typename T>
44[[deprecated( "use parseTextCoordinate() instead")]]
45Expected<void> parseAscCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* n = nullptr, Color* c = nullptr );
46
47
48
49template<typename T>
50Expected<void> parseSingleNumber( const std::string_view& str, T& num );
51
52}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
Definition MRCameraOrientationPlugin.h:8
Expected< void > parseSingleNumber(const std::string_view &str, T &num)
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:29
MRMESH_API std::vector< size_t > splitByLines(const char *data, size_t size)
MRMESH_API MR_BIND_IGNORE std::streamoff getStreamSize(std::istream &in)
tl::expected< T, E > Expected
Definition MRExpected.h:25
MRMESH_API MR_BIND_IGNORE Expected< std::string > readString(std::istream &in)
Expected< void > parseTextCoordinate(const std::string_view &str, Vector3< T > &v, Vector3< T > *n=nullptr, Color *c=nullptr)
MRMESH_API Expected< void > parsePolygon(const std::string_view &str, VertId *vertId, int *numPoints)
MRMESH_API Expected< void > parseFirstNum(const std::string_view &str, int &num)
Expected< void > parseObjCoordinate(const std::string_view &str, Vector3< T > &v, Vector3< T > *c=nullptr)
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:10
MRMESH_API MR_BIND_IGNORE Expected< Buffer< char > > readCharBuffer(std::istream &in)
Expected< void > parsePtsCoordinate(const std::string_view &str, Vector3< T > &v, Color &c)
Expected< void > parseAscCoordinate(const std::string_view &str, Vector3< T > &v, Vector3< T > *n=nullptr, Color *c=nullptr)
Definition MRMesh/MRColor.h:9
Definition MRMesh/MRVector3.h:28