MySQL 9.0.0
Source Code Documentation
Geometry_well_formed_checker Class Reference

WKB scanner event handler that checks if the WKB string is well formed. More...

Inheritance diagram for Geometry_well_formed_checker:
[legend]

Public Member Functions

 Geometry_well_formed_checker (Geometry::wkbType type, Geometry::wkbByteOrder required_byte_order)
 Create a new even handler. More...
 
void on_wkb_start (Geometry::wkbByteOrder bo, Geometry::wkbType geotype, const void *, uint32, bool has_hdr) override
 Notified when scanner sees the start of a geometry WKB. More...
 
void on_wkb_end (const void *wkb) override
 Notified when scanner sees the end of a geometry WKB. More...
 
bool continue_scan () const override
 
bool is_well_formed ()
 Check if the parsed WKB was well-formed, as far as this handler knows. More...
 
const char * get_last_position ()
 Get the position after the last parsed byte. More...
 
- Public Member Functions inherited from WKB_scanner_event_handler
virtual ~WKB_scanner_event_handler ()=default
 

Private Attributes

Prealloced_array< Geometry::wkbType, 8 > type
 
Geometry::wkbType previous_type
 Current stack of types. More...
 
int points_in_linestring
 Type of previous start/end. More...
 
const void * last_position
 Points in current ls. More...
 
bool is_ok
 Last wkb pointer seen. More...
 
Geometry::wkbByteOrder required_byte_order
 Whether the WKB is OK so far. More...
 

Detailed Description

WKB scanner event handler that checks if the WKB string is well formed.

This doesn't check if the geometry is valid (e.g., it's not checking if a polygon is self-intersecting), it only checks some simple rules for WKB well-formedness:

R1. The byte order is as specified (constructor parameter) R2. The wkbType is within the supported range R3. The geometry is of the specified type (constructor parameter), or a subtype R4. Nested geometries contain only geometries that can be contained by that type R5. Linestrings have at least two points R6. Polygon rings have at least four points R7. Polygons have at least one ring R8. Collections, except geometrycollection, contain at least one element.

An additional requirement, that the WKB ends exactly at the end of the string, is checked by Geometry::is_well_formed(). The last parse position is maintained as last_position here to make that test possible.

Constructor & Destructor Documentation

◆ Geometry_well_formed_checker()

Geometry_well_formed_checker::Geometry_well_formed_checker ( Geometry::wkbType  type,
Geometry::wkbByteOrder  required_byte_order 
)
inline

Create a new even handler.

Parameters
typeExpected geometry type. If set to Geometry::wkb_invalid_type, any geometry is allowed.
required_byte_orderThe expected byted order

Member Function Documentation

◆ continue_scan()

bool Geometry_well_formed_checker::continue_scan ( ) const
inlineoverridevirtual

Reimplemented from WKB_scanner_event_handler.

◆ get_last_position()

const char * Geometry_well_formed_checker::get_last_position ( )
inline

Get the position after the last parsed byte.

Returns
Pointer pointing to after the last parsed byte.

◆ is_well_formed()

bool Geometry_well_formed_checker::is_well_formed ( )
inline

Check if the parsed WKB was well-formed, as far as this handler knows.

There may be other conditions that cause the object to not be well-formed.

See also
Geometry::is_well_formed
Returns
True if the WKB was well-formed, false otherwise.

◆ on_wkb_end()

void Geometry_well_formed_checker::on_wkb_end ( const void *  wkb)
inlineoverridevirtual

Notified when scanner sees the end of a geometry WKB.

Parameters
wkbthe position of the first byte after the WKB byte string which the scanner just scanned.

Implements WKB_scanner_event_handler.

◆ on_wkb_start()

void Geometry_well_formed_checker::on_wkb_start ( Geometry::wkbByteOrder  bo,
Geometry::wkbType  geotype,
const void *  wkb,
uint32  len,
bool  has_hdr 
)
inlineoverridevirtual

Notified when scanner sees the start of a geometry WKB.

Parameters
bobyte order of the WKB.
geotypegeometry type of the WKB;
wkbWKB byte string, the first byte after the WKB header if any.
lenNO. of bytes of the WKB byte string starting from wkb. There can be many geometries in the [wkb, wkb+len) buffer.
has_hdrwhether there is a WKB header right before 'wkb' in the byte string.

Implements WKB_scanner_event_handler.

Member Data Documentation

◆ is_ok

bool Geometry_well_formed_checker::is_ok
private

Last wkb pointer seen.

◆ last_position

const void* Geometry_well_formed_checker::last_position
private

Points in current ls.

◆ points_in_linestring

int Geometry_well_formed_checker::points_in_linestring
private

Type of previous start/end.

◆ previous_type

Geometry::wkbType Geometry_well_formed_checker::previous_type
private

Current stack of types.

◆ required_byte_order

Geometry::wkbByteOrder Geometry_well_formed_checker::required_byte_order
private

Whether the WKB is OK so far.

◆ type

Prealloced_array<Geometry::wkbType, 8> Geometry_well_formed_checker::type
private

The documentation for this class was generated from the following file: