Gazebo Common

API Reference

6.0.1
gz::common Namespace Reference

Classes

class  Animation
 Manages an animation, which is a collection of keyframes and the ability to interpolate between the keyframes. More...
 
class  AssimpLoader
 Class used to load mesh files using the assimp lodaer. More...
 
class  AudioDecoder
 An audio decoder based on FFMPEG. More...
 
class  Base64
 
class  Battery
 A battery abstraction. More...
 
class  BVHLoader
 Handles loading BVH animation files. More...
 
class  ColladaExporter
 Class used to export Collada mesh files. More...
 
struct  ColladaLight
 This struct contains light data specifically for collada export Defaults set based on collada 1.4 specifications. More...
 
class  ColladaLoader
 Class used to load Collada mesh files. More...
 
class  Connection
 A class that encapsulates a connection. More...
 
class  Console
 Container for loggers, and global logging options (such as verbose vs. quiet output). More...
 
struct  CSVDialect
 A CSV specification. More...
 
class  CSVIStreamIterator
 A single-pass row iterator on an input stream of CSV data. More...
 
struct  CSVToken
 A token in CSV data. More...
 
class  DataFrame
 An abstract data frame. More...
 
class  Dem
 
class  DirIter
 A class for iterating over all items in a directory. More...
 
class  Event
 Base class for all events. More...
 
class  EventT
 A class for event processing. More...
 
class  FlagSet
 Set of flags defined by a C++11 enum class. More...
 
class  HeightmapData
 Encapsulates a generic heightmap data file. More...
 
class  HWEncoder
 Representation of a GPU video encoder and its configuration. More...
 
class  Image
 Encapsulates an image. More...
 
class  ImageHeightmap
 Encapsulates an image that will be interpreted as a heightmap. More...
 
struct  IO
 Traits for type-specific object I/O. More...
 
struct  IO< DataFrame< K, math::InMemoryTimeVaryingVolumetricGrid< T, V, P > > >
 Traits for IO of data frames comprised of time varying volumetric grids. More...
 
struct  IO< std::string >
 Traits for string I/O. More...
 
struct  IsEnumThatContainsSentinel
 
struct  IsEnumThatContainsSentinel< T, decltype(static_cast< void >(T::_))>
 
class  KeyEvent
 Generic description of a keyboard event. More...
 
class  KeyFrame
 A key frame in an animation. More...
 
class  LogMessage
 Helper class for providing gzlog macros. More...
 
class  Material
 Encapsulates description of a material. More...
 
class  MaterialDensity
 Encapsulates density types. More...
 
class  Mesh
 A 3D mesh. More...
 
class  MeshExporter
 Base class for exporting meshes. More...
 
class  MeshLoader
 Base class for loading meshes. More...
 
class  MeshManager
 Maintains and manages all meshes. Supported mesh formats are STL (STLA, STLB), COLLADA, OBJ, GLTF (GLB) and FBX. By default only GLTF and FBX are loaded using assimp loader, however if GZ_MESH_FORCE_ASSIMP environment variable is set, then MeshManager will use assimp loader for all supported mesh formats. More...
 
class  MouseEvent
 Generic description of a mouse event. More...
 
class  MovingWindowFilter
 Base class for MovingWindowFilter. More...
 
class  NodeAnimation
 Node animation. More...
 
class  NodeAssignment
 Vertex to node weighted assignment for skeleton animation visualization. More...
 
class  NodeTransform
 A transformation node. More...
 
class  NumericAnimation
 A numeric animation. More...
 
class  NumericKeyFrame
 A keyframe for a NumericAnimation. More...
 
class  OBJLoader
 Class used to load obj mesh files. More...
 
class  Pbr
 This class contains Physically-Based-Rendering (PBR) workflow properties. More...
 
class  PoseAnimation
 A pose animation. More...
 
class  PoseKeyFrame
 A keyframe for a PoseAnimation. More...
 
class  Profiler
 Used to perform application-wide performance profiling. More...
 
class  ScopedProfile
 Used to provide C++ RAII-style profiling sample. The sample will start on the construction of the ScopedProfile object and stop when the object leaves scope. More...
 
class  SignalHandler
 Register callbacks that get triggered on SIGINT and SIGTERM. More...
 
class  SingletonT
 Singleton template class. More...
 
class  Skeleton
 A skeleton, usually used for animation purposes. More...
 
class  SkeletonAnimation
 Skeleton animation. More...
 
class  SkeletonNode
 A skeleton node. More...
 
class  STLLoader
 Class used to load STL mesh files. More...
 
class  SubMesh
 A child mesh. More...
 
class  SVGCommand
 SVG command data structure. More...
 
class  SVGLoader
 A loader for SVG files. More...
 
struct  SVGPath
 An SVG path element data structure. More...
 
class  SystemPaths
 Functions to handle getting system paths, keeps track of: More...
 
class  TempDirectory
 Create a temporary directory in the OS temp location. Upon construction, the current working directory will be set to this new temporary directory. Upon destruction, the current working directory will be restored to the location when the TempDirectory object was constructed. More...
 
class  Timer
 A timer class, used to time things in real world walltime. More...
 
class  TrajectoryInfo
 Information about a trajectory for an animation (e.g., Actor) This contains the keyframe information. More...
 
class  URI
 A complete URI which has the following components: More...
 
class  URIAuthority
 
class  URIFragment
 The fragment component of a URI. More...
 
class  URIPath
 A URI path contains a sequence of segments separated by /. The path may be empty in a valid URI. When an authority is present, the path must start with a /. More...
 
class  URIQuery
 The query component of a URI. More...
 
class  Uuid
 A portable class for representing a Universally Unique Identifier. More...
 
class  Video
 Handle video encoding and decoding using libavcodec. More...
 
class  VideoEncoder
 The VideoEncoder class supports encoding a series of images to a video format, and then writing the video to disk. More...
 
class  WorkerPool
 A pool of worker threads that do stuff in parallel. More...
 

Typedefs

typedef std::shared_ptr< BatteryBatteryPtr
 
using ConnectionPtr = std::shared_ptr< Connection >
 
template<typename To , typename From >
using ConstCompatible = detail::ConstCompatible< To, From >
 Contains a static constexpr field named value which will be true if the type From has a const-quality less than or equal to the type To.
 
typedef std::runtime_error exception
 A runtime error.
 
using MaterialPtr = std::shared_ptr< Material >
 
using MeshPtr = std::shared_ptr< Mesh >
 
typedef std::map< unsigned int, SkeletonNode * > SkeletonNodeMap
 
using SkeletonPtr = std::shared_ptr< Skeleton >
 
using SubMeshPtr = std::shared_ptr< SubMesh >
 

Enumerations

enum  FilesystemWarningOp { FSWO_LOG_WARNINGS = 0 , FSWO_SUPPRESS_WARNINGS }
 Options for how to handle errors that occur in functions that manipulate the filesystem. More...
 
enum  NodeTransformType { TRANSLATE , ROTATE , SCALE , MATRIX }
 Enumeration of the transform types. More...
 
enum class  NormalMapSpace : int { TANGENT = 0 , OBJECT = 1 }
 Space the normal map is defined in. More...
 
enum class  PbrType : int { NONE = 0 , METAL = 1 , SPECULAR = 2 }
 Type of PBR workflow. More...
 

Functions

std::string absPath (const std::string &_path)
 Get the absolute path of a provided path. Relative paths are resolved relative to the current working directory.
 
void addFindFileURICallback (std::function< std::string(const URI &)> _cb)
 Add a callback to use when findFile() can't find a file that is a valid URI. The callback should return a full local path to the requested file, or and empty string if the file was not found in the callback. Callbacks will be called in the order they were added until a path is found.
 
void addSearchPathSuffix (const std::string &_suffix)
 add path suffix to common::SystemPaths
 
std::string av_err2str_cpp (int errnum)
 
std::string basename (const std::string &_path)
 Given a path, get just the basename portion.
 
void changeFromUnixPath (std::string &_path)
 Replace forward-slashes '/' with the preferred directory separator of the current operating system. On Windows, this will turn forward-slashes into backslashes. If forward-slash is the preferred separator of the current operating system, this will do nothing.
 
void changeToUnixPath (std::string &_path)
 Replace the preferred directory separator of the current operating system with a forward-slash '/'. On Windows, this will turn backslashes into forward-slashes.
 
bool chdir (const std::string &_dir)
 Change current working directory to _dir.
 
bool copyDirectory (const std::string &_existingDirname, const std::string &_newDirname, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Copy a directory, overwrite the destination directory if exists.
 
bool copyFile (const std::string &_existingFilename, const std::string &_newFilename, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Copy a file.
 
std::string copyFromUnixPath (const std::string &_path)
 Returns a copy of _path which has been passed through changeFromUnixPath.
 
std::string copyToUnixPath (const std::string &_path)
 Returns a copy of _path which has been passed through changeToUnixPath.
 
bool createDirectories (const std::string &_path)
 Create directories for the given path.
 
bool createDirectory (const std::string &_path)
 Create a new directory on the filesystem. Intermediate directories must already exist.
 
std::string createTempDirectory (const std::string &_baseName, const std::string &_parentPath, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Create a directory in the tempDirectoryPath by expanding a name template.
 
std::string cwd ()
 Get the current working directory.
 
bool GZ_COMMON_GRAPHICS_VISIBLE DelaunayTriangulation (const std::vector< gz::math::Vector2d > &_vertices, const std::vector< gz::math::Vector2i > &_edges, SubMesh *_submesh)
 Perform delaunay triangulation on input vertices.
 
bool EndsWith (const std::string &_s1, const std::string &_s2)
 return true if string ends with another string
 
bool env (const std::string &_name, std::string &_value)
 Find the environment variable '_name' and return its value.
 
bool env (const std::string &_name, std::string &_value, bool _allowEmpty)
 Find the environment variable '_name' and return its value.
 
bool exists (const std::string &_path)
 Determine whether the given path exists on the filesystem.
 
GZ_COMMON_IO_VISIBLE std::istreamExtractCSVToken (std::istream &_stream, CSVToken &_token, const CSVDialect &_dialect=CSVDialect::Unix)
 Extract a single token from an input stream of CSV data.
 
std::string findFile (const std::string &_file)
 search for file in common::SystemPaths
 
std::string findFile (const std::string &_file, bool _searchLocalPath)
 search for file in common::SystemPaths
 
std::string findFilePath (const std::string &_file)
 search for a file in common::SystemPaths
 
constexpr uint64_t hash64 (std::string_view _key)
 fnv1a algorithm for 64-bit platforms.
 
bool isDirectory (const std::string &_path)
 Determine whether the given path is a directory.
 
bool isFile (const std::string &_path)
 Check if the given path is a file.
 
bool isRelativePath (const std::string &_path)
 Check if the given path is relative.
 
std::string Join (const std::vector< std::string > &_orig, char _delim)
 Join a sequence of strings with a delimiter.
 
std::string Join (const std::vector< std::string > &_orig, const std::string &_delim)
 Join a sequence of strings with a delimiter.
 
std::string joinPaths (const std::string &_path)
 base case for joinPaths(...) below
 
std::string joinPaths (const std::string &_path1, const std::string &_path2)
 Join two strings together to form a path.
 
template<typename... Args>
std::string joinPaths (const std::string &_path1, const std::string &_path2, Args const &..._args)
 Append one or more additional path elements to the first passed in argument.
 
void load ()
 Load external libraries, such as libav. It is safe to call this multiple times.
 
std::string logPath ()
 Get the log path.
 
std::string lowercase (const char *_in)
 Transforms a string to its lowercase equivalent.
 
std::string lowercase (const std::string &_in)
 Transforms a string to its lowercase equivalent.
 
void ltrim (std::string &_s)
 In place left trim.
 
std::string ltrimmed (std::string _s)
 Copying left trim.
 
bool moveFile (const std::string &_existingFilename, const std::string &_newFilename, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Move a file.
 
bool GZ_COMMON_IO_VISIBLE operator== (const CSVDialect &_lhs, const CSVDialect &_rhs)
 Check CSV dialects for equality.
 
std::string parentPath (const std::string &_path)
 Given a path, get just its parent path portion, without separator at the end.
 
GZ_COMMON_IO_VISIBLE std::istreamParseCSVRow (std::istream &_stream, std::vector< std::string > &_row, const CSVDialect &_dialect=CSVDialect::Unix)
 Parse a single row from an input stream of CSV data.
 
std::string PluralCast (const std::string &_baseWord, const int _n)
 Choose whether to use a singular or plural version of a noun based on the value of an integer quantity. This version will simply add an 's' character to _baseWord in the event that std::abs(_n) != 1, otherwise it returns _baseWord.
 
std::string PluralCast (const std::string &_singular, const std::string &_plural, const int _n)
 A version of PluralCast that works for irregular nouns. If std::abs(_n)==1 then _singular is returned; otherwise _plural will be returned.
 
bool removeAll (const std::string &_path, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove a file or a directory and all its contents.
 
bool removeDirectory (const std::string &_path, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove an empty directory.
 
bool removeDirectoryOrFile (const std::string &_path, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove an empty directory or file.
 
bool removeFile (const std::string &_existingFilename, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
 Remove a file.
 
std::string replaceAll (const std::string &_orig, const std::string &_key, const std::string &_replacement)
 Replace all occurances of _key with _replacement.
 
void replaceAll (std::string &_result, const std::string &_orig, const std::string &_key, const std::string &_replacement)
 Replace all occurances of _key with _replacement.
 
void rtrim (std::string &_s)
 In place right trim.
 
std::string rtrimmed (std::string _s)
 Copying right trim.
 
std::string const separator (std::string const &_s)
 Append the preferred path separator character for this platform onto the passed-in string.
 
bool setenv (const std::string &_name, const std::string &_value)
 Set the environment variable '_name'.
 
template<typename T >
std::string sha1 (const T &_buffer)
 Compute the SHA1 hash of an array of bytes.
 
std::string sha1 (void const *_buffer, std::size_t _byteCount)
 Compute the SHA1 hash of an array of bytes. Use std::string sha1(const T &_buffer) instead of this function.
 
std::vector< std::stringSplit (const std::string &_orig, char _delim)
 split at a one character delimiter to get a vector of something
 
std::vector< std::stringsplit (const std::string &_str, const std::string &_delim)
 Splits a string into tokens.
 
bool StartsWith (const std::string &_s1, const std::string &_s2)
 return true if string starts with another string
 
common::SystemPathssystemPaths ()
 Get a pointer to the global system paths that is used by all the findFile functions. The returned instance has global shared state for a given process. Care should be taken when manipulating global system paths Caller should not assume ownership of the pointer.
 
std::string systemTimeISO ()
 Please use systemTimeIso() as this function will be deprecated in Gazebo Common 4. Get the wall time as an ISO string: YYYY-MM-DDTHH:MM:SS.NS.
 
std::string systemTimeIso ()
 Get the wall time as an ISO string: YYYY-MM-DDTHH:MM:SS.NS.
 
std::string tempDirectoryPath ()
 Return the path to a directory suitable for temporary files.
 
std::string timeToIso (const std::chrono::time_point< std::chrono::system_clock > &_time)
 Converts a time point to an ISO string: YYYY-MM-DDTHH:MM:SS.NS.
 
void trim (std::string &_s)
 In place trim from both ends.
 
std::string trimmed (std::string _s)
 Copying trim from both ends.
 
std::string uniqueDirectoryPath (const std::string &_dir)
 Unique directory path to not overwrite existing directory.
 
std::string uniqueFilePath (const std::string &_pathAndName, const std::string &_extension)
 Generates a path for a file which doesn't collide with existing files, by appending numbers to it (i.e. (0), (1), ...)
 
bool unsetenv (const std::string &_name)
 Unset the environment variable '_name'.
 
std::string uuid ()
 Get a UUID.
 

Variables

static std::string PixelFormatNames []
 String names for the pixel formats.
 

Detailed Description

This is an internal-use only class encapsulating HW video encoding. All symbols defined here are hidden from the public API.

Typedef Documentation

◆ BatteryPtr

◆ ConnectionPtr

◆ ConstCompatible

template<typename To , typename From >
using ConstCompatible = detail::ConstCompatible<To, From>

Contains a static constexpr field named value which will be true if the type From has a const-quality less than or equal to the type To.

The following expressions will return true:

The following expression will return false:

◆ exception

A runtime error.

◆ MaterialPtr

◆ MeshPtr

◆ SkeletonNodeMap

typedef std::map<unsigned int, SkeletonNode*> SkeletonNodeMap

◆ SkeletonPtr

◆ SubMeshPtr

Enumeration Type Documentation

◆ FilesystemWarningOp

Options for how to handle errors that occur in functions that manipulate the filesystem.

Enumerator
FSWO_LOG_WARNINGS 

Errors that occur during filesystem manipulation should be logged as warnings using gzwarn. (Recommended)

FSWO_SUPPRESS_WARNINGS 

Errors that occur during filesystem manipulation should not be logged. The user will be responsible for checking the system's error flags.

◆ NodeTransformType

Enumeration of the transform types.

Enumerator
TRANSLATE 
ROTATE 
SCALE 
MATRIX 

◆ NormalMapSpace

enum class NormalMapSpace : int
strong

Space the normal map is defined in.

Enumerator
TANGENT 

Tangent space.

OBJECT 

Object space.

◆ PbrType

enum class PbrType : int
strong

Type of PBR workflow.

Enumerator
NONE 

No workflow.

METAL 

Metal/Roughness workflow.

SPECULAR 

Specular/Glossiness workflow.

Function Documentation

◆ absPath()

std::string absPath ( const std::string _path)

Get the absolute path of a provided path. Relative paths are resolved relative to the current working directory.

Parameters
[in]_pathRelative or absolute path.
Returns
Absolute path (with platform-dependent directory separators).

◆ addFindFileURICallback()

void addFindFileURICallback ( std::function< std::string(const URI &)>  _cb)

Add a callback to use when findFile() can't find a file that is a valid URI. The callback should return a full local path to the requested file, or and empty string if the file was not found in the callback. Callbacks will be called in the order they were added until a path is found.

Parameters
[in]_cbThe callback function, which takes a file path or URI and returns the full local path.

◆ addSearchPathSuffix()

void addSearchPathSuffix ( const std::string _suffix)

add path suffix to common::SystemPaths

Parameters
[in]_suffixThe suffix to add.

◆ av_err2str_cpp()

std::string av_err2str_cpp ( int  errnum)
inline

◆ basename()

std::string basename ( const std::string _path)

Given a path, get just the basename portion.

Parameters
[in]_pathThe full path.
Returns
A new string with just the basename portion of the path.

◆ changeFromUnixPath()

void changeFromUnixPath ( std::string _path)

Replace forward-slashes '/' with the preferred directory separator of the current operating system. On Windows, this will turn forward-slashes into backslashes. If forward-slash is the preferred separator of the current operating system, this will do nothing.

Note that this will NOT convert backslashes (or any other separator) into forward slashes, even on operating systems that use forward-slashes as separators.

Parameters
[out]_pathThis string will be directly modified by replacing its forward-slashes with the preferred directory separator of the current operating system.

◆ changeToUnixPath()

void changeToUnixPath ( std::string _path)

Replace the preferred directory separator of the current operating system with a forward-slash '/'. On Windows, this will turn backslashes into forward-slashes.

Parameters
[out]_pathThis string will be directly modified to use forward slashes to separate its directory names.

◆ chdir()

bool chdir ( const std::string _dir)

Change current working directory to _dir.

Parameters
[in]_dirThe directory to change to.
Returns
Whether the operation succeeded.

◆ copyDirectory()

bool copyDirectory ( const std::string _existingDirname,
const std::string _newDirname,
const FilesystemWarningOp  _warningOp = FSWO_LOG_WARNINGS 
)

Copy a directory, overwrite the destination directory if exists.

Parameters
[in]_sourcePath to an existing directory to copy from.
[in]_destinationPath to the destination directory.
Returns
True on success.

◆ copyFile()

bool copyFile ( const std::string _existingFilename,
const std::string _newFilename,
const FilesystemWarningOp  _warningOp = FSWO_LOG_WARNINGS 
)

Copy a file.

Parameters
[in]_existingFilenamePath to an existing file.
[in]_newFilenamePath of the new file.
[in]_warningOpLog or suppress warnings that may occur.
Returns
True on success.

◆ copyFromUnixPath()

std::string copyFromUnixPath ( const std::string _path)

Returns a copy of _path which has been passed through changeFromUnixPath.

Parameters
[in]_pathThe path to start with
Returns
A modified path that uses the preferred directory separator of the current operating system.

◆ copyToUnixPath()

std::string copyToUnixPath ( const std::string _path)

Returns a copy of _path which has been passed through changeToUnixPath.

Parameters
[in]_pathThe path to start with
Returns
A modified path that uses forward slashes to separate directory names.

◆ createDirectories()

bool createDirectories ( const std::string _path)

Create directories for the given path.

Parameters
[in]_pathPath to create directories from
Returns
true on success

◆ createDirectory()

bool createDirectory ( const std::string _path)

Create a new directory on the filesystem. Intermediate directories must already exist.

Parameters
[in]_pathThe new directory path to create
Returns
True if directory creation was successful, false otherwise.

◆ createTempDirectory()

std::string createTempDirectory ( const std::string _baseName,
const std::string _parentPath,
const FilesystemWarningOp  _warningOp = FSWO_LOG_WARNINGS 
)

Create a directory in the tempDirectoryPath by expanding a name template.

On execution, will create the directory: "_parentPath"/"_baseName" + "XXXXXX", where XXXXXX will be filled out by an OS-appropriate method (eg mkdtmp/_mktemp_s)

Parameters
[in]_baseNameString to be prepended to the expanded template
[in]_parentPathLocation to create the directory
[in]_warningOpAllow or suppress filesystem warnings
Returns
Path to newly-created temporary directory

◆ cwd()

std::string cwd ( )

Get the current working directory.

Returns
Name of the current directory

◆ DelaunayTriangulation()

bool GZ_COMMON_GRAPHICS_VISIBLE DelaunayTriangulation ( const std::vector< gz::math::Vector2d > &  _vertices,
const std::vector< gz::math::Vector2i > &  _edges,
SubMesh _submesh 
)

Perform delaunay triangulation on input vertices.

Parameters
[in]_verticesA list of all vertices
[in]_edgesA list of edges. Each edge is made of 2 vertex indices from _vertices
[out]_submeshA submesh that will be populated with the resulting triangles.
Returns
True on success.

◆ EndsWith()

bool EndsWith ( const std::string _s1,
const std::string _s2 
)

return true if string ends with another string

Parameters
[in]_s1the string to check
[in]_s2the possible suffix
Returns
true if _s1 ends with _s2

◆ env() [1/2]

bool env ( const std::string _name,
std::string _value 
)

Find the environment variable '_name' and return its value.

\TODO(mjcarroll): Deprecate and remove in tick-tock.

Parameters
[in]_nameName of the environment variable.
[out]_valueValue if the variable was found.
Returns
True if the variable was found or false otherwise.

◆ env() [2/2]

bool env ( const std::string _name,
std::string _value,
bool  _allowEmpty 
)

Find the environment variable '_name' and return its value.

Parameters
[in]_nameName of the environment variable.
[out]_valueValue if the variable was found.
[in]_allowEmptyAllow set-but-empty variables. (Unsupported on Windows)
Returns
True if the variable was found or false otherwise.

◆ exists()

bool exists ( const std::string _path)

Determine whether the given path exists on the filesystem.

Parameters
[in]_pathThe path to check for existence
Returns
True if the path exists on the filesystem, false otherwise.

◆ ExtractCSVToken()

GZ_COMMON_IO_VISIBLE std::istream & ExtractCSVToken ( std::istream _stream,
CSVToken _token,
const CSVDialect _dialect = CSVDialect::Unix 
)

Extract a single token from an input stream of CSV data.

If tokenization fails, the CSV data stream failbit will be set.

Parameters
[in]_streamA stream of CSV data to tokenize.
[out]_tokenOutput CSV token to extract into.
[in]_dialectCSV data dialect. Defaults to the Unix dialect.
Returns
same CSV data stream.

◆ findFile() [1/2]

std::string findFile ( const std::string _file)

search for file in common::SystemPaths

Parameters
[in]_fileName of the file to find.
Returns
The path containing the file.

◆ findFile() [2/2]

std::string findFile ( const std::string _file,
bool  _searchLocalPath 
)

search for file in common::SystemPaths

Parameters
[in]_fileName of the file to find.
[in]_searchLocalPathTrue to search in the current working directory.
Returns
The path containing the file.

◆ findFilePath()

std::string findFilePath ( const std::string _file)

search for a file in common::SystemPaths

Parameters
[in]_filethe file name to look for.
Returns
The path containing the file.

◆ hash64()

constexpr uint64_t hash64 ( std::string_view  _key)
constexpr

fnv1a algorithm for 64-bit platforms.

Parameters
[in]_keyThe input string.
Returns
A 64-bit unsigned hash value. https://notes.underscorediscovery.com/constexpr-fnv1a/

◆ isDirectory()

bool isDirectory ( const std::string _path)

Determine whether the given path is a directory.

Parameters
[in]_pathThe path to check
Returns
True if given path exists and is a directory, false otherwise.

◆ isFile()

bool isFile ( const std::string _path)

Check if the given path is a file.

Parameters
[in]_pathPath to a file.
Returns
True if _path is a file.

◆ isRelativePath()

bool isRelativePath ( const std::string _path)

Check if the given path is relative.

Parameters
[in]_pathPath.
Returns
True if _path is relative.

◆ Join() [1/2]

std::string Join ( const std::vector< std::string > &  _orig,
char  _delim 
)

Join a sequence of strings with a delimiter.

Note that this will skip any empty entries in the vector, and will also not prepend or append the delimiter to the final output string

Parameters
[in]_origThe input sequence of strings
[in]_delima character to join the string with
Returns
a single string composed of strings joined with the delimiter

◆ Join() [2/2]

std::string Join ( const std::vector< std::string > &  _orig,
const std::string _delim 
)

Join a sequence of strings with a delimiter.

Note that this will skip any empty entries in the vector, and will also not prepend or append the delimiter to the final output string

Parameters
[in]_origThe input sequence of strings
[in]_delima string delimiter to join the string with
Returns
a single string composed of strings joined with the delimiter

◆ joinPaths() [1/3]

std::string joinPaths ( const std::string _path)
inline

base case for joinPaths(...) below

◆ joinPaths() [2/3]

std::string joinPaths ( const std::string _path1,
const std::string _path2 
)

Join two strings together to form a path.

Parameters
[in]_path1the left portion of the path
[in]_path2the right portion of the path
Returns
Joined path. The function can do simplifications such as elimination of ../ and removal of duplicate // (but is not guaranteed to do so).

Referenced by joinPaths().

◆ joinPaths() [3/3]

template<typename... Args>
std::string joinPaths ( const std::string _path1,
const std::string _path2,
Args const &...  _args 
)
inline

Append one or more additional path elements to the first passed in argument.

Parameters
[in]argsThe paths to append together
Returns
A new string with the paths appended together.

References joinPaths().

◆ load()

void load ( )

Load external libraries, such as libav. It is safe to call this multiple times.

◆ logPath()

std::string logPath ( )

Get the log path.

Returns
the log path

◆ lowercase() [1/2]

std::string lowercase ( const char *  _in)

Transforms a string to its lowercase equivalent.

Parameters
[in]_inString to convert to lowercase
Returns
Lowercase equilvalent of _in.

◆ lowercase() [2/2]

std::string lowercase ( const std::string _in)

Transforms a string to its lowercase equivalent.

Parameters
[in]_inString to convert to lowercase
Returns
Lowercase equilvalent of _in.

◆ ltrim()

void ltrim ( std::string _s)

In place left trim.

Parameters
[in,out]_sString to trim

◆ ltrimmed()

std::string ltrimmed ( std::string  _s)

Copying left trim.

Parameters
[in]_sString to trim
Returns
Trimmed string

◆ moveFile()

bool moveFile ( const std::string _existingFilename,
const std::string _newFilename,
const FilesystemWarningOp  _warningOp = FSWO_LOG_WARNINGS 
)

Move a file.

Parameters
[in]_existingFilenameFull path to an existing file.
[in]_newFilenameFull path of the new file.
[in]_warningOpLog or suppress warnings that may occur.
Returns
True on success.

◆ operator==()

bool GZ_COMMON_IO_VISIBLE operator== ( const CSVDialect _lhs,
const CSVDialect _rhs 
)

Check CSV dialects for equality.

Parameters
[in]_lhsLeft-hand side CSV dialect.
[in]_rhsRight-hand side CSV dialect.
Returns
true if CSV dialects are equal, false otherwise.

◆ parentPath()

std::string parentPath ( const std::string _path)

Given a path, get just its parent path portion, without separator at the end.

Parameters
[in]_pathPath of which to find parent path
Returns
A new string with just the parent path of the path.

◆ ParseCSVRow()

GZ_COMMON_IO_VISIBLE std::istream & ParseCSVRow ( std::istream _stream,
std::vector< std::string > &  _row,
const CSVDialect _dialect = CSVDialect::Unix 
)

Parse a single row from an input stream of CSV data.

If parsing fails, the CSV data stream failbit will be set.

Parameters
[in]_streamCSV data stream to parse.
[out]_rowOutput CSV row to parse into.
[in]_dialectCSV data dialect. Defaults to the Unix dialect.
Returns
same CSV data stream.

◆ PluralCast() [1/2]

std::string PluralCast ( const std::string _baseWord,
const int  _n 
)

Choose whether to use a singular or plural version of a noun based on the value of an integer quantity. This version will simply add an 's' character to _baseWord in the event that std::abs(_n) != 1, otherwise it returns _baseWord.

Parameters
[in]_baseWordthe singular version of the word to return
[in]_nthe quantity that _baseWord is describing
Returns
_baseWord if std::abs(_n)==1, otherwise return _baseWords

◆ PluralCast() [2/2]

std::string PluralCast ( const std::string _singular,
const std::string _plural,
const int  _n 
)

A version of PluralCast that works for irregular nouns. If std::abs(_n)==1 then _singular is returned; otherwise _plural will be returned.

Parameters
[in]_singularthe return value when std::abs(_n) == 1
[in]_pluralthe return value when std::abs(_n) != 1
Returns
_singular if std::abs(_n)==1, otherwise return _plural

◆ removeAll()

bool removeAll ( const std::string _path,
const FilesystemWarningOp  _warningOp = FSWO_LOG_WARNINGS 
)

Remove a file or a directory and all its contents.

Parameters
[in]_pathPath to a directory or file.
[in]_warningOpLog or suppress warnings that may occur.
Returns
True if _path was removed.

◆ removeDirectory()

bool removeDirectory ( const std::string _path,
const FilesystemWarningOp  _warningOp = FSWO_LOG_WARNINGS 
)

Remove an empty directory.

Remarks
the directory must be empty to be removed
Parameters
[in]_pathPath to a directory.
[in]_warningOpLog or suppress warnings that may occur.
Returns
True if _path is a directory and was removed.

◆ removeDirectoryOrFile()

bool removeDirectoryOrFile ( const std::string _path,
const FilesystemWarningOp  _warningOp = FSWO_LOG_WARNINGS 
)

Remove an empty directory or file.

Parameters
[in]_pathPath to a directory or file.
[in]_warningOpLog or suppress warnings that may occur.
Returns
True if _path was removed.

◆ removeFile()

bool removeFile ( const std::string _existingFilename,
const FilesystemWarningOp  _warningOp = FSWO_LOG_WARNINGS 
)

Remove a file.

Parameters
[in]_existingFilenameFull path to an existing file.
[in]_warningOpLog or suppress warnings that may occur.
Returns
True on success.

◆ replaceAll() [1/2]

std::string replaceAll ( const std::string _orig,
const std::string _key,
const std::string _replacement 
)

Replace all occurances of _key with _replacement.

Parameters
[in]_origOriginal string.
[in]_keyString to replace.
[in]_replacementThe string that replaces _key.
Returns
The new string that has had _key replaced with _replacement.
See also
void common::replaceAll(std::string &_result, const std::string &_orig, const std::string &_key, const std::string &_replacement)

◆ replaceAll() [2/2]

void replaceAll ( std::string _result,
const std::string _orig,
const std::string _key,
const std::string _replacement 
)

Replace all occurances of _key with _replacement.

Parameters
[out]_resultThe new string that has had _key replaced with _replacement.
[in]_origOriginal string.
[in]_keyString to replace.
[in]_replacementThe string that replaces _key.
See also
std::string replaceAll(const std::string &_orig, const std::string &_key, const std::string &_replacement)

◆ rtrim()

void rtrim ( std::string _s)

In place right trim.

Parameters
[in,out]_sString to trim

◆ rtrimmed()

std::string rtrimmed ( std::string  _s)

Copying right trim.

Parameters
[in]_sString to trim
Returns
Trimmed string

◆ separator()

std::string const separator ( std::string const &  _s)

Append the preferred path separator character for this platform onto the passed-in string.

Parameters
[in]_sThe path to start with.
Returns
The original path with the platform path separator appended.

◆ setenv()

bool setenv ( const std::string _name,
const std::string _value 
)

Set the environment variable '_name'.

Note that on Windows setting an empty string (_value=="") is the equivalent of unsetting the variable.

Parameters
[in]_nameName of the environment variable.
[in]_valueValue of the variable to be set.
Returns
True if the variable was set or false otherwise.

◆ sha1() [1/2]

template<typename T >
std::string sha1 ( const T &  _buffer)

Compute the SHA1 hash of an array of bytes.

Parameters
[in]_bufferInput sequence. The permitted data types for this function are std::string and any STL container.
Returns
The string representation (40 character) of the SHA1 hash.

◆ sha1() [2/2]

std::string sha1 ( void const *  _buffer,
std::size_t  _byteCount 
)

Compute the SHA1 hash of an array of bytes. Use std::string sha1(const T &_buffer) instead of this function.

Parameters
[in]_bufferInput sequence. The permitted data types for this function are std::string and any STL container.
Returns
The string representation (40 character) of the SHA1 hash.
See also
sha1(const T &_buffer)

◆ Split()

std::vector< std::string > Split ( const std::string _orig,
char  _delim 
)

split at a one character delimiter to get a vector of something

Parameters
[in]_origThe string to split
[in]_delima character to split the string at
Returns
vector of split pieces of the string excluding the delimiter

◆ split()

std::vector< std::string > split ( const std::string _str,
const std::string _delim 
)

Splits a string into tokens.

Parameters
[in]_strInput string.
[in]_delimToken delimiter.
Returns
Vector of tokens.

◆ StartsWith()

bool StartsWith ( const std::string _s1,
const std::string _s2 
)

return true if string starts with another string

Parameters
[in]_s1the string to check
[in]_s2the possible prefix
Returns
true if _s1 starts with _s2

◆ systemPaths()

common::SystemPaths * systemPaths ( )

Get a pointer to the global system paths that is used by all the findFile functions. The returned instance has global shared state for a given process. Care should be taken when manipulating global system paths Caller should not assume ownership of the pointer.

Returns
A mutable reference to the system paths object.

◆ systemTimeISO()

std::string systemTimeISO ( )

Please use systemTimeIso() as this function will be deprecated in Gazebo Common 4. Get the wall time as an ISO string: YYYY-MM-DDTHH:MM:SS.NS.

Returns
The current wall time as an ISO string.
See also
systemTimeIso();

◆ systemTimeIso()

std::string systemTimeIso ( )

Get the wall time as an ISO string: YYYY-MM-DDTHH:MM:SS.NS.

Returns
The current wall time as an ISO string.

◆ tempDirectoryPath()

std::string tempDirectoryPath ( )

Return the path to a directory suitable for temporary files.

Calls std::filesystem::temp_directory_path, refer to the standard documentation for your platform for behaviors.

Returns
A directory suitable for temporary files.

◆ timeToIso()

Converts a time point to an ISO string: YYYY-MM-DDTHH:MM:SS.NS.

Parameters
[in]_timeA time point, such as one created by GZ_SYSTEM_TIME().
Returns
An ISO string that represents the given _time.

◆ trim()

void trim ( std::string _s)

In place trim from both ends.

Parameters
[in,out]_sString to trim

◆ trimmed()

std::string trimmed ( std::string  _s)

Copying trim from both ends.

Parameters
[in]_sString to trim
Returns
Trimmed string

◆ uniqueDirectoryPath()

std::string uniqueDirectoryPath ( const std::string _dir)

Unique directory path to not overwrite existing directory.

Parameters
[in]_pathAndNameFull absolute path
Returns
Full path which doesn't collide with existing files

◆ uniqueFilePath()

std::string uniqueFilePath ( const std::string _pathAndName,
const std::string _extension 
)

Generates a path for a file which doesn't collide with existing files, by appending numbers to it (i.e. (0), (1), ...)

Parameters
[in]_pathAndNameFull absolute path and file name up to the file extension.
[in]_extensionFile extension, such as "sdf".
Returns
Full path with name and extension, which doesn't collide with existing files

◆ unsetenv()

bool unsetenv ( const std::string _name)

Unset the environment variable '_name'.

Parameters
[in]_nameName of the environment variable.
Returns
True if the variable was unset or false otherwise.

◆ uuid()

std::string uuid ( )

Get a UUID.

Returns
A UUID string

Variable Documentation

◆ PixelFormatNames

std::string PixelFormatNames[]
static
Initial value:
=
{
"UNKNOWN_PIXEL_FORMAT",
"L_INT8",
"L_INT16",
"RGB_INT8",
"RGBA_INT8",
"BGRA_INT8",
"RGB_INT16",
"RGB_INT32",
"BGR_INT8",
"BGR_INT16",
"BGR_INT32",
"R_FLOAT16",
"RGB_FLOAT16",
"R_FLOAT32",
"RGB_FLOAT32",
"BAYER_RGGB8",
"BAYER_BGGR8",
"BAYER_GBRG8",
"BAYER_GRBG8",
"COMPRESSED_PNG"
}

String names for the pixel formats.

See also
Image::PixelFormat.