MeshLib
 
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 <istream>
6
7namespace MR
8{
9
10// returns offsets for each new line in monolith char block
11MRMESH_API std::vector<size_t> splitByLines( const char* data, size_t size );
12
13// get the size of the remaining data in the input stream
14MRMESH_API std::streamoff getStreamSize( std::istream& in );
15
16// reads input stream to string
18
19// reads input stream to monolith char block
21
22// read coordinates to `v` separated by space
23template<typename T>
24Expected<void> parseTextCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* n = nullptr, Color* c = nullptr );
25template<typename T>
26Expected<void> parseObjCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* c = nullptr );
27template<typename T>
28Expected<void> parsePtsCoordinate( const std::string_view& str, Vector3<T>& v, Color& c );
29
30// reads the first integer number in the line
31MRMESH_API Expected<void> parseFirstNum( const std::string_view& str, int& num );
32// reads the polygon points and optional number of polygon points
33// example
34// N vertex0 vertex1 ... vertexN
35MRMESH_API Expected<void> parsePolygon( const std::string_view& str, VertId* vertId, int* numPoints );
36
37template<typename T>
38[[deprecated( "use parseTextCoordinate() instead")]]
39Expected<void> parseAscCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* n = nullptr, Color* c = nullptr );
40
41
42
43template<typename T>
44Expected<void> parseSingleNumber( const std::string_view& str, T& num );
45
46}
int VertId
Definition MRDotNet/MRMeshFwd.h:51
#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)
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)
MRMESH_API 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)
MRMESH_API std::streamoff getStreamSize(std::istream &in)
Definition MRColor.h:9
Definition MRMesh/MRVector3.h:19