MicroStation® is a computer-aided-design (CAD) tool produced by Bentley Systems. It is used by engineers, architects, and draughting technicians to create 3D models and 2D drawings.
MicroStation can be customised. Bentley Systems themselves have many applications for specialised markets that use MicroStation as a platform. Third-parties likewise may use MicroStation as a platform on which to develop their application software. Bentley Systems provide the MicroStation Software Development Kit (SDK) that software developers use to create their applications.
The SDK has two libraries: the MicroStation Development Library (MDL) and the MicroStationAPI. The MicroStation Development Library contains thousands of functions that provide a C-language interface. The MicroStationAPI provides an object-oriented C++ interface.
StringLib provides some String Library free functions and a CfgVar class to help with
configuration variables.
Some of the string functions are general-purpose: for example, there's a string splitter,
useful for dealing with multi-path configuration variables.
The CfgVar class wraps some of the mdlSystem_api functions that deal with
configuration variables.
The String Library uses the C++ Standard Library,
including std::string and std::vector.
The String Library lives inside the LASolutions namespace.
The free functions live in the StringLib nested namespace.
typedefs
If you're not familiar with the Standard Library or templates,
the typedef syntax may appear as if a cat walked over the keyboard.
We want to have an elastic array of values; the Standard Library calls an
elastic array a <vector>.
We declare a vector of strings like this …
std::vector<std::string> elasticArrayOfStrings;
However, typing all those chevrons become tedious, so we create an alias,
known in C as a typedef.
Here's the alias for our elastic array of strings …
typedef std::vector<std::string> StringCollection;
Having created that alias, our variable declaration is a lot clearer …
StringCollection elasticArrayOfStrings;
Here's the public interface for the CfgVar class.
I've removed the namespace to simplify what you see here …
bool Valid () const; void SetCfgVar (char const* cfgvar); std::string const& GetCfgVar () const; std::string Definition () const; std::string Expand () const; bool IsMultipath () const; int Paths (LASolutions::StringCollection& paths) const; CfgVar (char const* cfgvar);
Instantiate the CfgVar class with the name of a
configuration variable. Then use its methods to see the
definition or expanded value of that variable.
For example …
#include <StringLibImpl.h>
CfgVar cfgVar ("MS_DEF");
if (cfgVar.Valid ())
{
std::string definition = cfgVar.Definition (); // e.g. $(PROJECTS)project1/dgn/
std::string expanded = cfgVar.Expand (); // e.g. C:/projects/project1/dgn/
}
Instantiate the CfgVar class with the name of a
configuration variable. Then use its methods to see the
definition or expanded value of that variable.
Often, configuration variable MS_DEF or MS_RFDIR
is a multipath variable:
that is, it contains a list of folders separated (usually) by a semi-colon.
For example …
#include <StringLibImpl.h>
CfgVar cfgVar ("MS_DEF");
if (cfgVar.Valid ())
{
std::string definition = cfgVar.Definition (); // e.g. $(PROJECTS)project1/dgn/;$(COMMON)borders/;$(SHARED_PROJECT_DATA)components/
std::string expanded = cfgVar.Expand (); // e.g. C:/projects/project1/dgn/;V:/group/cad/borders/;V:/construction/detail/components/
StringCollection paths;
if (cfgVar.Paths (paths))
{
// Iterate paths in StringCollection
// e.g. C:/projects/project1/dgn/
// V:/group/cad/borders/
// V:/construction/detail/components/
}
}
We've created a sample project that exercises StringLib.
It provides examples of the free function usage as well as CfgVar class usage.
The StringLib project provides two MicroStation keyin commands …
STRINGLIB CFGVAR EXPAND CLASS <variable-name>: illustrates the CfgVar class
STRINGLIB CFGVAR EXPAND PROCEDURAL <variable-name>: illustrates the free functions
Download the StringLib project.
This ZIP file contains C++ source code header and implementation files, and a bmake (.mke) file to build the project.
You need
Visual Studio 2005 to be installed in order to compile this project.