MeshLib Documentation
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
15MRMESH_API std::streamoff getStreamSize( std::istream& in );
16
17// reads input stream to string
19
20// reads input stream to monolith char block
21MR_BIND_IGNORE MRMESH_API Expected<Buffer<char>> readCharBuffer( std::istream& in );
22
23// read coordinates to `v` separated by space
24template<typename T>
25Expected<void> parseTextCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* n = nullptr, Color* c = nullptr );
26template<typename T>
27Expected<void> parseObjCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* c = nullptr );
28template<typename T>
29Expected<void> parsePtsCoordinate( const std::string_view& str, Vector3<T>& v, Color& c );
30
31// reads the first integer number in the line
32MRMESH_API Expected<void> parseFirstNum( const std::string_view& str, int& num );
33// reads the polygon points and optional number of polygon points
34// example
35// N vertex0 vertex1 ... vertexN
36MRMESH_API Expected<void> parsePolygon( const std::string_view& str, VertId* vertId, int* numPoints );
37
38template<typename T>
39[[deprecated( "use parseTextCoordinate() instead")]]
40Expected<void> parseAscCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* n = nullptr, Color* c = nullptr );
41
42
43
44template<typename T>
45Expected<void> parseSingleNumber( const std::string_view& str, T& num );
46
47}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRCameraOrientationPlugin.h:8
Expected< void > parseSingleNumber(const std::string_view &str, T &num)
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
MRMESH_API std::vector< size_t > splitByLines(const char *data, size_t size)
MRMESH_API Expected< std::string > readString(std::istream &in)
MR_BIND_IGNORE MRMESH_API Expected< Buffer< char > > readCharBuffer(std::istream &in)
tl::expected< T, E > Expected
Definition MRExpected.h:58
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)
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)
MRMESH_API std::streamoff getStreamSize(std::istream &in)
Definition MRColor.h:9
Definition MRMesh/MRVector3.h:19