ddc
Functions
ddcString.cpp File Reference
#include "ddcString.h"
#include "utilit.h"
#include "ddcLog.h"
#include <string.h>
Include dependency graph for ddcString.cpp:

Functions

string escapeCString (const std::string &s)
 
string unescapeCString (const string &s)
 
std::string escapeJsonString (const std::string &s, bool assume_utf8, bool add_quotes)
 
string unescapeJsonString (const string &s)
 
string escapeUrlString (const string &s)
 
string unescapeUrlString (const string &s)
 
string unescapeUtf8String (const string &s)
 
string escapeChars (const string &s, const string &chars)
 
string sqString (const std::string &s)
 
string reString (const std::string &re)
 
string escapeRegex (const std::string &re)
 
string Format (const char *format,...)
 
string vFormat (const char *format, va_list &args)
 
char * StrError (int ErrorNo)
 
std::string TrimSafe (const std::string &str)
 
void TrimTruncateV (std::string &str, size_t max, const char *label)
 
bool StringToBool (const std::string &s, bool onempty)
 
const char * BoolToString (bool b)
 

Function Documentation

◆ escapeCString()

string escapeCString ( const std::string &  s)

Encode C escapes into string; encodes byte-wise with escapes

References Format().

Referenced by NavHintCache::insert(), NavHintCache::lower_bound(), and CHighlightTags::ToString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unescapeCString()

string unescapeCString ( const string &  s)

References u8_wc_toutf8().

Referenced by CConcordance::LoadOptionsFromString(), CHighlightTags::ReadFromString(), CDDCBranchServer::ReadSelectedHosts(), CBiblIndex::RegisterFreeBiblAttributes(), CDDCServerOptions::Set(), and yyqparse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ escapeJsonString()

std::string escapeJsonString ( const std::string &  s,
bool  assume_utf8 = true,
bool  add_quotes = false 
)

Encode JSON escapes into string.

  • If assume_utf8 is true (default), leaves bytes with high-bit set alone; otherwise encodes them as escapes.
  • If add_quotes is true, the returned string will be wrapped in JSON-friendly double quotes ("")

References Format().

Referenced by jsonStr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unescapeJsonString()

string unescapeJsonString ( const string &  s)

References u8_wc_toutf8().

Here is the call graph for this function:

◆ escapeUrlString()

string escapeUrlString ( const string &  s)

Referenced by TxCab::expand().

Here is the caller graph for this function:

◆ unescapeUrlString()

string unescapeUrlString ( const string &  s)

◆ unescapeUtf8String()

string unescapeUtf8String ( const string &  s)

References u8_wc_toutf8().

Here is the call graph for this function:

◆ escapeChars()

string escapeChars ( const string &  s,
const string &  chars 
)

◆ sqString()

string sqString ( const std::string &  s)

◆ reString()

string reString ( const std::string &  re)

quote a regex in slashes //

Referenced by jsonArray(), CQFHasFieldRegex::valueString(), and CQTokRegex::ValueString().

Here is the caller graph for this function:

◆ escapeRegex()

string escapeRegex ( const std::string &  re)

escape regex operators .*+?\ etc

References escapeChars().

Referenced by CQFHasFieldInfix::CQFHasFieldInfix(), CQFHasFieldPrefix::CQFHasFieldPrefix(), CQFHasFieldSuffix::CQFHasFieldSuffix(), and jsonArray().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Format()

string Format ( const char *  format,
  ... 
)

wrapper for vsnprintf() which returns a C++ string

References DDC_STATIC_BUFLEN.

Referenced by MorphoWizard::add_lemma(), CHitBorders::AddBreakByIndex(), CTabFormatIndexator::AddColumnMap(), CTempArticle::AddCortegeToVector(), ConcIndexatorInvoker::AddInputLoadIndexToMemoryLoadIndexWrapper(), AddMessage(), CIndexSetForQueryingStage::AddOneIndexItem(), CDDCBranchServer::AlignCorpusPath(), ConcIndexatorInvoker::BuildIndex(), ConcIndexatorInvoker::BuildIndexStart(), CGraphanDicts::BuildOborottos(), CConcSessionContext::CacheGet(), CConcSessionContext::CacheSet(), CDocumentIterator::CDocumentIterator(), MorphoWizard::check_paradigm(), CTempArticle::CheckCortegeVector(), CItemIndexForLoading::CheckOccurrences(), CHost::ClientError(), ddcMMap< CIndexItem >::close(), CHost::CloseListenSocket(), CloseSocketRef(), CQCountKeyExprBibl::Compile(), TxCab::compile(), CFreeBiblStringIndex::ConvertAndSaveToDiskAfterIndexing(), CQCount::countOptionsToString(), CQFRandomSort::CQFRandomSort(), CQFSizeSort::CQFSizeSort(), CQFSort::CQFSort(), CQueryNearNode::Create(), create_inet_socket(), create_unix_socket(), CConcIndexator::CreateAsUnion(), CHost::CreateListener(), CFreeBiblStringIndex::CreatePartitions(), CreatePartitionStorage(), CHost::CreateSocket(), CStringIndexSet::CreateSplitPartitions(), CFreeBiblStringIndex::CreateUnion(), CStringIndexSet::CreateUnionTokenStorages(), ddcLog(), CHitToSort::debugStr(), ddcObject::Descendants(), do_start(), CConcordance::DumpFileBibliography(), CConcordance::DumpIndex(), CMyTimeSpanHolder::EndTimer(), ddcMapFile< DWORD, DWORD >::ensureMap(), ddcStringEnum< OffT_ >::ensureVec(), ddcCorpusList< OffT_ >::ensureVec(), ddcVecFile< CIndexItem >::ensureVec(), escapeCString(), escapeJsonString(), CQCountKeyExpr::Evaluate(), TxMorph::expand(), TxCab::expand(), FileAppend(), FileAppendPartial(), ConcIndexatorInvoker::FinalizeIndex(), CConcXml::FinalSaveBibliography(), CFormInfo::FormatAsInPlmLine(), CBiblIndex::FreeBiblMapToJson(), GenerateCountString(), CConcSession::GenerateCountStrings(), CConcSession::GenerateOneHitString(), CConcSession::GenerateOneHitStringJson(), CMorphDictBuilder::GenPredictIdx(), CConcSession::GetAllHits(), CHitBorders::GetBorderIndicesString(), CHitBorders::CBreakCollection::GetBreakFileName(), CConcSession::GetContext(), CConcSession::GetContextJson(), CConcSession::GetCountIds(), GetCWBFormattedStringRecursive(), CFreeBiblIndex::GetDescriptionStr(), CDDCBranchServer::GetFirstHitsFromCorpora(), CBiblIndex::GetFreeBibiAttributesDescr(), CDDCBranchServer::GetHitContexts(), CConcSession::GetHitIds(), CConcSession::GetHits(), CDDCBranchServer::GetHitStringsFromOneCorpus(), CConcordance::GetHtmlReference(), CStringIndexator::GetIndicesString(), CConcordance::GetIndicesToShowStr(), GetLogLevel(), CHost::GetRequest(), CFreeBiblIndex::GetStringValue(), CDDCBranchServer::GetSubcorpusJsonStrings(), CBiblIndex::GetTextAreaElements(), CBiblIndex::GetTextAreasDescr(), GetTextFromXMLRecursive(), TRoss::GetUnitTextHeader(), GetWordForms(), CDDCLeafServer::handle__clear_cache(), CDDCBranchServer::handle__clear_cache(), CDDCLeafServer::handle__expand_terms(), CDDCBranchServer::handle__expand_terms(), CDDCLeafServer::handle__get_first_hits(), CDDCBranchServer::handle__get_first_hits(), CDDCLeafServer::handle__get_hit_strings(), CDDCBranchServer::handle__get_hit_strings(), CDDCLeafServer::handle__info(), CDDCBranchServer::handle__nodes(), CDDCLeafServer::handle__reload(), CDDCBranchServer::handle__reload(), CDDCLeafServer::handle__run_query(), CDDCBranchServer::handle__run_query(), CDDCLeafServer::handle__status(), CDDCBranchServer::handle__status(), CHost::HandleClientConnection(), CDDCServer::HandleClientConnection(), CHost::HandleSocketError(), CDictionary::ImportFromText(), ConcIndexatorInvoker::IndexFile(), ConcIndexatorInvoker::IndexFiles(), CConcIndexator::IndexOneTableTextArea(), CStringIndexator::IndexOneToken(), CTabFormatIndexator::IndexTabFormat(), CConcIndexator::IndexTextOrHtmlFile(), CStringIndexator::IndexTokenFixLongColumns(), CConcIndexator::InitGraphan(), InitMorphologySystem(), CConcSession::InitSortByContext(), CConcSession::InitSortByRank(), NavHintCache::insert(), TRoss::InsertDomItem(), jsonArray(), CQueryOptions::jsonData(), CQCountKeyExprDateSlice::jsonData(), CQCountKeyExprToken::jsonData(), CQFContextSort::jsonData(), CQWith::jsonData(), CQCount::jsonData(), CQToken::jsonData(), CQKeys::jsonData(), CQFPrune::jsonData(), CQNear::jsonData(), CQTokAnchor::jsonValue(), ListenerThread(), CMorphDict::Load(), CMorphAutomat::Load(), CBiblIndex::LoadBibl(), LoadDDCServer(), CDDCServerOptions::LoadFile(), CConcIndexator::LoadFileIntoGraphan(), CDDCLeafServer::LoadHolder(), CIndexSetForQueryingStage::LoadIndexSet(), CDDCServerOptions::LoadLines(), LoadLocalCorpora(), CConcordance::LoadMaskedFiles(), TRoss::LoadOnlyConstants(), CConcordance::LoadOptionsFromFile(), CConcordance::LoadOptionsFromString(), CConcordance::LoadProject(), CConcordance::LoadSourceFilesAndOptions(), CGraphmatFile::LoadStringToGraphan(), CConcXml::LoadXmlAndReadBibliography(), CConcIndexator::LoadXmlFile(), NavHintCache::lower_bound(), MakeDirP(), CTempArticle::MarkUp(), CQToken::MatchIdString(), ddcMMap< CIndexItem >::open(), ddcStringEnum< OffT_ >::open(), ddcCorpusList< OffT_ >::open(), ddcRecFile::open(), ddcFileOrMMap::Open(), ddcStringEnum< OffT_ >::openCompat(), ddcCorpusList< OffT_ >::openCompat(), ConcIndexatorInvoker::PrintProgress(), CTabFormatIndexator::ProcessMetaField(), CDictionary::ProcessOneArticle(), CDDCServer::ProcessSocketString(), CFreeBiblIndex::ReadFromDisk(), CDumpParadigm::ReadFromFile(), CConcXml::ReadMorphXmlFileIntoGraTable(), MorphoWizard::ReadNextParadigmFromFile(), CDDCBranchServer::ReadSelectedHosts(), MorphoWizard::ReadSessions(), CSourceFileHolder::ReadSourceFileList(), CDocumentIterator::ReadTabFormatDocument(), ReadTabFormatDocumentName(), ReadVectorInner(), ReadXmlField(), CFreeBiblStringIndex::RegisterBiblStringItemId(), CHitBorders::RegisterBorderIndices(), CBiblIndex::RegisterFreeBiblAttributes(), CStringIndexator::RegisterIndexAlias(), CStringIndexator::RegisterIndexAliases(), CConcordance::RegisterIndicesToShow(), CConcIndexator::RollbackIndexOneFile(), CIndexSetForLoadingStage::RollbackLoadIndex(), CDDCServerThread::run(), CDDCBranchServer::RunDistributed(), CDDCBranchServer::RunGetFirstHits(), CHost::RunThread(), CBibliography::Sanitize(), SanitizeBiblString(), CMorphDict::Save(), CMorphAutomat::Save(), ddcVecFile< CIndexItem >::save(), MorphoWizard::save_mrd(), ConcIndexatorInvoker::SaveLoadIndexToDisk(), CConcSession::SaveOccurrences(), SaveOnePartOfUnionTokenStorage(), CConcordance::SaveOptionsToString(), send_buffer(), CDDCBranchServer::SendGetHitStringsRequest(), CHost::SendResponse(), CDDCServerOptions::Set(), CConcXml::SetFreeBiblByName(), CDDCServer::SetOptions(), CDDCBranchServer::SetOptions(), MorphoWizard::show_differences_in_two_paradigms(), CConcSession::ShowBibliographyForTable(), CConcSession::ShowBibliographyForTextOrHtml(), CDDCLeafServer::Shutdown(), CDDCServer::Shutdown(), CDDCBranchServer::Shutdown(), CConcSession::SimpleQuery(), SocketPeer(), CConcSession::SortKeyLB(), CConcXml::SplitBibliography(), CConcIndexator::SplitProject(), CDDCServerThreadPool::start(), CHitBorders::StartIndexing(), tar_get_next_file(), tar_header::th_get_pathname(), NavHintKey::toJson(), NavHint::toJson(), NavHintCache::toJson(), DDCTimeAvg::toJsonArray(), DDCTimeAvg::toJsonMap(), CHighlightTags::ToString(), CAccentModel::ToString(), NavHintKey::toString(), CDDCServerOptions::toString(), CMorphSession::ToString(), CSocketAddr::toString(), CQueryOptions::toString(), CQCountKeyExprDateSlice::toString(), CSelectedHosts::toString(), CRunQueryData::toString(), CQCountKeyExprToken::toString(), CQFContextSort::toString(), CQWith::toString(), CQFPrune::toString(), CQKeys::toString(), CQNear::toString(), CQSeq::toString(), TrimTruncateV(), CConcXml::UnionBibliographies(), CStringIndexSet::UnionIndexSets(), CDDCBranchServer::UpdateNavCache(), CQTokAnchor::ValueString(), CConcSession::WorkerClone(), CFreeBiblStringIndex::WriteBiblStringItems(), and CIndexSetForQueryingStage::WritePeriodsDivision().

◆ vFormat()

string vFormat ( const char *  format,
va_list &  args 
)

wrapper for vsnprintf(), va_list version

References DDC_STATIC_BUFLEN.

Referenced by EchoOption(), and jsonArray().

Here is the caller graph for this function:

◆ StrError()

char* StrError ( int  ErrorNo)

wrapper for strerror_r() if available, otherwise wraps strerror()

Referenced by create_inet_socket(), create_unix_socket(), CreateWaitFile(), do_start(), do_stop(), CConcordance::DumpIndex(), jsonArray(), CDDCServerOptions::LoadFile(), read_pid_from_lock_file(), receive_buffer(), CHost::RunThread(), and send_buffer().

Here is the caller graph for this function:

◆ TrimSafe()

std::string TrimSafe ( const std::string &  str)

constructive variant of Trim() from utilit.(h|cpp): trims leading and trailing whitespace from argument, returns new trimmed string

Referenced by StringSplitter::operator++(), and CDDCServerOptions::Set().

Here is the caller graph for this function:

◆ TrimTruncateV()

void TrimTruncateV ( std::string &  str,
size_t  max,
const char *  label = NULL 
)

verbose auto-truncation: logs a warning "LABEL ILABEL truncated to max=MAX bytes" on truncation

References ddcLogWarn, Format(), and TrimTruncate().

Referenced by TrimTruncate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StringToBool()

bool StringToBool ( const std::string &  s,
bool  onempty = true 
)

option-parsing utility for boolean options

References stolower().

Referenced by CConcordance::LoadOptionsFromString(), CDDCServerOptions::Set(), and TrimTruncate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BoolToString()

const char* BoolToString ( bool  b)

boolean value reporting for options

Referenced by CConcordance::LoadOptionsFromString(), CDDCServerOptions::toString(), and TrimTruncate().

Here is the caller graph for this function: