KiCad PCB EDA Suite
|
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and from wxString, to and from std::string, and has non-mutating iteration over Unicode characters. More...
#include <utf8.h>
Classes | |
class | uni_iter |
uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded string. More... | |
Public Member Functions | |
UTF8 (const wxString &o) | |
UTF8 (const char *txt) | |
This is a constructor for which you could end up with non-UTF8 encoding, but that would be your fault. | |
UTF8 (const wchar_t *txt) | |
For use with _() function on wx 2.8. | |
UTF8 (const std::string &o) | |
UTF8 () | |
~UTF8 () | |
const char * | c_str () const |
bool | empty () const |
std::string::size_type | find (char c) const |
std::string::size_type | find (char c, size_t s) const |
void | clear () |
std::string::size_type | length () const |
std::string::size_type | size () const |
int | compare (const std::string &s) const |
bool | operator== (const UTF8 &rhs) const |
bool | operator== (const std::string &rhs) const |
bool | operator== (const char *s) const |
bool | operator!= (const UTF8 &rhs) const |
bool | operator< (const UTF8 &rhs) const |
bool | operator> (const UTF8 &rhs) const |
std::string::size_type | find_first_of (const std::string &str, std::string::size_type pos=0) const |
UTF8 & | operator+= (const UTF8 &str) |
UTF8 & | operator+= (char ch) |
UTF8 & | operator+= (const char *s) |
UTF8 & | operator+= (unsigned w_ch) |
Append a wide (unicode) char to the UTF8 string. | |
UTF8 & | operator= (const wxString &o) |
UTF8 & | operator= (const std::string &o) |
UTF8 & | operator= (const char *s) |
UTF8 & | operator= (char c) |
std::string | substr (size_t pos=0, size_t len=npos) const |
operator const std::string & () const | |
wxString | wx_str () const |
operator wxString () const | |
std::string::const_iterator | begin () const |
std::string::const_iterator | end () const |
uni_iter | ubegin () const |
Returns a uni_iter initialized to the start of "this" UTF8 byte sequence. | |
uni_iter | uend () const |
Return a uni_iter initialized to the end of "this" UTF8 byte sequence. | |
Static Public Member Functions | |
static int | uni_forward (const unsigned char *aSequence, unsigned *aResult=nullptr) |
Advance over a single UTF8 encoded multibyte character, capturing the Unicode character as it goes, and returning the number of bytes consumed. | |
Static Public Attributes | |
static constexpr std::string::size_type | npos = -1 |
Protected Attributes | |
std::string | m_s |
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and from wxString, to and from std::string, and has non-mutating iteration over Unicode characters.
I've been careful to supply only conversion facilities and not try and duplicate wxString() with many member functions. There are multiple ways to create text into a std::string without the need of too many member functions:
Because this class uses no virtuals, it should be possible to cast any std::string into a UTF8 using this kind of cast: (UTF8 &) without construction or copying being the effect of the cast. Be sure the source std::string holds UTF8 encoded text before you do that.
|
inline |
This is a constructor for which you could end up with non-UTF8 encoding, but that would be your fault.
Definition at line 78 of file utf8.h.
References c_str(), and MAYBE_VERIFY_UTF8.
UTF8::UTF8 | ( | const wchar_t * | txt | ) |
|
inline |
Definition at line 88 of file utf8.h.
References c_str(), and MAYBE_VERIFY_UTF8.
|
inline |
|
inline |
Definition at line 103 of file utf8.h.
References m_s.
Referenced by PCB_IO_EAGLE::centerBoard(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), LIB_ID::Format(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), PCB_IO_CADSTAR_ARCHIVE::LoadBoard(), DSN::SPECCTRA_DB::makeIMAGE(), operator+=(), operator=(), DIALOG_EXCHANGE_FOOTPRINTS::processFootprint(), CVPCB_MAINFRAME::readNetListAndFpFiles(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), CVPCB_MAINFRAME::refreshAfterSymbolSearch(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), UTF8(), NETLIST_EXPORTER_SPICE::WriteDirectives(), and wx_str().
|
inline |
|
inline |
Definition at line 112 of file utf8.h.
References m_s.
Referenced by LIB_ID::compare(), and SCH_REFERENCE::CompareLibName().
|
inline |
Definition at line 104 of file utf8.h.
References m_s.
Referenced by PCB_IO_EAGLE::centerBoard(), SCH_SCREENS::GetLibNicknames(), SCH_SYMBOL::GetMsgPanelInfo(), SCH_SCREENS::HasNoFullyDefinedLibIds(), SYMBOL_EDITOR_CONTROL::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PCB_IO_CADSTAR_ARCHIVE::LoadBoard(), PCB_EDIT_FRAME::OpenProjectFiles(), FOOTPRINT_EDITOR_CONTROL::PasteFootprint(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), FOOTPRINT_EDITOR_CONTROL::SaveAs(), SCH_EDIT_FRAME::SaveSelectionAsDesignBlock(), SCH_EDIT_FRAME::SaveSheetAsDesignBlock(), LIB_TREE::setState(), SYMBOL_EDIT_FRAME::setupUIConditions(), FOOTPRINT_EDIT_FRAME::setupUIConditions(), FOOTPRINT_EDITOR_CONTROL::tryToSaveFootprintInLibrary(), and FOOTPRINT_EDIT_FRAME::UpdateTitle().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 110 of file utf8.h.
References m_s.
Referenced by PLACE_FILE_EXPORTER::GenPositionData().
|
inline |
|
inline |
Definition at line 118 of file utf8.h.
References operator==().
|
inline |
Definition at line 135 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
|
inline |
Definition at line 142 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
Definition at line 128 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
UTF8 & UTF8::operator+= | ( | unsigned | w_ch | ) |
|
inline |
|
inline |
Definition at line 174 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
|
inline |
Definition at line 167 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
|
inline |
Definition at line 160 of file utf8.h.
References c_str(), m_s, and MAYBE_VERIFY_UTF8.
UTF8 & UTF8::operator= | ( | const wxString & | o | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 111 of file utf8.h.
References m_s.
Referenced by LIB_ID::Format(), LIB_TABLE::FormatOptions(), guessNickname(), PCB_EDIT_FRAME::LoadFootprints(), and setLibNickname().
|
inline |
Definition at line 183 of file utf8.h.
References m_s.
Referenced by operator+=(), and LIB_ID::Parse().
|
inline |
Returns a uni_iter initialized to the start of "this" UTF8 byte sequence.
Definition at line 284 of file utf8.h.
References m_s.
Referenced by KIGFX::OPENGL_GAL::computeBitmapTextSize(), and LIB_ID::FixIllegalChars().
|
inline |
Return a uni_iter initialized to the end of "this" UTF8 byte sequence.
Definition at line 292 of file utf8.h.
References m_s.
Referenced by KIGFX::OPENGL_GAL::computeBitmapTextSize(), and LIB_ID::FixIllegalChars().
|
static |
Advance over a single UTF8 encoded multibyte character, capturing the Unicode character as it goes, and returning the number of bytes consumed.
aSequence | is the UTF8 byte sequence, must be aligned on start of character. |
aResult | is where to put the unicode character, and may be NULL if no interest. |
Definition at line 67 of file utf8.cpp.
Referenced by IsUTF8(), UTF8::uni_iter::operator*(), UTF8::uni_iter::operator++(), and UTF8::uni_iter::operator->().
wxString UTF8::wx_str | ( | ) | const |
Definition at line 45 of file utf8.cpp.
References c_str().
Referenced by COMPONENTS_MANAGER::AddComponent(), SCH_SCREEN::AddLibSymbol(), BOARD_NETLIST_UPDATER::addNewFootprint(), CVPCB_ASSOCIATION_TOOL::Associate(), CVPCB_MAINFRAME::AssociateFootprint(), BASIC_FOOTPRINT_INFO::BASIC_FOOTPRINT_INFO(), PANEL_DESIGN_BLOCK_LIB_TABLE::browseLibrariesHandler(), PANEL_FP_LIB_TABLE::browseLibrariesHandler(), SCH_SCREENS::ChangeSymbolLibNickname(), CADSTAR_SCH_ARCHIVE_LOADER::CreateLibName(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), PCBNEW_JOBS_HANDLER::doFpExportSvg(), SYMBOL_SAVE_AS_HANDLER::DoSave(), PCB_EDIT_FRAME::ExchangeFootprint(), LIB_TREE_MODEL_ADAPTER::FindItem(), SYMBOL_LIBS::FindLibSymbol(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(), SYMBOL_LIB::FindSymbol(), PCB_IO_KICAD_SEXPR::FootprintSave(), SCH_IO_KICAD_SEXPR::Format(), FOOTPRINT_INFO_GENERATOR::GenerateHtml(), DESIGN_BLOCK_TREE_MODEL_ADAPTER::GenerateInfo(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::GetActionDescription(), FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), LIB_ID::GetFullLibraryName(), SCH_IO_ALTIUM::getLibName(), SCH_IO_EAGLE::getLibName(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), PCBNEW_JOBS_HANDLER::JobExportFpSvg(), PCB_IO_KICAD_LEGACY::loadFOOTPRINT(), PCB_EDIT_FRAME::LoadFootprints(), PCB_IO_KICAD_LEGACY::loadFP_SHAPE(), PCB_IO_KICAD_LEGACY::loadPAD(), PANEL_SYMBOL_CHOOSER::populateFootprintSelector(), CVPCB_MAINFRAME::readNetListAndFpFiles(), DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), BOARD_NETLIST_UPDATER::replaceFootprint(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::RESCUE_SYMBOL_LIB_TABLE_CANDIDATE(), SYMBOL_EDIT_FRAME::Revert(), SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol(), SCH_IO_KICAD_SEXPR::saveSymbol(), SchGetDesignBlock(), SchGetLibSymbol(), PCB_BASE_FRAME::SelectFootprintFromLibrary(), DIALOG_EDIT_SYMBOLS_LIBID::setLibIdByBrowser(), setLibNickname(), FOOTPRINTS_LISTBOX::SetSelectedFootprint(), SYMBOL_VIEWER_FRAME::SetSelectedLibrary(), PANEL_SYMBOL_CHOOSER::showFootprintFor(), SYMBOL_CANDIDATE::SYMBOL_CANDIDATE(), BOARD_NETLIST_UPDATER::testConnectivity(), DIALOG_PLUGIN_OPTIONS::TransferDataFromWindow(), and BOARD_NETLIST_UPDATER::UpdateNetlist().
|
protected |
Definition at line 309 of file utf8.h.
Referenced by begin(), c_str(), clear(), compare(), empty(), end(), find(), find_first_of(), length(), operator const std::string &(), operator+=(), operator<(), operator=(), operator==(), operator>(), size(), substr(), ubegin(), uend(), and UTF8().
|
staticconstexpr |
Definition at line 156 of file utf8.h.
Referenced by LIB_ID::Parse().