mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a7d2191649 | |||
| 14fa14de3f | |||
| cced8f4912 | |||
| a52a8e982e | |||
| 6afa54ebef | |||
| 27a0e77ef1 | |||
| 76b682063e | |||
| effdab1ff4 | |||
| 48aa99af83 | |||
| 00e9ce56df | |||
| 261e48227d | |||
| 29e3f90ebf | |||
| b9b843f25d | |||
| d7e2bedc6b | |||
| 58cd45f4ee | |||
| 33f7ee49df | |||
| 95a49140cb | |||
| aad12cf471 | |||
| f0ffb7f14c | |||
| 4c8bc2227a | |||
| c517b3ac19 | |||
| 48a1f01220 | |||
| 8a2923e534 | |||
| 0ab7e55add | |||
| cb1cb43a0b | |||
| 0ca3432d05 | |||
| 50208be48d | |||
| c796f4a0f6 | |||
| 618da3c8cc | |||
| 9b4568e81a | |||
| 752acf1e46 | |||
| d9afc49bb3 | |||
| 4c6ba8ed41 |
@ -58,6 +58,9 @@
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
|
||||
#define GETBIT(from, num) ((from & (1 << num)) != 0)
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
typedef unsigned char Bool8;
|
||||
|
||||
@ -72,10 +72,14 @@ namespace DocFileFormat
|
||||
{
|
||||
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
|
||||
|
||||
unsigned short index_author = atrdPre10->GetAuthorIndex();
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
|
||||
m_pXmlWriter->WriteAttribute( L"w:author",
|
||||
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->GetAuthorIndex() ) ));
|
||||
if (index_author < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc
|
||||
{
|
||||
m_pXmlWriter->WriteAttribute( L"w:author",
|
||||
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( index_author ) ));
|
||||
}
|
||||
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->GetUserInitials());
|
||||
|
||||
//!!!TODO!!!
|
||||
|
||||
@ -163,6 +163,7 @@ namespace OpenXmlRelationshipTypes
|
||||
static const wchar_t* GlossaryDocument = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument";
|
||||
static const wchar_t* Package = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
||||
static const wchar_t* VbaProject = L"http://schemas.microsoft.com/office/2006/relationships/vbaProject";
|
||||
static const wchar_t* Hyperlink = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
||||
}
|
||||
|
||||
namespace MicrosoftWordRelationshipTypes
|
||||
|
||||
@ -679,9 +679,9 @@ namespace DocFileFormat
|
||||
|
||||
if ( _bContentWrite )
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
|
||||
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
|
||||
m_pXmlWriter->WriteNodeEnd( L"", true );
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
|
||||
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
|
||||
m_pXmlWriter->WriteNodeEnd( L"", true );
|
||||
|
||||
_fieldLevels.back().bBegin = true;
|
||||
}
|
||||
@ -703,12 +703,12 @@ namespace DocFileFormat
|
||||
{
|
||||
_writeWebHidden = true;
|
||||
std::wstring _writeTocLink =f1.substr(d + 9);
|
||||
d = (int)_writeTocLink.find(L" ");
|
||||
d = (int)_writeTocLink.find(L" ");
|
||||
_writeTocLink = _writeTocLink.substr(0, d);
|
||||
|
||||
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
|
||||
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
|
||||
_writeAfterRun += _writeTocLink;
|
||||
_writeAfterRun += std::wstring (L"\" w:history=\"1\">");
|
||||
_writeAfterRun += std::wstring (L"\" w:history=\"1\">");
|
||||
|
||||
break;
|
||||
//cp = cpFieldSep1;
|
||||
@ -718,7 +718,28 @@ namespace DocFileFormat
|
||||
_skipRuns = 5; //with separator
|
||||
}
|
||||
}
|
||||
else if ( bEMBED || bLINK || bQUOTE)
|
||||
//else if ( bHYPERLINK )
|
||||
//{//todooo - выделение гиперссылки отдельно
|
||||
// std::vector<std::wstring> arRefs;
|
||||
// boost::algorithm::split(arRefs, f, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
//
|
||||
// std::wstring sLink = arRefs[2];
|
||||
// m_pXmlWriter->WriteNodeBegin( L"w:hyperlink", true );
|
||||
|
||||
// int relID = m_context->_docx->RegisterHyperlink(_caller, sLink);
|
||||
// m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) );
|
||||
// m_pXmlWriter->WriteAttribute( L"w:history", 1 );
|
||||
// m_pXmlWriter->WriteNodeEnd( L"", true, false );
|
||||
|
||||
// if (arRefs.size() > 2)
|
||||
// {
|
||||
// writeTextElement(arRefs[3].substr(1, arRefs[3].length() - 2), textType);
|
||||
// }
|
||||
// m_pXmlWriter->WriteNodeEnd( L"w:hyperlink", false, true );
|
||||
|
||||
// _skipRuns = 1;
|
||||
//}
|
||||
else if ( bEMBED || (bLINK && !bHYPERLINK)|| bQUOTE)
|
||||
{
|
||||
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
|
||||
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
|
||||
@ -841,19 +862,21 @@ namespace DocFileFormat
|
||||
else if (TextMark::FieldEndMark == code)
|
||||
{
|
||||
if (!_fieldLevels.empty())
|
||||
{
|
||||
_fieldLevels.back().bEnd = true;
|
||||
|
||||
if (_fieldLevels.back().bBegin == true && !text.empty())
|
||||
{
|
||||
if (!text.empty())
|
||||
{
|
||||
writeTextElement(text, textType);
|
||||
text.clear();
|
||||
}
|
||||
}
|
||||
if (_fieldLevels.back().bBegin)
|
||||
{
|
||||
_fieldLevels.back().bEnd = true;
|
||||
|
||||
XMLTools::XMLElement elem( L"w:fldChar" );
|
||||
elem.AppendAttribute( L"w:fldCharType", L"end" );
|
||||
XMLTools::XMLElement elem( L"w:fldChar" );
|
||||
elem.AppendAttribute( L"w:fldCharType", L"end" );
|
||||
|
||||
m_pXmlWriter->WriteString( elem.GetXMLString());
|
||||
m_pXmlWriter->WriteString( elem.GetXMLString());
|
||||
}
|
||||
|
||||
_fieldLevels.pop_back();
|
||||
}
|
||||
@ -1152,20 +1175,7 @@ namespace DocFileFormat
|
||||
if ( fc >= nMinVal )
|
||||
{
|
||||
ret = m_document->AllPapx->find(nMinVal)->second;
|
||||
//? if (!ret && m_document->AllPapx->size() > 0)
|
||||
//? {
|
||||
//? map<int, ParagraphPropertyExceptions*>::iterator it = m_document->AllPapx->end();
|
||||
//? it--;
|
||||
//? do
|
||||
//? {
|
||||
//? if (it->first < nMinVal && it->second)
|
||||
//? break;
|
||||
//? it--;
|
||||
//? }
|
||||
//? while(it != m_document->AllPapx->begin());
|
||||
//?
|
||||
//? ret = it->second;
|
||||
//? }
|
||||
|
||||
_lastValidPapx = ret;
|
||||
}
|
||||
}
|
||||
@ -1215,8 +1225,8 @@ namespace DocFileFormat
|
||||
TableInfo tai( papx );
|
||||
|
||||
//build the table grid
|
||||
std::vector<short> grid, grid_write;
|
||||
buildTableGrid( cp, nestingLevel, grid, grid_write );
|
||||
std::vector<short> grid;
|
||||
buildTableGrid( cp, nestingLevel, grid);
|
||||
|
||||
//find first row end
|
||||
int fcRowEnd = findRowEndFc( cp, nestingLevel );
|
||||
@ -1227,7 +1237,7 @@ namespace DocFileFormat
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:tbl" );
|
||||
|
||||
//Convert it
|
||||
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, &grid, &grid_write );
|
||||
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, &grid);
|
||||
|
||||
row1Tapx.Convert( tpMapping );
|
||||
|
||||
@ -1240,7 +1250,7 @@ namespace DocFileFormat
|
||||
//only convert the cells with the given nesting level
|
||||
while ( tai.iTap == nestingLevel )
|
||||
{
|
||||
cp = writeTableRow( cp, &grid, &grid_write, nestingLevel );
|
||||
cp = writeTableRow( cp, &grid, nestingLevel );
|
||||
//?fc = m_document->FindFileCharPos(cp );
|
||||
fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp );
|
||||
papx = findValidPapx( fc );
|
||||
@ -1253,7 +1263,7 @@ namespace DocFileFormat
|
||||
//convert until the end of table is reached
|
||||
while ( tai.fInTable )
|
||||
{
|
||||
cp = writeTableRow( cp, &grid, &grid_write, nestingLevel );
|
||||
cp = writeTableRow( cp, &grid, nestingLevel );
|
||||
fc = m_document->FindFileCharPos( cp );
|
||||
|
||||
papx = findValidPapx( fc );
|
||||
@ -1268,12 +1278,11 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
// Builds a list that contains the width of the several columns of the table.
|
||||
bool DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write)
|
||||
bool DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel, std::vector<short>& grid)
|
||||
{
|
||||
ParagraphPropertyExceptions* backup = _lastValidPapx;
|
||||
|
||||
std::vector<short> boundaries;
|
||||
std::vector<short> boundaries_all;
|
||||
std::map<short, short> boundaries;
|
||||
|
||||
int cp = initialCp;
|
||||
int fc = m_document->FindFileCharPos( cp );
|
||||
@ -1284,8 +1293,12 @@ namespace DocFileFormat
|
||||
int fcRowEnd = findRowEndFc( cp, cp, nestingLevel );
|
||||
ParagraphPropertyExceptions* papx_prev = NULL;
|
||||
|
||||
short max_boundary = -1;
|
||||
short count_column = 0;
|
||||
|
||||
while ( tai.fInTable )
|
||||
{
|
||||
short current_count_column = 0;
|
||||
//check all SPRMs of this TAPX
|
||||
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
|
||||
{
|
||||
@ -1294,43 +1307,33 @@ namespace DocFileFormat
|
||||
|
||||
switch(iter->OpCode)
|
||||
{
|
||||
case sprmTDefTable:
|
||||
case sprmOldTDefTable:
|
||||
{
|
||||
unsigned char itcMac = iter->Arguments[0];
|
||||
|
||||
while(boundaries.size() < itcMac + 1)
|
||||
boundaries.push_back(-0x7fff);
|
||||
|
||||
short boundary0 = -0x7fff;
|
||||
for (unsigned char i = 0; i < itcMac; i++)
|
||||
case sprmTDefTable:
|
||||
case sprmOldTDefTable:
|
||||
{
|
||||
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
|
||||
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
|
||||
//SprmTDefTable tdef(iter->Arguments, iter->argumentsSize);
|
||||
//int itcMac = tdef.numberOfColumns;
|
||||
|
||||
if (boundary2 - boundary1 > 1 && boundary1 - boundary0 > 1)
|
||||
{
|
||||
if ( boundaries[i] == -0x7fff || boundaries[i+1] == -0x7fff)
|
||||
{
|
||||
boundaries[i] = boundary1;
|
||||
boundaries[i+1] = boundary2;
|
||||
}
|
||||
}
|
||||
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary1 ) == boundaries_all.end() )
|
||||
{
|
||||
boundaries_all.push_back( boundary1 );
|
||||
}
|
||||
unsigned char itcMac = iter->Arguments[0];
|
||||
|
||||
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary2 ) == boundaries_all.end() )
|
||||
short boundary1, boundary2;
|
||||
for (unsigned char i = 0; i < itcMac; i++)
|
||||
{
|
||||
boundaries_all.push_back( boundary2 );
|
||||
boundary1 = FormatUtils::BytesToInt16( iter->Arguments + 1, i * 2 , iter->argumentsSize );
|
||||
boundary2 = FormatUtils::BytesToInt16( iter->Arguments + 1, ( i + 1 ) * 2, iter->argumentsSize );
|
||||
|
||||
AddBoundary(boundary1, boundary2, boundaries);
|
||||
}
|
||||
boundary0 = boundary1;
|
||||
}break;
|
||||
}
|
||||
if (max_boundary < boundary2)
|
||||
max_boundary = boundary2;
|
||||
|
||||
AddBoundary(boundary2, max_boundary, boundaries);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
if (current_count_column > count_column)
|
||||
count_column = current_count_column;
|
||||
|
||||
//get the next papx
|
||||
papx = findValidPapx( fcRowEnd );
|
||||
tai = TableInfo( papx );
|
||||
@ -1341,21 +1344,11 @@ namespace DocFileFormat
|
||||
papx_prev = papx;
|
||||
}
|
||||
|
||||
//build the grid based on the boundaries
|
||||
sort( boundaries_all.begin(), boundaries_all.end() );
|
||||
|
||||
if ( !boundaries.empty() )
|
||||
{
|
||||
for ( size_t i = 0; i < ( boundaries.size() - 1 ); i++ )
|
||||
for ( std::map<short, short>::iterator it = boundaries.begin(); it != boundaries.end(); ++it)
|
||||
{
|
||||
grid_write.push_back( boundaries[i + 1] - boundaries[i] );
|
||||
}
|
||||
}
|
||||
if ( !boundaries_all.empty() )
|
||||
{
|
||||
for ( size_t i = 0; i < ( boundaries_all.size() - 1 ); i++ )
|
||||
{
|
||||
grid.push_back( boundaries_all[i + 1] - boundaries_all[i] );
|
||||
grid.push_back( it->second );
|
||||
}
|
||||
}
|
||||
_lastValidPapx = backup;
|
||||
@ -1363,6 +1356,40 @@ namespace DocFileFormat
|
||||
return true;
|
||||
}
|
||||
|
||||
void DocumentMapping::AddBoundary(short boundary1, short boundary2, std::map<short, short> &boundaries)
|
||||
{
|
||||
if (boundary2 - boundary1 < 10)
|
||||
return;
|
||||
|
||||
std::map<short, short>::iterator pFind = boundaries.find(boundary1);
|
||||
|
||||
while(true)
|
||||
{
|
||||
if (pFind == boundaries.end())
|
||||
{
|
||||
boundaries.insert(std::make_pair(boundary1, boundary2 - boundary1));
|
||||
break;
|
||||
}
|
||||
else if (pFind->second != boundary2 - boundary1)
|
||||
{
|
||||
if (pFind->second > boundary2 - boundary1)
|
||||
{
|
||||
short new_size = boundary2 - boundary1;
|
||||
boundary1 = boundary2;
|
||||
boundary2 = pFind->second + pFind->first;
|
||||
pFind->second = new_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
boundary1 = pFind->second + pFind->first;
|
||||
}
|
||||
pFind = boundaries.find(boundary1);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Finds the FC of the next row end mark.
|
||||
int DocumentMapping::findRowEndFc(int initialCp, int& rowEndCp, unsigned int nestingLevel )
|
||||
{
|
||||
@ -1480,7 +1507,7 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
/// Writes the table row that starts at the given cp value and ends at the next row end mark
|
||||
int DocumentMapping::writeTableRow(int initialCp, std::vector<short>* grid, std::vector<short>* grid_write, unsigned int nestingLevel)
|
||||
int DocumentMapping::writeTableRow(int initialCp, std::vector<short>* grid, unsigned int nestingLevel)
|
||||
{
|
||||
int cp = initialCp;
|
||||
int fc = m_document->FindFileCharPos( cp );
|
||||
@ -1510,7 +1537,7 @@ namespace DocFileFormat
|
||||
//Write until the first "inner trailer paragraph" is reached
|
||||
while ( !( ( m_document->Text->at( cp ) == TextMark::ParagraphEnd ) && ( tai.fInnerTtp ) ) && tai.fInTable )
|
||||
{
|
||||
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
|
||||
cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel );
|
||||
cellIndex++;
|
||||
|
||||
//each cell has it's own PAPX
|
||||
@ -1527,7 +1554,7 @@ namespace DocFileFormat
|
||||
while ( !( ( m_document->Text->at( cp ) == TextMark::CellOrRowMark ) && ( tai.fTtp ) )
|
||||
&& tai.fInTable )
|
||||
{
|
||||
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
|
||||
cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel );
|
||||
cellIndex++;
|
||||
|
||||
//each cell has it's own PAPX
|
||||
@ -1550,7 +1577,7 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
/// Writes the table cell that starts at the given cp value and ends at the next cell end mark
|
||||
int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel )
|
||||
int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel )
|
||||
{
|
||||
int cp = initialCp;
|
||||
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
|
||||
@ -1558,7 +1585,7 @@ namespace DocFileFormat
|
||||
//start w:tc
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
|
||||
|
||||
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, grid_write, gridIndex, cellIndex );
|
||||
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, gridIndex, cellIndex );
|
||||
|
||||
if ( tapx != NULL )
|
||||
{
|
||||
|
||||
@ -110,15 +110,15 @@ namespace DocFileFormat
|
||||
// Writes the table starts at the given cp value
|
||||
int writeTable ( int initialCp, unsigned int nestingLevel );
|
||||
// Builds a list that contains the width of the several columns of the table.
|
||||
bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write );
|
||||
bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector<short>& grid);
|
||||
// Finds the FC of the next row end mark.
|
||||
int findRowEndFc ( int initialCp, int& rowEndCp, unsigned int nestingLevel );
|
||||
// Finds the FC of the next row end mark.
|
||||
int findRowEndFc ( int initialCp, unsigned int nestingLevel );
|
||||
// Writes the table row that starts at the given cp value and ends at the next row end mark
|
||||
int writeTableRow ( int initialCp, std::vector<short>* grid, std::vector<short>* grid_write, unsigned int nestingLevel );
|
||||
int writeTableRow ( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
|
||||
// Writes the table cell that starts at the given cp value and ends at the next cell end mark
|
||||
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel );
|
||||
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
|
||||
int findCellEndCp ( int initialCp, unsigned int nestingLevel );
|
||||
|
||||
bool writeBookmarks ( int cp );
|
||||
@ -135,6 +135,8 @@ namespace DocFileFormat
|
||||
// Searches the given vector for the next FieldEnd character.
|
||||
int searchNextTextMark( std::vector<wchar_t>* chars, int initialCp, wchar_t mark );
|
||||
Symbol getSymbol ( const CharacterPropertyExceptions* chpx );
|
||||
|
||||
void AddBoundary(short boundary1, short boundary2, std::map<short, short> &boundaries);
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
bool m_bInternalXmlWriter;
|
||||
|
||||
|
||||
@ -407,7 +407,10 @@ namespace DocFileFormat
|
||||
|
||||
return AddPart( mapping, L"word", fileName, VMLPictureMapping::GetContentType( blipType ), OpenXmlRelationshipTypes::Image );
|
||||
}
|
||||
|
||||
int OpenXmlPackage::RegisterHyperlink(const IMapping* mapping, const std::wstring& link)
|
||||
{
|
||||
return AddPart(mapping, L"", link, L"", OpenXmlRelationshipTypes::Hyperlink, L"External");
|
||||
}
|
||||
int OpenXmlPackage::RegisterOLEObject(const IMapping* mapping, const std::wstring& objectType)
|
||||
{
|
||||
std::wstring fileName = ( std::wstring( L"embeddings/oleObject" ) + FormatUtils::IntToWideString( ++_oleCounter ) + OleObjectMapping::GetTargetExt(objectType));
|
||||
|
||||
@ -178,6 +178,7 @@ namespace DocFileFormat
|
||||
int RegisterEndnotes();
|
||||
int RegisterComments();
|
||||
int RegisterImage ( const IMapping* mapping, Global::BlipType blipType );
|
||||
int RegisterHyperlink ( const IMapping* mapping, const std::wstring& link);
|
||||
int RegisterOLEObject ( const IMapping* mapping, const std::wstring& objectType );
|
||||
int RegisterPackage ( const IMapping* mapping, const std::wstring& objectType);
|
||||
int RegisterExternalOLEObject( const IMapping* mapping, const std::wstring& objectType, const std::wstring& uri );
|
||||
|
||||
@ -177,8 +177,6 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
unsigned char numberOfColumns;
|
||||
|
||||
/// An array of 16-bit signed integer that specifies horizontal distance in twips.
|
||||
|
||||
@ -171,7 +171,7 @@ namespace DocFileFormat
|
||||
if ( (*iter)->tapx != NULL )
|
||||
{
|
||||
std::vector<short> tableGrid;
|
||||
TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, NULL, false);
|
||||
TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, false);
|
||||
(*iter)->tapx->Convert( tpMapping );
|
||||
RELEASEOBJECT( tpMapping );
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex) :
|
||||
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, int gridIndex, int cellIndex) :
|
||||
PropertiesMapping(pWriter)
|
||||
{
|
||||
_width = 0;
|
||||
@ -141,6 +141,10 @@ namespace DocFileFormat
|
||||
}
|
||||
break;
|
||||
|
||||
case sprmTDxaCol:
|
||||
{
|
||||
}break;
|
||||
|
||||
case sprmTCellPadding:
|
||||
{
|
||||
unsigned char first = iter->Arguments[0];
|
||||
|
||||
@ -58,7 +58,7 @@ namespace DocFileFormat
|
||||
public:
|
||||
|
||||
virtual ~TableCellPropertiesMapping();
|
||||
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex);
|
||||
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, int gridIndex, int cellIndex);
|
||||
virtual void Apply( IVisitable* visited );
|
||||
|
||||
inline int GetGridSpan() const
|
||||
@ -91,6 +91,6 @@ namespace DocFileFormat
|
||||
BorderCode* _brcRight;
|
||||
BorderCode* _brcBottom;
|
||||
|
||||
int _gridSpan;
|
||||
int _gridSpan;
|
||||
};
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ namespace DocFileFormat
|
||||
cellElements.clear();
|
||||
}
|
||||
|
||||
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, int& gridIndex, int nCellIndex)
|
||||
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, int& gridIndex, int nCellIndex)
|
||||
{
|
||||
if (NULL != mapping)
|
||||
{
|
||||
@ -123,7 +123,7 @@ namespace DocFileFormat
|
||||
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
|
||||
|
||||
//convert the properties
|
||||
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, grid_write, gridIndex, nCellIndex);
|
||||
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, gridIndex, nCellIndex);
|
||||
|
||||
if ( tapx != NULL )
|
||||
{
|
||||
@ -193,7 +193,7 @@ namespace DocFileFormat
|
||||
cells.clear();
|
||||
}
|
||||
|
||||
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write)
|
||||
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid)
|
||||
{
|
||||
if ( mapping != NULL )
|
||||
{
|
||||
@ -234,7 +234,7 @@ namespace DocFileFormat
|
||||
{
|
||||
for ( std::list<TableCell>::iterator iter = cells.begin(); iter != cells.end(); iter++ )
|
||||
{
|
||||
iter->Convert( mapping, &tapx, grid, grid_write, gridIndex, nCellIndex++);
|
||||
iter->Convert( mapping, &tapx, grid, gridIndex, nCellIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,8 +516,8 @@ namespace DocFileFormat
|
||||
SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx;
|
||||
|
||||
//build the table grid
|
||||
std::vector<short> grid, grid_write;
|
||||
documentMapping->buildTableGrid( cpStart, depth, grid, grid_write );
|
||||
std::vector<short> grid;
|
||||
documentMapping->buildTableGrid( cpStart, depth, grid);
|
||||
|
||||
//find first row end
|
||||
int fcRowEnd = documentMapping->findRowEndFc( cpStart, depth );
|
||||
@ -530,7 +530,7 @@ namespace DocFileFormat
|
||||
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tbl" );
|
||||
|
||||
//Convert it
|
||||
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, &grid, &grid_write );
|
||||
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, &grid);
|
||||
|
||||
row1Tapx.Convert( &tpMapping );
|
||||
|
||||
@ -539,7 +539,7 @@ namespace DocFileFormat
|
||||
|
||||
for ( std::list<TableRow>::iterator iter = rows.begin(); iter != rows.end(); iter++ )
|
||||
{
|
||||
iter->Convert( mapping, &grid, &grid_write );
|
||||
iter->Convert( mapping, &grid );
|
||||
}
|
||||
|
||||
//close w:tbl
|
||||
|
||||
@ -58,7 +58,7 @@ namespace DocFileFormat
|
||||
void AddItem( const ITableCellElement& _tableCellElement );
|
||||
bool IsEmpty() const;
|
||||
void Clear();
|
||||
void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, int& gridIndex, int cellIndex );
|
||||
void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, int& gridIndex, int cellIndex );
|
||||
~TableCell();
|
||||
|
||||
private:
|
||||
@ -81,7 +81,7 @@ namespace DocFileFormat
|
||||
void AddCell( const TableCell& _tableCell );
|
||||
bool IsEmpty() const;
|
||||
void Clear();
|
||||
void Convert( IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write );
|
||||
void Convert( IMapping* mapping, const std::vector<short>* grid);
|
||||
~TableRow();
|
||||
|
||||
private:
|
||||
|
||||
@ -34,8 +34,8 @@
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded ):
|
||||
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(grid), _grid_write(grid_write),
|
||||
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded ):
|
||||
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(grid),
|
||||
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(styles),
|
||||
_isTableStyleNeeded(isTableStyleNeeded)
|
||||
{
|
||||
@ -495,7 +495,7 @@ namespace DocFileFormat
|
||||
bWriteGridCol = true;
|
||||
else
|
||||
{
|
||||
for ( size_t i = 0, nSize = _grid_write->size(); i < nSize; i++ )
|
||||
for ( size_t i = 0, nSize = _grid->size(); i < nSize; i++ )
|
||||
{
|
||||
if(_grid->at(i) % DocFileFormat::gc_nZeroWidth != 0)
|
||||
{
|
||||
@ -506,10 +506,10 @@ namespace DocFileFormat
|
||||
}
|
||||
if(true == bWriteGridCol)
|
||||
{
|
||||
for ( size_t i = 0; i < _grid_write->size(); i++ )
|
||||
for ( size_t i = 0; i < _grid->size(); i++ )
|
||||
{
|
||||
XMLTools::XMLElement gridCol( L"w:gridCol");
|
||||
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid_write->at( i ) ) );
|
||||
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid->at( i ) ) );
|
||||
gridCol.AppendAttribute( gridColW );
|
||||
_tblGrid->AppendChild( gridCol );
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ namespace DocFileFormat
|
||||
class TablePropertiesMapping: public PropertiesMapping, public IMapping
|
||||
{
|
||||
public:
|
||||
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded = true );
|
||||
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded = true );
|
||||
virtual ~TablePropertiesMapping();
|
||||
void Apply( IVisitable* visited );
|
||||
|
||||
@ -83,7 +83,6 @@ namespace DocFileFormat
|
||||
|
||||
StyleSheet* _styles;
|
||||
std::vector<short>* _grid;
|
||||
std::vector<short>* _grid_write;
|
||||
|
||||
BorderCode* brcLeft;
|
||||
BorderCode* brcTop;
|
||||
|
||||
@ -39,6 +39,7 @@ namespace DocFileFormat
|
||||
{
|
||||
friend class Converter;
|
||||
friend class MainDocumentMapping;
|
||||
friend class DocumentMapping;
|
||||
friend class CommandTableMapping;
|
||||
friend class StyleSheetMapping;
|
||||
friend class NumberingMapping;
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
namespace Writers
|
||||
{
|
||||
static std::wstring g_string_set_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><w:settings xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\">");
|
||||
static std::wstring g_string_set_Default = _T("<w:zoom w:percent=\"100\"/><w:characterSpacingControl w:val=\"doNotCompress\"/><w:compat><w:compatSetting w:name=\"compatibilityMode\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"14\"/><w:compatSetting w:name=\"overrideTableStyleFontSizeAndJustification\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"enableOpenTypeFeatures\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"doNotFlipMirrorIndents\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/></w:compat><w:themeFontLang w:val=\"en-US\" w:eastAsia=\"zh-CN\"/><w:shapeDefaults><o:shapedefaults v:ext=\"edit\" spidmax=\"1026\"/><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val=\".\"/><w:listSeparator w:val=\",\"/>");
|
||||
static std::wstring g_string_set_Default = _T("<w:zoom w:percent=\"100\"/><w:characterSpacingControl w:val=\"doNotCompress\"/><w:compat><w:compatSetting w:name=\"compatibilityMode\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"15\"/><w:compatSetting w:name=\"overrideTableStyleFontSizeAndJustification\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"enableOpenTypeFeatures\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"doNotFlipMirrorIndents\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/></w:compat><w:themeFontLang w:val=\"en-US\" w:eastAsia=\"zh-CN\"/><w:shapeDefaults><o:shapedefaults v:ext=\"edit\" spidmax=\"1026\"/><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val=\".\"/><w:listSeparator w:val=\",\"/>");
|
||||
static std::wstring g_string_set_End = _T("</w:settings>");
|
||||
|
||||
class SettingWriter
|
||||
|
||||
@ -109,14 +109,20 @@ namespace svg_path
|
||||
aChar = rStr[++io_rPos];
|
||||
}
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
if(!sNumberString.empty())
|
||||
{
|
||||
o_fRetval = boost::lexical_cast<double>(sNumberString);
|
||||
return true;
|
||||
try
|
||||
{
|
||||
o_fRetval = boost::lexical_cast<double>(sNumberString);
|
||||
result = true;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool importDoubleAndSpaces( double& o_fRetval, int& io_rPos, const std::wstring& rStr, const int nLen )
|
||||
|
||||
@ -342,6 +342,16 @@ void odf_table_context::change_current_column_width(double width)
|
||||
int index = impl_->current_table().current_column ;
|
||||
if (index < 0) return;
|
||||
|
||||
while(index >= impl_->current_table().columns.size())
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"table", L"table-column", elm, impl_->odf_context_);
|
||||
|
||||
impl_->styles_context()->create_style(L"", style_family::TableColumn, true, false, -1);
|
||||
|
||||
add_column(elm, true);
|
||||
|
||||
}
|
||||
style *style_ = dynamic_cast<style*>(impl_->current_table().columns[index].style_elm.get());
|
||||
|
||||
if (style_ == NULL) return;
|
||||
@ -527,7 +537,11 @@ void odf_table_context::set_cell_row_span_restart()
|
||||
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = sz;
|
||||
}
|
||||
state.spanned_row_cell.clear();
|
||||
state.spanned_row_cell.push_back(impl_->current_table().cells.back().elm);
|
||||
|
||||
if (false == impl_->current_table().cells.empty())
|
||||
{
|
||||
state.spanned_row_cell.push_back(impl_->current_table().cells.back().elm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
|
||||
#include "../../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Slide.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h"
|
||||
@ -267,6 +268,10 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
}
|
||||
if (oox_picture->oleObject.IsInit())
|
||||
{
|
||||
if (pathImage.empty() && oox_picture->blipFill.blip.IsInit())
|
||||
{
|
||||
pathImage = oox_picture->blipFill.blip->oleFilepathImage;
|
||||
}
|
||||
std::wstring pathOle;
|
||||
|
||||
if (oox_picture->oleObject->m_oId.IsInit())
|
||||
@ -283,6 +288,58 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
{
|
||||
odf_context()->drawing_context()->set_program(*oox_picture->oleObject->m_sProgId);
|
||||
}
|
||||
|
||||
if (pathImage.empty() && oox_picture->oleObject->m_sShapeId.IsInit())
|
||||
{
|
||||
PPTX::Slide *pSlide = dynamic_cast<PPTX::Slide*>(current_document());
|
||||
PPTX::SlideMaster *pSlideMaster = dynamic_cast<PPTX::SlideMaster*>(current_document());
|
||||
|
||||
OOX::CVmlDrawing *pVml = pSlide ? pSlide->Vml.operator->() : (pSlideMaster ? pSlideMaster->Vml.operator->() : NULL);
|
||||
|
||||
if (pVml)
|
||||
{
|
||||
std::wstring sShapeId = oox_picture->oleObject->m_sShapeId.get();
|
||||
boost::unordered_map<std::wstring, OOX::CVmlDrawing::_vml_shape>::iterator pFind = pVml->m_mapShapes.find(sShapeId);
|
||||
|
||||
if (pVml->m_mapShapes.end() != pFind)
|
||||
{
|
||||
OOX::Vml::CVmlCommonElements* pShape = dynamic_cast<OOX::Vml::CVmlCommonElements*>(pFind->second.pElement);
|
||||
|
||||
if (pShape)
|
||||
{
|
||||
for(size_t i = 0; i < pShape->m_arrItems.size(); ++i)
|
||||
{
|
||||
OOX::WritingElement* pChildElemShape = pShape->m_arrItems[i];
|
||||
|
||||
if(OOX::et_v_imagedata == pChildElemShape->getType())
|
||||
{
|
||||
OOX::Vml::CImageData* pImageData = static_cast<OOX::Vml::CImageData*>(pChildElemShape);
|
||||
|
||||
std::wstring sIdImageFileCache;
|
||||
|
||||
if (pImageData->m_oRelId.IsInit()) sIdImageFileCache = pImageData->m_oRelId->GetValue();
|
||||
else if (pImageData->m_rId.IsInit()) sIdImageFileCache = pImageData->m_rId->GetValue();
|
||||
|
||||
if (!sIdImageFileCache.empty())
|
||||
{
|
||||
//ищем физический файл ( rId относительно vml_drawing)
|
||||
smart_ptr<OOX::File> pFile = pVml->Find(sIdImageFileCache);
|
||||
|
||||
if (pFile.IsInit() && ( OOX::FileTypes::Image == pFile->type()))
|
||||
{
|
||||
OOX::Image* pImageFileCache = static_cast<OOX::Image*>(pFile.operator->());
|
||||
|
||||
pathImage = pImageFileCache->filename().GetPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
odf_ref_image = bEmbedded ? odf_context()->add_imageobject(pathImage) : pathImage;
|
||||
odf_context()->drawing_context()->set_image_replacement(odf_ref_image);
|
||||
|
||||
@ -1973,24 +2030,26 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run)
|
||||
if (!oox_run) return;
|
||||
bool styled = false;
|
||||
|
||||
odf_writer::odf_text_context* text_context = odf_context()->text_context();
|
||||
|
||||
if (oox_run->rPr.IsInit())
|
||||
{
|
||||
odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties();
|
||||
odf_writer::style_text_properties * text_properties = text_context->get_text_properties();
|
||||
|
||||
if (!text_properties)
|
||||
{
|
||||
odf_context()->styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1);
|
||||
text_properties = odf_context()->styles_context()->last_state()->get_text_properties();
|
||||
text_context->get_styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1);
|
||||
text_properties = text_context->get_styles_context()->last_state()->get_text_properties();
|
||||
styled = true;
|
||||
}
|
||||
convert(oox_run->rPr.GetPointer(), text_properties);
|
||||
}
|
||||
|
||||
odf_context()->text_context()->start_span(styled);
|
||||
text_context->start_span(styled);
|
||||
|
||||
if ((oox_run->rPr.IsInit()) && (oox_run->rPr->hlinkClick.IsInit()) && (oox_run->rPr->hlinkClick->id.IsInit()))
|
||||
{
|
||||
odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties();
|
||||
odf_writer::style_text_properties * text_properties = text_context->get_text_properties();
|
||||
|
||||
if (!text_properties->content_.fo_color_)
|
||||
{
|
||||
@ -2010,13 +2069,13 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run)
|
||||
text_properties->content_.style_text_underline_style_ = odf_types::line_style::Solid;
|
||||
|
||||
std::wstring hlink = find_link_by_id(oox_run->rPr->hlinkClick->id.get(), 2);
|
||||
odf_context()->text_context()->add_hyperlink(hlink, oox_run->GetText());
|
||||
text_context->add_hyperlink(hlink, oox_run->GetText());
|
||||
}
|
||||
else
|
||||
{
|
||||
odf_context()->text_context()->add_text_content( oox_run->GetText());
|
||||
text_context->add_text_content( oox_run->GetText());
|
||||
}
|
||||
odf_context()->text_context()->end_span();
|
||||
text_context->end_span();
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::Fld *oox_fld)
|
||||
{
|
||||
|
||||
@ -437,7 +437,10 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
|
||||
odt_context->text_context()->set_KeepNextParagraph(false);
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
current_font_size.erase(current_font_size.begin() + 1, current_font_size.end());
|
||||
if (false == current_font_size.empty())
|
||||
{
|
||||
current_font_size.erase(current_font_size.begin() + 1, current_font_size.end());
|
||||
}
|
||||
|
||||
bool bStyled = false;
|
||||
bool bStartNewParagraph = !odt_context->text_context()->get_KeepNextParagraph();
|
||||
@ -2112,7 +2115,7 @@ void DocxConverter::convert(ComplexTypes::Word::CTblWidth *oox_size, _CP_OPT(odf
|
||||
//tblwidthNil = 2,
|
||||
//tblwidthPct = 3
|
||||
}
|
||||
void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::style_text_properties * text_properties)
|
||||
void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::style_text_properties * text_properties, bool is_list_styles)
|
||||
{
|
||||
if (oox_run_pr == NULL) return;
|
||||
if (text_properties == NULL) return;
|
||||
@ -2120,7 +2123,20 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
|
||||
if (oox_run_pr->m_oRStyle.IsInit() && oox_run_pr->m_oRStyle->m_sVal.IsInit())
|
||||
{
|
||||
std::wstring style_name = *oox_run_pr->m_oRStyle->m_sVal;
|
||||
odt_context->styles_context()->last_state()->set_parent_style_name(style_name);
|
||||
|
||||
odf_writer::odf_style_state_ptr style_state;
|
||||
//if (is_list_styles)
|
||||
//{
|
||||
// style_state = odt_context->styles_context()->lists_styles()->last_state();
|
||||
//}
|
||||
//else
|
||||
{
|
||||
style_state = odt_context->styles_context()->last_state();
|
||||
}
|
||||
if (style_state)
|
||||
{
|
||||
style_state->set_parent_style_name(style_name);
|
||||
}
|
||||
|
||||
odf_writer::style_text_properties parent_text_properties;
|
||||
odt_context->styles_context()->calc_text_properties(style_name, odf_types::style_family::Text, &parent_text_properties.content_);
|
||||
@ -3233,7 +3249,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
|
||||
odf_writer::odf_style_context* styles_context = odf_context()->page_layout_context()->get_local_styles_context();
|
||||
|
||||
odf_writer::style_text_properties *text_props = odt_context->styles_context()->lists_styles().get_text_properties();
|
||||
convert(oox_num_lvl->m_oRPr.GetPointer(), text_props);
|
||||
convert(oox_num_lvl->m_oRPr.GetPointer(), text_props, true);
|
||||
|
||||
//create text style for symbols list НА ЛОКАЛЬНОМ контексте - иначе пересечение имен стилей (todoo вытащить генерацию имен в общую часть)
|
||||
styles_context->create_style(L"", odf_types::style_family::Text, false, true, -1);
|
||||
|
||||
@ -189,7 +189,7 @@ namespace Oox2Odf
|
||||
void convert(OOX::Logic::CRun *oox_run);
|
||||
void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties);
|
||||
void convert(ComplexTypes::Word::CFramePr *oox_frame_pr, odf_writer::style_paragraph_properties *paragraph_properties);
|
||||
void convert(OOX::Logic::CRunProperty *oox_run_prop, odf_writer::style_text_properties *text_properties);
|
||||
void convert(OOX::Logic::CRunProperty *oox_run_prop, odf_writer::style_text_properties *text_properties, bool is_list_styles = false);
|
||||
void convert(ComplexTypes::Word::CShading *oox_shading, odf_writer::style_text_properties *text_properties );
|
||||
void convert(OOX::Logic::CFldSimple *oox_fld);
|
||||
void convert(OOX::Logic::CFldChar *oox_fld);
|
||||
|
||||
@ -954,7 +954,9 @@ void PptxConverter::convert(PPTX::Logic::TableCell *oox_table_cell, int numCol)
|
||||
covered = true;
|
||||
|
||||
if (oox_table_cell->CellProperties.IsInit())
|
||||
{
|
||||
styled = (oox_table_cell->CellProperties->is_empty == false);
|
||||
}
|
||||
|
||||
odp_context->slide_context()->start_table_cell(numCol, covered, styled);
|
||||
|
||||
@ -1193,8 +1195,8 @@ bool PptxConverter::convert(PPTX::Logic::TableCellProperties *oox_table_cell_pr)
|
||||
{
|
||||
if (!oox_table_cell_pr) return false;
|
||||
|
||||
odf_writer::style_table_cell_properties *odf_cell_props = odp_context->styles_context()->last_state()->get_table_cell_properties();
|
||||
odf_writer::style_paragraph_properties *odf_para_props = odp_context->styles_context()->last_state(odf_types::style_family::TableCell)->get_paragraph_properties();
|
||||
odf_writer::style_table_cell_properties *odf_cell_props = odp_context->slide_context()->get_styles_context()->last_state()->get_table_cell_properties();
|
||||
odf_writer::style_paragraph_properties *odf_para_props = odp_context->slide_context()->get_styles_context()->last_state(odf_types::style_family::TableCell)->get_paragraph_properties();
|
||||
|
||||
if (!odf_para_props) return false;
|
||||
|
||||
|
||||
@ -916,11 +916,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorkbookView *oox_book_views)
|
||||
{
|
||||
int table_id = oox_book_views->m_oActiveTab->GetValue();
|
||||
|
||||
std::map<int, OOX::Spreadsheet::CSheet*>::iterator pFind = Workbook->m_oSheets->mapSheets.find(table_id);
|
||||
|
||||
if (pFind != Workbook->m_oSheets->mapSheets.end())
|
||||
if (table_id >= 0 && table_id < Workbook->m_oSheets->m_arrItems.size())
|
||||
{
|
||||
ods_context->settings_context()->add_property(L"ActiveTable", L"string", pFind->second->m_oName.get2());
|
||||
ods_context->settings_context()->add_property(L"ActiveTable", L"string",
|
||||
Workbook->m_oSheets->m_arrItems[table_id]->m_oName.get2());
|
||||
}
|
||||
}
|
||||
if (oox_book_views->m_oShowSheetTabs.IsInit())
|
||||
|
||||
@ -15,6 +15,7 @@ PWD_ROOT_DIR = $$PWD
|
||||
|
||||
CONFIG += core_x2t
|
||||
include(../../../Common/base.pri)
|
||||
include(../../../Common/3dParty/curl/curl.pri)
|
||||
|
||||
#BOOST
|
||||
include($$PWD/../../../Common/3dParty/boost/boost.pri)
|
||||
|
||||
@ -284,7 +284,7 @@ void NSPresentationEditor::CPPTXWriter::WriteApp(CFile& oFile)
|
||||
CP_XML_NODE(L"Properties")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties");
|
||||
CP_XML_ATTR(L"xmlns:vt", L"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypess");
|
||||
CP_XML_ATTR(L"xmlns:vt", L"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
|
||||
|
||||
CP_XML_NODE(L"TotalTime")
|
||||
{
|
||||
|
||||
@ -1191,7 +1191,7 @@ namespace NSBinPptxRW
|
||||
std::to_wstring(nIndexTheme + 1) + L".xml\"/>";
|
||||
m_pWriter->WriteString(s);
|
||||
}
|
||||
void CRelsGenerator::StartNotesMaster(int nIndexTheme)
|
||||
void CRelsGenerator::StartThemeNotesMaster(int nIndexTheme)
|
||||
{
|
||||
m_pWriter->WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
|
||||
m_pWriter->WriteString(_T("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">"));
|
||||
@ -1280,22 +1280,22 @@ namespace NSBinPptxRW
|
||||
|
||||
m_pWriter->WriteString(strRels);
|
||||
}
|
||||
void CRelsGenerator::WriteNotesMaster()
|
||||
{
|
||||
std::wstring strRels0 = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
|
||||
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster\" Target=\"notesMasters/notesMaster1.xml\"/>";
|
||||
m_pWriter->WriteString(strRels0);
|
||||
}
|
||||
void CRelsGenerator::WritePresentationComments(int nComment)
|
||||
{
|
||||
std::wstring strRels = L"<Relationship Id=\"rId" + std::to_wstring( m_lNextRelsID++ ) +
|
||||
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments\" Target=\"comments/comment" +
|
||||
L"\" Type=\"http://schemas.onlyoffice.com/comments\" Target=\"comments/comment" +
|
||||
std::to_wstring(nComment) + L".xml\"/>";
|
||||
|
||||
m_pWriter->WriteString(strRels);
|
||||
}
|
||||
void CRelsGenerator::EndPresentationRels(bool bIsCommentsAuthors, bool bIsNotesMaster, bool bIsVbaProject, bool bIsJsaProject)
|
||||
void CRelsGenerator::EndPresentationRels(bool bIsCommentsAuthors, bool bIsVbaProject, bool bIsJsaProject)
|
||||
{
|
||||
if (bIsNotesMaster)
|
||||
{
|
||||
std::wstring strRels0 = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
|
||||
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster\" Target=\"notesMasters/notesMaster1.xml\"/>";
|
||||
m_pWriter->WriteString(strRels0);
|
||||
}
|
||||
std::wstring strRels1 = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
|
||||
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps\" Target=\"presProps.xml\" />";
|
||||
std::wstring strRels2 = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
|
||||
@ -1326,10 +1326,6 @@ namespace NSBinPptxRW
|
||||
m_pWriter->WriteString(strRels5);
|
||||
}
|
||||
}
|
||||
int CRelsGenerator::GetNextId()
|
||||
{
|
||||
return m_lNextRelsID;
|
||||
}
|
||||
void CRelsGenerator::CloseRels()
|
||||
{
|
||||
m_pWriter->WriteString(_T("</Relationships>"));
|
||||
|
||||
@ -401,10 +401,10 @@ namespace NSBinPptxRW
|
||||
{
|
||||
private:
|
||||
CStringWriter* m_pWriter;
|
||||
int m_lNextRelsID;
|
||||
std::map<std::wstring, _relsGeneratorInfo> m_mapImages;
|
||||
std::map<std::wstring, int> m_mapLinks;
|
||||
public:
|
||||
size_t m_lNextRelsID;
|
||||
CImageManager2* m_pManager;
|
||||
|
||||
CRelsGenerator(CImageManager2* pManager = NULL);
|
||||
@ -418,19 +418,20 @@ namespace NSBinPptxRW
|
||||
void StartLayout (int nIndexTheme);
|
||||
void StartSlide (int nIndexSlide, int nIndexLayout, int nIndexNotes);
|
||||
void StartNotes (int nIndexSlide);
|
||||
void StartNotesMaster(int nIndexTheme);
|
||||
void StartThemeNotesMaster(int nIndexTheme);
|
||||
|
||||
void WriteMasters (int nCount);
|
||||
void WriteThemes (int nCount);
|
||||
void WriteSlides (int nCount);
|
||||
void WriteNotesMaster();
|
||||
|
||||
void WriteSlideComments (int nComment);
|
||||
void WritePresentationComments (int nComment);
|
||||
int WriteChart (int nChartNumber, _INT32 lDocType);
|
||||
int WriteRels (const std::wstring& bsType, const std::wstring& bsTarget, const std::wstring& bsTargetMode);
|
||||
int WriteHyperlink (const std::wstring& strLink, const bool& bIsActionInit);
|
||||
|
||||
void EndPresentationRels (bool bIsCommentsAuthors = false, bool bIsNotesMaster = false, bool bIsVbaProject = false, bool bIsJsaProject = false );
|
||||
int GetNextId ();
|
||||
void EndPresentationRels (bool bIsCommentsAuthors = false, bool bIsVbaProject = false, bool bIsJsaProject = false );
|
||||
void CloseRels ();
|
||||
|
||||
void AddRels (const std::wstring& strRels);
|
||||
|
||||
@ -131,6 +131,11 @@ namespace PPTX2EditorAdvanced
|
||||
for (size_t nNote = 0; nNote < nCountNoteMasters; ++nNote)
|
||||
{
|
||||
smart_ptr<PPTX::NotesMaster> noteMaster = ((*presentation)[presentation->notesMasterIdLst[nNote].rid.get()]).smart_dynamic_cast<PPTX::NotesMaster>();
|
||||
if (false == noteMaster.IsInit())
|
||||
{
|
||||
// такого быть не должно
|
||||
continue;
|
||||
}
|
||||
size_t pPointerNM = (size_t)(noteMaster.operator ->());
|
||||
|
||||
std::map<size_t, LONG>::const_iterator pSearchNM = pCommon->notesMasters.find(pPointerNM);
|
||||
|
||||
@ -209,25 +209,25 @@ namespace NSBinPptxRW
|
||||
LONG nCountSlides = 0;
|
||||
bool bNotesMasterPresent = false;
|
||||
|
||||
pPair = m_mainTables.find(NSMainTables::Themes);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::Themes);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
nCountThemes = m_oReader.GetLong();
|
||||
}
|
||||
pPair = m_mainTables.find(NSMainTables::SlideMasters);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::SlideMasters);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
nCountMasters = m_oReader.GetLong();
|
||||
}
|
||||
pPair = m_mainTables.find(NSMainTables::SlideLayouts);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::SlideLayouts);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
nCountLayouts = m_oReader.GetLong();
|
||||
}
|
||||
pPair = m_mainTables.find(NSMainTables::Slides);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::Slides);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
@ -256,7 +256,7 @@ namespace NSBinPptxRW
|
||||
m_arSlides_Notes.push_back(-1);
|
||||
|
||||
// ThemeRels
|
||||
pPair = m_mainTables.find(NSMainTables::ThemeRels);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::ThemeRels);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
@ -286,7 +286,7 @@ namespace NSBinPptxRW
|
||||
}
|
||||
|
||||
// готово, теперь нужно слайдам проставить шаблоны
|
||||
pPair = m_mainTables.find(NSMainTables::SlideRels);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::SlideRels);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
@ -304,7 +304,7 @@ namespace NSBinPptxRW
|
||||
m_arSlides_Layout[index++] = m_oReader.GetULong();
|
||||
}
|
||||
}
|
||||
pPair = m_mainTables.find(NSMainTables::SlideNotesRels);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::SlideNotesRels);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
@ -574,7 +574,7 @@ namespace NSBinPptxRW
|
||||
m_arNotesMasters.push_back(elm);
|
||||
|
||||
m_oReader.m_pRels->Clear();
|
||||
m_oReader.m_pRels->StartNotesMaster(m_arSlideMasters_Theme.size());
|
||||
m_oReader.m_pRels->StartThemeNotesMaster(m_arSlideMasters_Theme.size());
|
||||
|
||||
bNotesMasterPresent = true;
|
||||
if (lCount > 0)
|
||||
@ -798,7 +798,7 @@ namespace NSBinPptxRW
|
||||
m_oReader.m_pRels->WriteMasters(nCountMasters);
|
||||
m_oReader.m_pRels->WriteThemes(nCountThemes);
|
||||
|
||||
int nCurrentRels = m_oReader.m_pRels->GetNextId();
|
||||
size_t nCurrentRels = m_oReader.m_pRels->m_lNextRelsID;
|
||||
|
||||
m_oPresentation.sldIdLst.clear();
|
||||
for (LONG i = 0; i < nCountSlides; ++i)
|
||||
@ -808,10 +808,8 @@ namespace NSBinPptxRW
|
||||
std::wstring sId = std::to_wstring(256 + i);
|
||||
|
||||
m_oPresentation.sldIdLst[i].id = sId;
|
||||
m_oPresentation.sldIdLst[i].rid = (size_t)nCurrentRels;
|
||||
++nCurrentRels;
|
||||
m_oPresentation.sldIdLst[i].rid = nCurrentRels++;
|
||||
}
|
||||
|
||||
m_oReader.m_pRels->WriteSlides(nCountSlides);
|
||||
|
||||
m_oPresentation.notesMasterIdLst.clear();
|
||||
@ -819,8 +817,8 @@ namespace NSBinPptxRW
|
||||
{
|
||||
m_oPresentation.notesMasterIdLst.push_back(PPTX::Logic::XmlId(L"p:notesMasterId"));
|
||||
|
||||
m_oPresentation.notesMasterIdLst[0].rid = (size_t)nCurrentRels;
|
||||
++nCurrentRels;
|
||||
m_oPresentation.notesMasterIdLst[0].rid = m_oReader.m_pRels->m_lNextRelsID;
|
||||
m_oReader.m_pRels->WriteNotesMaster();
|
||||
}
|
||||
if (m_oPresentation.comments.is_init())
|
||||
{
|
||||
@ -841,7 +839,7 @@ namespace NSBinPptxRW
|
||||
++nComment;
|
||||
}
|
||||
|
||||
m_oReader.m_pRels->EndPresentationRels(m_oPresentation.commentAuthors.is_init(), bNotesMasterPresent, m_oPresentation.m_pVbaProject.is_init(), m_oPresentation.m_pJsaProject.is_init());
|
||||
m_oReader.m_pRels->EndPresentationRels(m_oPresentation.commentAuthors.is_init(), m_oPresentation.m_pVbaProject.is_init(), m_oPresentation.m_pJsaProject.is_init());
|
||||
m_oReader.m_pRels->CloseRels();
|
||||
|
||||
oXmlWriter.ClearNoAttack();
|
||||
|
||||
@ -15,6 +15,7 @@ PWD_ROOT_DIR = $$PWD
|
||||
|
||||
CONFIG += core_x2t
|
||||
include(../../../../Common/base.pri)
|
||||
include(../../../../Common/3dParty/curl/curl.pri)
|
||||
|
||||
core_windows {
|
||||
QMAKE_CXXFLAGS_RELEASE += -Ob0
|
||||
|
||||
@ -405,7 +405,8 @@ public:
|
||||
|
||||
if (Header.FormatID == 2)
|
||||
{
|
||||
if (Header.OLEVersion & 0x00000500)
|
||||
if (Header.OLEVersion & 0x00000500 ||
|
||||
Header.OLEVersion & 0x00010001)
|
||||
{
|
||||
stream >> Header.ClassName;
|
||||
}
|
||||
|
||||
@ -407,60 +407,63 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
|
||||
WriteDataToPicture( sImagePath, *pOutput->m_oPicture, oParam.oReader->m_sTempFolder );
|
||||
}
|
||||
}
|
||||
int nCropedWidthGoal = pOutput->m_oPicture->m_nWidthGoal;
|
||||
if( PROP_DEF != nCropedWidthGoal )
|
||||
if (pOutput->m_oPicture)
|
||||
{
|
||||
//делаем crop
|
||||
if( image_data->m_oCropLeft.IsInit() )
|
||||
int nCropedWidthGoal = pOutput->m_oPicture->m_nWidthGoal;
|
||||
if( PROP_DEF != nCropedWidthGoal )
|
||||
{
|
||||
float nCropLeft = image_data->m_oCropLeft->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropL = nCropLeft * pOutput->m_oPicture->m_nWidthGoal * pOutput->m_oPicture->m_nScaleX / 100;
|
||||
pOutput->m_oPicture->m_nCropL = (int)(nCropLeft * pOutput->m_oPicture->m_nWidthGoal);
|
||||
pOutput->m_nCropFromLeft = (int)(nCropLeft * 65536);
|
||||
nCropedWidthGoal -= pOutput->m_oPicture->m_nCropL;
|
||||
//делаем crop
|
||||
if( image_data->m_oCropLeft.IsInit() )
|
||||
{
|
||||
float nCropLeft = image_data->m_oCropLeft->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropL = nCropLeft * pOutput->m_oPicture->m_nWidthGoal * pOutput->m_oPicture->m_nScaleX / 100;
|
||||
pOutput->m_oPicture->m_nCropL = (int)(nCropLeft * pOutput->m_oPicture->m_nWidthGoal);
|
||||
pOutput->m_nCropFromLeft = (int)(nCropLeft * 65536);
|
||||
nCropedWidthGoal -= pOutput->m_oPicture->m_nCropL;
|
||||
}
|
||||
if( image_data->m_oCropRight.IsInit())
|
||||
{
|
||||
float nCropRight =image_data->m_oCropRight->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropR = nCropRight * pOutput->m_oPicture->m_nWidthGoal * pOutput->m_oPicture->m_nScaleX / 100;
|
||||
pOutput->m_oPicture->m_nCropR = (int)(nCropRight * pOutput->m_oPicture->m_nWidthGoal);
|
||||
pOutput->m_nCropFromRight = (int)(nCropRight * 65536);
|
||||
nCropedWidthGoal -= pOutput->m_oPicture->m_nCropR;
|
||||
}
|
||||
}
|
||||
if( image_data->m_oCropRight.IsInit())
|
||||
int nCropedHeightGoal = pOutput->m_oPicture->m_nHeightGoal;
|
||||
if( PROP_DEF != nCropedHeightGoal )
|
||||
{
|
||||
float nCropRight =image_data->m_oCropRight->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropR = nCropRight * pOutput->m_oPicture->m_nWidthGoal * pOutput->m_oPicture->m_nScaleX / 100;
|
||||
pOutput->m_oPicture->m_nCropR = (int)(nCropRight * pOutput->m_oPicture->m_nWidthGoal);
|
||||
pOutput->m_nCropFromRight = (int)(nCropRight * 65536);
|
||||
nCropedWidthGoal -= pOutput->m_oPicture->m_nCropR;
|
||||
if( image_data->m_oCropTop.IsInit() )
|
||||
{
|
||||
float nCropTop = image_data->m_oCropTop->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropT = nCropTop * pOutput->m_oPicture->m_nHeightGoal * pOutput->m_oPicture->m_dScaleY / 100;
|
||||
pOutput->m_oPicture->m_nCropT = (int)(nCropTop * pOutput->m_oPicture->m_nHeightGoal);
|
||||
pOutput->m_nCropFromTop = (int)(nCropTop * 65536);
|
||||
nCropedHeightGoal -= pOutput->m_oPicture->m_nCropT;
|
||||
}
|
||||
if( image_data->m_oCropBottom.IsInit())
|
||||
{
|
||||
float nCropBottom = image_data->m_oCropBottom->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropT = nCropTop * pOutput->m_oPicture->m_nHeightGoal * pOutput->m_oPicture->m_dScaleY / 100;
|
||||
pOutput->m_oPicture->m_nCropB = (int)(nCropBottom * pOutput->m_oPicture->m_nHeightGoal);
|
||||
pOutput->m_nCropFromBottom = (int)(nCropBottom * 65536);
|
||||
nCropedHeightGoal -= pOutput->m_oPicture->m_nCropB;
|
||||
}
|
||||
}
|
||||
}
|
||||
int nCropedHeightGoal = pOutput->m_oPicture->m_nHeightGoal;
|
||||
if( PROP_DEF != nCropedHeightGoal )
|
||||
{
|
||||
if( image_data->m_oCropTop.IsInit() )
|
||||
//устанавливаем scale
|
||||
if( PROP_DEF != pOutput->m_nLeft && PROP_DEF != pOutput->m_nRight && PROP_DEF != nCropedWidthGoal && 0 != nCropedWidthGoal )
|
||||
{
|
||||
float nCropTop = image_data->m_oCropTop->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropT = nCropTop * pOutput->m_oPicture->m_nHeightGoal * pOutput->m_oPicture->m_dScaleY / 100;
|
||||
pOutput->m_oPicture->m_nCropT = (int)(nCropTop * pOutput->m_oPicture->m_nHeightGoal);
|
||||
pOutput->m_nCropFromTop = (int)(nCropTop * 65536);
|
||||
nCropedHeightGoal -= pOutput->m_oPicture->m_nCropT;
|
||||
int nWidth = pOutput->m_nRight - pOutput->m_nLeft;
|
||||
double dNewScale = 100 * ( 1.0 * nWidth / nCropedWidthGoal );
|
||||
pOutput->m_oPicture->m_dScaleX = dNewScale;
|
||||
}
|
||||
if( image_data->m_oCropBottom.IsInit())
|
||||
if( PROP_DEF != pOutput->m_nTop && PROP_DEF != pOutput->m_nBottom && PROP_DEF != nCropedHeightGoal && 0 != nCropedHeightGoal )
|
||||
{
|
||||
float nCropBottom = image_data->m_oCropBottom->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropT = nCropTop * pOutput->m_oPicture->m_nHeightGoal * pOutput->m_oPicture->m_dScaleY / 100;
|
||||
pOutput->m_oPicture->m_nCropB = (int)(nCropBottom * pOutput->m_oPicture->m_nHeightGoal);
|
||||
pOutput->m_nCropFromBottom = (int)(nCropBottom * 65536);
|
||||
nCropedHeightGoal -= pOutput->m_oPicture->m_nCropB;
|
||||
int nHeight = pOutput->m_nBottom - pOutput->m_nTop;
|
||||
double dNewScale = 100 * ( 1.0 * nHeight / nCropedHeightGoal );
|
||||
pOutput->m_oPicture->m_dScaleY = dNewScale;
|
||||
}
|
||||
}
|
||||
//устанавливаем scale
|
||||
if( PROP_DEF != pOutput->m_nLeft && PROP_DEF != pOutput->m_nRight && PROP_DEF != nCropedWidthGoal && 0 != nCropedWidthGoal )
|
||||
{
|
||||
int nWidth = pOutput->m_nRight - pOutput->m_nLeft;
|
||||
double dNewScale = 100 * ( 1.0 * nWidth / nCropedWidthGoal );
|
||||
pOutput->m_oPicture->m_dScaleX = dNewScale;
|
||||
}
|
||||
if( PROP_DEF != pOutput->m_nTop && PROP_DEF != pOutput->m_nBottom && PROP_DEF != nCropedHeightGoal && 0 != nCropedHeightGoal )
|
||||
{
|
||||
int nHeight = pOutput->m_nBottom - pOutput->m_nTop;
|
||||
double dNewScale = 100 * ( 1.0 * nHeight / nCropedHeightGoal );
|
||||
pOutput->m_oPicture->m_dScaleY = dNewScale;
|
||||
}
|
||||
}break;
|
||||
case OOX::et_wd_wrap:
|
||||
{
|
||||
|
||||
@ -271,7 +271,7 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
|
||||
|
||||
sResult += m_oCharProperty.RenderToRtf( oRenderParameter );
|
||||
|
||||
if (m_bIsOle)
|
||||
if (m_bIsOle && m_oPicture)
|
||||
{
|
||||
m_oPicture->dump_shape_properties = RenderToRtfShapeProperty( oRenderParameter );
|
||||
sResult += m_oPicture->RenderToRtf( oRenderParameter );
|
||||
@ -1143,9 +1143,8 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
|
||||
|
||||
if( PROP_DEF != m_nZOrderRelative && PROP_DEF != nZIndex)
|
||||
{
|
||||
//берем большое значение чтобы сделать строго выше или ниже текста
|
||||
if( 0 == m_nZOrderRelative ) nZIndex += 10000;
|
||||
else nZIndex -= 10000;
|
||||
if( 0 == m_nZOrderRelative ) nZIndex = abs(nZIndex);
|
||||
else nZIndex = -abs(nZIndex);
|
||||
}
|
||||
if (PROP_DEF != nZIndex)
|
||||
sStyle += L"z-index:" + std::to_wstring(nZIndex) + L";";
|
||||
|
||||
@ -455,30 +455,37 @@ public:
|
||||
}
|
||||
static int convertDateTime (std::wstring & dt_)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if ( dt_.empty() ) return PROP_DEF;
|
||||
|
||||
std::string dt(dt_.begin(), dt_.end());
|
||||
|
||||
boost::posix_time::ptime date_time_;
|
||||
try
|
||||
{
|
||||
boost::posix_time::ptime date_time_;
|
||||
|
||||
boost::posix_time::time_input_facet *tif = new boost::posix_time::time_input_facet;
|
||||
tif->set_iso_extended_format();
|
||||
std::istringstream strm(dt);
|
||||
strm.imbue(std::locale(std::locale::classic(), tif));
|
||||
strm >> date_time_;
|
||||
boost::posix_time::time_input_facet *tif = new boost::posix_time::time_input_facet;
|
||||
tif->set_iso_extended_format();
|
||||
std::istringstream strm(dt);
|
||||
strm.imbue(std::locale(std::locale::classic(), tif));
|
||||
strm >> date_time_;
|
||||
|
||||
short Min = date_time_.time_of_day().minutes();
|
||||
short Hour = date_time_.time_of_day().hours();
|
||||
short Day = date_time_.date().day();
|
||||
short Month = date_time_.date().month().as_number();
|
||||
int Year = date_time_.date().year() - 1900;
|
||||
short Min = date_time_.time_of_day().minutes();
|
||||
short Hour = date_time_.time_of_day().hours();
|
||||
short Day = date_time_.date().day();
|
||||
short Month = date_time_.date().month().as_number();
|
||||
int Year = date_time_.date().year() - 1900;
|
||||
|
||||
int result = 0;
|
||||
SETBITS(result, 0 , 5, Min);
|
||||
SETBITS(result, 6 , 10, Hour);
|
||||
SETBITS(result, 11, 15, Day);
|
||||
SETBITS(result, 16, 19, Month);
|
||||
SETBITS(result, 20, 28, Year);
|
||||
SETBITS(result, 0 , 5, Min);
|
||||
SETBITS(result, 6 , 10, Hour);
|
||||
SETBITS(result, 11, 15, Day);
|
||||
SETBITS(result, 16, 19, Month);
|
||||
SETBITS(result, 20, 28, Year);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -39,6 +39,8 @@
|
||||
#include "../Biff_records/XCT.h"
|
||||
#include "../Biff_records/CRN.h"
|
||||
|
||||
#include "../../../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -310,7 +312,7 @@ int SUPBOOK::serialize_book(std::wostream & strm)
|
||||
}
|
||||
CP_XML_NODE(L"v")
|
||||
{
|
||||
CP_XML_STREAM() << strVal;
|
||||
CP_XML_STREAM() << XmlUtils::EncodeXmlString(strVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,11 +59,11 @@ PropertyPtr PropertyFactory::ReadProperty(const unsigned int prop_type, XLS::CFS
|
||||
return PropertyPtr(new PropertyCodePage(prop_type, value_type, stream));
|
||||
default:
|
||||
{
|
||||
if (value_type == 0x001E)
|
||||
/* if (value_type == 0x001E)
|
||||
{
|
||||
return PropertyPtr(new PropertyStr(prop_type, value_type, stream));
|
||||
}
|
||||
else if (value_type == 0x0003)
|
||||
else */if (value_type == 0x0003)
|
||||
{
|
||||
return PropertyPtr(new PropertyInt(prop_type, value_type, stream));
|
||||
}
|
||||
|
||||
73
Common/3dParty/curl/build.sh
Executable file
73
Common/3dParty/curl/build.sh
Executable file
@ -0,0 +1,73 @@
|
||||
SCRIPT=$(readlink -f "$0" || grealpath "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
|
||||
case "$os" in
|
||||
Linux*)
|
||||
platform="linux"
|
||||
BUILD_PLATFORM=Linux
|
||||
;;
|
||||
Darwin*)
|
||||
platform="mac"
|
||||
BUILD_PLATFORM=MacOSX
|
||||
;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
|
||||
architecture=$(uname -m)
|
||||
arch=""
|
||||
|
||||
case "$architecture" in
|
||||
x86_64*) arch="_64" ;;
|
||||
*) arch="_32" ;;
|
||||
esac
|
||||
|
||||
if [[ -d "$SCRIPTPATH/$platform$arch" ]]
|
||||
then
|
||||
echo
|
||||
else
|
||||
mkdir "$SCRIPTPATH/$platform$arch"
|
||||
fi
|
||||
|
||||
CURL_FOLDER=curl
|
||||
cd ${CURL_FOLDER}
|
||||
|
||||
if [[ ! -f configure ]]
|
||||
then
|
||||
./buildconf
|
||||
fi
|
||||
|
||||
if [[ ! -f Makefile ]]
|
||||
then
|
||||
./configure \
|
||||
--disable-shared \
|
||||
--enable-static \
|
||||
--disable-ldap \
|
||||
--disable-sspi \
|
||||
--without-librtmp \
|
||||
--disable-ftp \
|
||||
--disable-file \
|
||||
--disable-dict \
|
||||
--disable-telnet \
|
||||
--disable-tftp \
|
||||
--disable-rtsp \
|
||||
--disable-pop3 \
|
||||
--disable-imap \
|
||||
--disable-smtp \
|
||||
--disable-gopher \
|
||||
--disable-smb \
|
||||
--without-libidn
|
||||
fi
|
||||
|
||||
make
|
||||
|
||||
if [ ! -d "$SCRIPTPATH/$platform$arch/build" ]
|
||||
then
|
||||
DESTDIR="$SCRIPTPATH/$platform$arch" make install
|
||||
mkdir -p "$SCRIPTPATH/$platform$arch/build"
|
||||
cp "$SCRIPTPATH/$platform$arch/usr/local/lib/libcurl.a" "$SCRIPTPATH/$platform$arch/build/"
|
||||
fi
|
||||
|
||||
5
Common/3dParty/curl/curl.pri
Normal file
5
Common/3dParty/curl/curl.pri
Normal file
@ -0,0 +1,5 @@
|
||||
core_linux {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include
|
||||
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libcurl.a
|
||||
}
|
||||
@ -1,55 +1,64 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
SET platform=win_32
|
||||
SET ICU_MAJOR_VER=60
|
||||
SET ICU_MINOR_VER=2
|
||||
|
||||
SET build_platform=win_32
|
||||
if defined ProgramFiles(x86) (
|
||||
SET platform=win_64
|
||||
SET build_platform=win_64
|
||||
)
|
||||
|
||||
if defined TARGET (
|
||||
SET platform=%TARGET%
|
||||
SET build_platform=%TARGET%
|
||||
)
|
||||
|
||||
if not exist "%platform%" (
|
||||
md "%platform%"
|
||||
if "%build_platform%" == "win_32" (
|
||||
SET MACHINE=x86
|
||||
)
|
||||
|
||||
if not exist "%platform%\build" (
|
||||
md "%platform%\build"
|
||||
if "%build_platform%" == "win_64" (
|
||||
SET MACHINE=x64
|
||||
)
|
||||
|
||||
if "%platform%" == "win_64" (
|
||||
SET URL=http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-Win64-msvc10.zip
|
||||
if not exist "%build_platform%" (
|
||||
md "%build_platform%"
|
||||
)
|
||||
|
||||
if not exist "%build_platform%\build" (
|
||||
md "%build_platform%\build"
|
||||
)
|
||||
|
||||
cd "%SCRIPTPATH%%build_platform%"
|
||||
|
||||
if exist "%SCRIPTPATH%%build_platform%\icu\" (
|
||||
echo "icu already exported"
|
||||
) else (
|
||||
SET URL=http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-Win32-msvc10.zip
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-%ICU_MAJOR_VER%-%ICU_MINOR_VER%/icu4c ./icu
|
||||
)
|
||||
|
||||
if exist "%SCRIPTPATH%%platform%\icu.zip" (
|
||||
echo "icu already downloaded"
|
||||
SET VC=%ProgramFiles%\Microsoft Visual Studio 14.0\VC
|
||||
SET VC64=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC
|
||||
if exist %VC64% (
|
||||
SET VC=%VC64%
|
||||
)
|
||||
|
||||
call "%VC%\vcvarsall.bat" %MACHINE%
|
||||
|
||||
if "%build_platform%" == "win_64" (
|
||||
MSBuild.exe icu\source\allinone\allinone.sln /p:Configuration=Release /p:PlatformToolset=v140 /p:Platform="X64"
|
||||
) else (
|
||||
Powershell.exe Invoke-WebRequest -OutFile %platform%\icu.zip -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox "%URL%"
|
||||
MSBuild.exe icu\source\allinone\allinone.sln /p:Configuration=Release /p:PlatformToolset=v140 /p:Platform="Win32"
|
||||
)
|
||||
|
||||
SET UNSIP_PROGRAMM="C:\Program Files\7-Zip\7z.exe"
|
||||
SET UNSIP_PROGRAMM2="C:\Program Files (x86)\7-Zip\7z.exe"
|
||||
if exist %UNSIP_PROGRAMM2% (
|
||||
SET UNSIP_PROGRAMM=%UNSIP_PROGRAMM2%
|
||||
)
|
||||
|
||||
if exist "%SCRIPTPATH%%platform%\icu\" (
|
||||
echo "icu already extracted"
|
||||
if "%build_platform%" == "win_64" (
|
||||
XCOPY /Y "%SCRIPTPATH%%build_platform%\icu\bin64\icudt%ICU_MAJOR_VER%.dll" "%SCRIPTPATH%%build_platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%build_platform%\icu\bin64\icuuc%ICU_MAJOR_VER%.dll" "%SCRIPTPATH%%build_platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%build_platform%\icu\lib64\icudt.lib" "%SCRIPTPATH%%build_platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%build_platform%\icu\lib64\icuuc.lib" "%SCRIPTPATH%%build_platform%\build\"
|
||||
) else (
|
||||
call %UNSIP_PROGRAMM% x "%SCRIPTPATH%%platform%\icu.zip" -o"%SCRIPTPATH%%platform%\"
|
||||
)
|
||||
|
||||
if "%platform%" == "win_64" (
|
||||
XCOPY /Y "%SCRIPTPATH%%platform%\icu\bin64\icudt55.dll" "%SCRIPTPATH%%platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%platform%\icu\bin64\icuuc55.dll" "%SCRIPTPATH%%platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%platform%\icu\lib64\icudt.lib" "%SCRIPTPATH%%platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%platform%\icu\lib64\icuuc.lib" "%SCRIPTPATH%%platform%\build\"
|
||||
) else (
|
||||
XCOPY /Y "%SCRIPTPATH%%platform%\icu\bin\icudt55.dll" "%SCRIPTPATH%%platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%platform%\icu\bin\icuuc55.dll" "%SCRIPTPATH%%platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%platform%\icu\lib\icudt.lib" "%SCRIPTPATH%%platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%platform%\icu\lib\icuuc.lib" "%SCRIPTPATH%%platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%build_platform%\icu\bin\icudt%ICU_MAJOR_VER%.dll" "%SCRIPTPATH%%build_platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%build_platform%\icu\bin\icuuc%ICU_MAJOR_VER%.dll" "%SCRIPTPATH%%build_platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%build_platform%\icu\lib\icudt.lib" "%SCRIPTPATH%%build_platform%\build\"
|
||||
XCOPY /Y "%SCRIPTPATH%%build_platform%\icu\lib\icuuc.lib" "%SCRIPTPATH%%build_platform%\build\"
|
||||
)
|
||||
|
||||
@ -3,15 +3,31 @@
|
||||
SCRIPT=$(readlink -f "$0" || grealpath "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
|
||||
ICU_MAJOR_VER=60
|
||||
ICU_MINOR_VER=2
|
||||
|
||||
SHARED_LIB_VER=$ICU_MAJOR_VER.$ICU_MINOR_VER
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
|
||||
case "$os" in
|
||||
Linux*) platform="linux" ;;
|
||||
Darwin*) platform="mac" ;;
|
||||
Linux*)
|
||||
platform="linux"
|
||||
BUILD_PLATFORM=Linux
|
||||
SHARED_LIB_EXT=.so.$SHARED_LIB_VER
|
||||
SHARED_LIB_SHORT_EXT=.so.$ICU_MAJOR_VER
|
||||
;;
|
||||
Darwin*)
|
||||
platform="mac"
|
||||
BUILD_PLATFORM=MacOSX
|
||||
SHARED_LIB_EXT=.$SHARED_LIB_VER.dylib
|
||||
SHARED_LIB_SHORT_EXT=.$ICU_MAJOR_VER.dylib
|
||||
;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
|
||||
architecture=$(uname -m)
|
||||
arch=""
|
||||
|
||||
@ -31,46 +47,33 @@ cd "$SCRIPTPATH/$platform$arch"
|
||||
|
||||
if [ -d "build" ]
|
||||
then
|
||||
echo ""
|
||||
echo ""
|
||||
else
|
||||
mkdir "build"
|
||||
mkdir "build"
|
||||
fi
|
||||
|
||||
if [[ "$platform" == *"linux"* ]]
|
||||
then
|
||||
if [[ -f "./icu.zip" ]]
|
||||
then
|
||||
echo "icu already downloaded"
|
||||
else
|
||||
if [[ "$arch" == *"_64"* ]]
|
||||
then
|
||||
wget -O icu.zip http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-RHEL6-x64.tgz
|
||||
else
|
||||
wget -O icu.zip http://download.icu-project.org/files/icu4c/55.1/icu4c-55_1-RHEL6-i386.tgz
|
||||
fi
|
||||
fi
|
||||
if [ -d "./icu" ]
|
||||
then
|
||||
echo "icu already extracted"
|
||||
echo "icu already exported"
|
||||
else
|
||||
7z x -so "./icu.zip" | tar xf -
|
||||
fi
|
||||
cp "./usr/local/lib/libicudata.so.55.1" "build/libicudata.so.55"
|
||||
cp "./usr/local/lib/libicuuc.so.55.1" "build/libicuuc.so.55"
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
|
||||
fi
|
||||
|
||||
if [[ "$platform" == *"mac"* ]]
|
||||
then
|
||||
if [ -d "./icu" ]
|
||||
then
|
||||
echo "icu already extracted"
|
||||
else
|
||||
svn export http://source.icu-project.org/repos/icu/icu/tags/release-55-1 ./icu
|
||||
fi
|
||||
cd ./icu/source/
|
||||
./runConfigureICU MacOSX
|
||||
make
|
||||
cd ../../
|
||||
cp "./icu/source/lib/libicudata.55.1.dylib" "build/libicudata.55.1.dylib"
|
||||
cp "./icu/source/lib/libicuuc.55.1.dylib" "build/libicuuc.55.1.dylib"
|
||||
|
||||
if [ ! -f "./Makefile" ]
|
||||
then
|
||||
./runConfigureICU $BUILD_PLATFORM
|
||||
fi
|
||||
|
||||
make
|
||||
|
||||
if [ ! -d "$SCRIPTPATH/$platform$arch/usr/local" ]
|
||||
then
|
||||
DESTDIR="$SCRIPTPATH/$platform$arch" make install
|
||||
fi
|
||||
|
||||
cd ../../
|
||||
|
||||
cp "./icu/source/lib/libicudata$SHARED_LIB_EXT" "build/libicudata$SHARED_LIB_SHORT_EXT"
|
||||
cp "./icu/source/lib/libicuuc$SHARED_LIB_EXT" "build/libicuuc$SHARED_LIB_SHORT_EXT"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
core_windows {
|
||||
message($$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu/include)
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu/include
|
||||
}
|
||||
|
||||
@ -13,13 +14,13 @@ core_win_32 {
|
||||
core_linux {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include
|
||||
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.so.55
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.so.55
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.so.60
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.so.60
|
||||
}
|
||||
|
||||
core_mac {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu/source/common
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include
|
||||
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.55.1.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.55.1.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.60.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.60.dylib
|
||||
}
|
||||
|
||||
@ -145,17 +145,15 @@ namespace OOX
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
|
||||
int index = 0;
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
|
||||
|
||||
if ( _T("sheet") == sName )
|
||||
if ( _T("sheet") == sName )
|
||||
{
|
||||
CSheet* pSheet = new CSheet( oReader );
|
||||
|
||||
m_arrItems.push_back( pSheet );
|
||||
mapSheets.insert(std::make_pair(index++, pSheet));
|
||||
}
|
||||
|
||||
}
|
||||
@ -170,8 +168,6 @@ namespace OOX
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
}
|
||||
public:
|
||||
std::map<int, OOX::Spreadsheet::CSheet*> mapSheets;
|
||||
};
|
||||
} //Spreadsheet
|
||||
} // namespace OOX
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "FileDownloader.h"
|
||||
#include "FileDownloader.h"
|
||||
|
||||
#if _IOS
|
||||
#import <Foundation/Foundation.h>
|
||||
@ -27,10 +27,13 @@ public :
|
||||
}
|
||||
|
||||
virtual int DownloadFile()
|
||||
{
|
||||
m_sFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"DWD");
|
||||
if (NSFile::CFileBinary::Exists(m_sFilePath))
|
||||
NSFile::CFileBinary::Remove(m_sFilePath);
|
||||
{
|
||||
if (m_sFilePath.empty())
|
||||
{
|
||||
m_sFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"DWD");
|
||||
if (NSFile::CFileBinary::Exists(m_sFilePath))
|
||||
NSFile::CFileBinary::Remove(m_sFilePath);
|
||||
}
|
||||
|
||||
NSString* stringURL = StringWToNSString(m_sFileUrl);
|
||||
NSURL *url = [NSURL URLWithString:stringURL];
|
||||
|
||||
@ -245,8 +245,14 @@ bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (POLE::Storage * storage
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & fileName)
|
||||
bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring fileName = CorrectPathW(_fileName);
|
||||
#else
|
||||
std::wstring fileName = _fileName;
|
||||
#endif
|
||||
|
||||
//приоритет как оказывается важен
|
||||
//Metamorphic Manual for windows 28415.doc
|
||||
POLE::Storage storage(fileName.c_str());
|
||||
|
||||
@ -314,7 +314,8 @@ namespace NSDirectory
|
||||
static bool Exists(const std::wstring& strDirectory)
|
||||
{
|
||||
#if defined(_WIN32) || defined (_WIN64)
|
||||
DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str());
|
||||
std::wstring strDirectoryW = CorrectPathW(strDirectory);
|
||||
DWORD dwAttrib = ::GetFileAttributesW(strDirectoryW.c_str());
|
||||
return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
#elif __linux__
|
||||
BYTE* pUtf8 = NULL;
|
||||
|
||||
@ -43,6 +43,32 @@
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
static std::wstring CorrectPathW(const std::wstring& path)
|
||||
{
|
||||
int len = (int)path.length();
|
||||
if (2 > len)
|
||||
return path;
|
||||
|
||||
const wchar_t* path_str = path.c_str();
|
||||
if (path_str[0] == '\\' || path_str[1] == '/')
|
||||
return path;
|
||||
|
||||
// local files: '\\?\' prefix
|
||||
// server files: '\\?\UNC\' prefix <== TODO!
|
||||
int nLen = GetFullPathNameW(path_str, 0, 0, 0);
|
||||
if (2 > nLen)
|
||||
return path;
|
||||
|
||||
wchar_t* pBuf = new wchar_t[nLen * sizeof(wchar_t)];
|
||||
GetFullPathNameW(path_str, nLen, pBuf, NULL);
|
||||
if (pBuf[0] == '\\' || pBuf[1] == '/')
|
||||
return path;
|
||||
|
||||
std::wstring retPath(pBuf);
|
||||
delete [] pBuf;
|
||||
return L"\\\\?\\" + retPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), (LONG)val.length())
|
||||
@ -629,7 +655,8 @@ namespace NSFile
|
||||
bool OpenFile(const std::wstring& sFileName, bool bRewrite = false)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
if ( 0 != _wfopen_s(&m_pFile, sFileName.c_str(), bRewrite ? L"rb+" : L"rb"))
|
||||
std::wstring sFileNameW = CorrectPathW(sFileName);
|
||||
if ( 0 != _wfopen_s(&m_pFile, sFileNameW.c_str(), bRewrite ? L"rb+" : L"rb"))
|
||||
return false;
|
||||
#else
|
||||
BYTE* pUtf8 = NULL;
|
||||
@ -668,8 +695,9 @@ namespace NSFile
|
||||
bool CreateFileW(const std::wstring& sFileName)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
if ( 0 != _wfopen_s(&m_pFile, sFileName.c_str(), L"wb"))
|
||||
return false;
|
||||
std::wstring sFileNameW = CorrectPathW(sFileName);
|
||||
if ( 0 != _wfopen_s(&m_pFile, sFileNameW.c_str(), L"wb"))
|
||||
return false;
|
||||
#else
|
||||
BYTE* pUtf8 = NULL;
|
||||
LONG lLen = 0;
|
||||
@ -829,8 +857,9 @@ namespace NSFile
|
||||
static bool Exists(const std::wstring& strFileName)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring sFileNameW = CorrectPathW(strFileName);
|
||||
FILE* pFile = NULL;
|
||||
if ( 0 != _wfopen_s( &pFile, strFileName.c_str(), L"rb"))
|
||||
if ( 0 != _wfopen_s( &pFile, sFileNameW.c_str(), L"rb"))
|
||||
return false;
|
||||
#else
|
||||
BYTE* pUtf8 = NULL;
|
||||
@ -879,8 +908,10 @@ namespace NSFile
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
src.open(strSrc.c_str(), std::ios::binary);
|
||||
dst.open(strDst.c_str(), std::ios::binary);
|
||||
std::wstring sS = CorrectPathW(strSrc);
|
||||
std::wstring sD = CorrectPathW(strDst);
|
||||
src.open(sS.c_str(), std::ios::binary);
|
||||
dst.open(sD.c_str(), std::ios::binary);
|
||||
#else
|
||||
BYTE* pUtf8Src = NULL;
|
||||
LONG lLenSrc = 0;
|
||||
@ -913,7 +944,8 @@ namespace NSFile
|
||||
static bool Remove(const std::wstring& strFileName)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
int nRes = _wremove(strFileName.c_str());
|
||||
std::wstring strFileNameW = CorrectPathW(strFileName);
|
||||
int nRes = _wremove(strFileNameW.c_str());
|
||||
#else
|
||||
BYTE* pUtf8 = NULL;
|
||||
LONG lLen = 0;
|
||||
@ -938,7 +970,8 @@ namespace NSFile
|
||||
bool bIsSuccess = false;
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
HANDLE hFile = ::CreateFileW( sPath.c_str(), GENERIC_WRITE, FILE_SHARE_READ,
|
||||
std::wstring sPathW = CorrectPathW(sPath);
|
||||
HANDLE hFile = ::CreateFileW( sPathW.c_str(), GENERIC_WRITE, FILE_SHARE_READ,
|
||||
NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
if ( hFile == INVALID_HANDLE_VALUE )
|
||||
@ -1091,7 +1124,8 @@ namespace NSFile
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
FILE* pFile = NULL;
|
||||
_wfopen_s(&pFile, sFileName.c_str(), sMode.c_str());
|
||||
std::wstring sFileNameW = CorrectPathW(sFileName);
|
||||
_wfopen_s(&pFile, sFileNameW.c_str(), sMode.c_str());
|
||||
|
||||
return pFile;
|
||||
#else
|
||||
|
||||
@ -23,6 +23,7 @@ CONFIG += build_all_zlib build_zlib_as_sources
|
||||
include(../../OfficeUtils/OfficeUtils.pri)
|
||||
|
||||
include(../../Common/3dParty/v8/v8.pri)
|
||||
include(../../Common/3dParty/curl/curl.pri)
|
||||
|
||||
SOURCES += \
|
||||
memorystream.cpp \
|
||||
@ -55,8 +56,6 @@ core_windows {
|
||||
core_linux {
|
||||
SOURCES += \
|
||||
../../Common/FileDownloader/FileDownloader_curl.cpp
|
||||
|
||||
LIBS += -lcurl
|
||||
}
|
||||
core_mac {
|
||||
OBJECTIVE_SOURCES += \
|
||||
|
||||
@ -596,8 +596,8 @@ namespace MetaFile
|
||||
float fL = 0, fT = 0, fW = 0, fH = 0;
|
||||
pFontManager->LoadFontByName(wsFaceName, dFontHeight, lStyle, 72, 72);
|
||||
pFontManager->SetCharSpacing(GetCharSpace());
|
||||
double dFHeight = dFontHeight * pFontManager->m_pFont->GetHeight() / pFontManager->m_pFont->m_lUnits_Per_Em;
|
||||
double dFDescent = dFontHeight * pFontManager->m_pFont->GetDescender() / pFontManager->m_pFont->m_lUnits_Per_Em;
|
||||
double dFHeight = pFontManager->m_pFont ? (dFontHeight * pFontManager->m_pFont->GetHeight() / pFontManager->m_pFont->m_lUnits_Per_Em) : 0;
|
||||
double dFDescent = pFontManager->m_pFont ? (dFontHeight * pFontManager->m_pFont->GetDescender() / pFontManager->m_pFont->m_lUnits_Per_Em) : 0;
|
||||
double dFAscent = dFHeight - std::abs(dFDescent);
|
||||
|
||||
if (NULL != pDx && unCharsCount > 1)
|
||||
|
||||
@ -8,6 +8,9 @@
|
||||
#define OOXML_HASH_ALG_SHA1 0
|
||||
#define OOXML_HASH_ALG_INVALID 1
|
||||
#define OOXML_HASH_ALG_SHA256 2
|
||||
#define OOXML_HASH_ALG_SHA224 3
|
||||
#define OOXML_HASH_ALG_SHA384 4
|
||||
#define OOXML_HASH_ALG_SHA512 5
|
||||
|
||||
#define OPEN_SSL_WARNING_OK 0
|
||||
#define OPEN_SSL_WARNING_ERR 1
|
||||
@ -15,31 +18,11 @@
|
||||
#define OPEN_SSL_WARNING_PASS 4
|
||||
#define OPEN_SSL_WARNING_NOVERIFY 8
|
||||
|
||||
class ICertificate;
|
||||
class Q_DECL_EXPORT ICertificateSelectDialogOpenSsl
|
||||
namespace NSOpenSSL
|
||||
{
|
||||
public:
|
||||
ICertificateSelectDialogOpenSsl()
|
||||
{
|
||||
}
|
||||
virtual ~ICertificateSelectDialogOpenSsl()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::wstring GetCertificatePath() = 0;
|
||||
virtual std::wstring GetCertificatePassword() = 0;
|
||||
|
||||
virtual std::wstring GetKeyPath() = 0;
|
||||
virtual std::wstring GetKeyPassword() = 0;
|
||||
|
||||
virtual bool ShowSelectDialog() = 0;
|
||||
virtual int ShowCertificate(ICertificate* pCert) = 0;
|
||||
|
||||
static int LoadKey(std::wstring file, std::string password);
|
||||
static int LoadCert(std::wstring file, std::string password);
|
||||
static void SetOpenSslDialogApplication(ICertificateSelectDialogOpenSsl* pDialog);
|
||||
};
|
||||
Q_DECL_EXPORT int LoadKey(std::wstring file, std::string password);
|
||||
Q_DECL_EXPORT int LoadCert(std::wstring file, std::string password);
|
||||
}
|
||||
|
||||
class Q_DECL_EXPORT CCertificateInfo
|
||||
{
|
||||
@ -123,22 +106,30 @@ public:
|
||||
virtual std::string GetHash(const std::wstring& sXmlFile, int nAlg) = 0;
|
||||
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg) = 0;
|
||||
|
||||
virtual bool LoadFromBase64Data(const std::string& data) = 0;
|
||||
virtual bool LoadFromBase64Data(const std::string& data) = 0;
|
||||
|
||||
virtual std::vector<int> GetHashAlgs() = 0;
|
||||
virtual int GetHashAlg() = 0;
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog() = 0;
|
||||
virtual int ShowCertificate() = 0;
|
||||
|
||||
virtual void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog) {}
|
||||
virtual int ShowSelectDialog(void* parent = NULL) = 0;
|
||||
virtual int ShowCertificate(void* parent = NULL) = 0;
|
||||
|
||||
static CCertificateInfo GetDefault();
|
||||
static ICertificate* GetById(const std::string& id);
|
||||
|
||||
virtual CCertificateInfo GetInfo();
|
||||
|
||||
virtual bool FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword);
|
||||
|
||||
public:
|
||||
static int GetOOXMLHashAlg(const std::string& sAlg);
|
||||
static ICertificate* CreateInstance();
|
||||
static std::string GetDigestMethodA(const int& nAlg);
|
||||
static std::wstring GetDigestMethod(const int& nAlg);
|
||||
static std::string GetSignatureMethodA(const int& nAlg);
|
||||
static std::wstring GetSignatureMethod(const int& nAlg);
|
||||
|
||||
static ICertificate* CreateInstance();
|
||||
};
|
||||
|
||||
#endif // _XML_SERTIFICATE_BASE_H_
|
||||
|
||||
@ -46,7 +46,9 @@ public:
|
||||
m_date = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(date);
|
||||
|
||||
m_signed_info.WriteString("<CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>");
|
||||
m_signed_info.WriteString("<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>");
|
||||
m_signed_info.WriteString("<SignatureMethod Algorithm=\"");
|
||||
m_signed_info.WriteString(ICertificate::GetSignatureMethodA(m_certificate->GetHashAlg()));
|
||||
m_signed_info.WriteString("\"/>");
|
||||
}
|
||||
~COOXMLSigner_private()
|
||||
{
|
||||
@ -55,9 +57,9 @@ public:
|
||||
std::wstring GetReference(const std::wstring& file, const std::wstring& content_type)
|
||||
{
|
||||
std::wstring sXml = L"<Reference URI=\"" + file + L"?ContentType=" + content_type + L"\">";
|
||||
sXml += L"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>";
|
||||
sXml += (L"<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethod(m_certificate->GetHashAlg()) + L"\"/>");
|
||||
sXml += L"<DigestValue>";
|
||||
std::string sTmp = m_certificate->GetHash(m_sFolder + file, OOXML_HASH_ALG_SHA1);
|
||||
std::string sTmp = m_certificate->GetHash(m_sFolder + file, m_certificate->GetHashAlg());
|
||||
sXml += UTF8_TO_U(sTmp);
|
||||
sXml += L"</DigestValue>";
|
||||
sXml += L"</Reference>";
|
||||
@ -68,7 +70,7 @@ public:
|
||||
{
|
||||
std::string sXmlSigned = U_TO_UTF8(xml);
|
||||
sXmlSigned = CXmlCanonicalizator::Execute(sXmlSigned, XML_C14N_1_0);
|
||||
return m_certificate->GetHash(sXmlSigned, OOXML_HASH_ALG_SHA1);
|
||||
return m_certificate->GetHash(sXmlSigned, m_certificate->GetHashAlg());
|
||||
}
|
||||
|
||||
std::string GetReferenceMain(const std::wstring& xml, const std::wstring& id, const bool& isCannon = true)
|
||||
@ -87,7 +89,7 @@ public:
|
||||
if (isCannon)
|
||||
sRet = "<Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>";
|
||||
|
||||
sRet += ("<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>" + sHash + "</DigestValue>");
|
||||
sRet += ("<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethodA(m_certificate->GetHashAlg()) + "\"/><DigestValue>" + sHash + "</DigestValue>");
|
||||
|
||||
return sRet;
|
||||
}
|
||||
@ -144,7 +146,7 @@ public:
|
||||
builder.WriteString(file);
|
||||
builder.WriteString(L"?ContentType=application/vnd.openxmlformats-package.relationships+xml\">");
|
||||
builder.WriteString(oRels.GetTransforms());
|
||||
builder.WriteString(L"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>");
|
||||
builder.WriteString(L"<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethod(m_certificate->GetHashAlg()) + L"\"/><DigestValue>");
|
||||
|
||||
std::wstring sXml = oRels.GetXml();
|
||||
std::string sHash = GetHashXml(sXml);
|
||||
@ -489,13 +491,16 @@ Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-sign
|
||||
std::string sKeyA = m_certificate->GetNumber();
|
||||
std::wstring sKey = UTF8_TO_U(sKeyA);
|
||||
|
||||
std::string sCertHA = m_certificate->GetCertificateHash();
|
||||
std::wstring sCertHW = UTF8_TO_U(sCertHA);
|
||||
|
||||
std::wstring sXml = (L"<xd:SignedSignatureProperties>\
|
||||
<xd:SigningTime>" + m_date + L"</xd:SigningTime>\
|
||||
<xd:SigningCertificate>\
|
||||
<xd:Cert>\
|
||||
<xd:CertDigest>\
|
||||
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\
|
||||
<DigestValue>MJJT2Y0iMxaPGVXBmOLb9bY60pA=</DigestValue>\
|
||||
<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethod(m_certificate->GetHashAlg()) + L"\"/>\
|
||||
<DigestValue>" + sCertHW + L"</DigestValue>\
|
||||
</xd:CertDigest>\
|
||||
<xd:IssuerSerial>\
|
||||
<X509IssuerName>CN=" + sName + L"</X509IssuerName>\
|
||||
@ -516,8 +521,8 @@ Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-sign
|
||||
|
||||
m_signed_info.WriteString("<Reference Type=\"http://uri.etsi.org/01903#SignedProperties\" URI=\"#idSignedProperties\">");
|
||||
m_signed_info.WriteString("<Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>");
|
||||
m_signed_info.WriteString("<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>");
|
||||
m_signed_info.WriteString(m_certificate->GetHash(sXmlTmp, OOXML_HASH_ALG_SHA1));
|
||||
m_signed_info.WriteString("<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethodA(m_certificate->GetHashAlg()) + "\"/><DigestValue>");
|
||||
m_signed_info.WriteString(m_certificate->GetHash(sXmlTmp, m_certificate->GetHashAlg()));
|
||||
m_signed_info.WriteString("</DigestValue></Reference>");
|
||||
|
||||
return (L"<Object><xd:QualifyingProperties xmlns:xd=\"http://uri.etsi.org/01903/v1.3.2#\" Target=\"#idPackageSignature\">\
|
||||
|
||||
@ -252,7 +252,9 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// 5) Check signature
|
||||
// 5) Check sert digest! (TODO:)
|
||||
|
||||
// 6) Check signature
|
||||
CXmlStackNamespaces stack(m_node);
|
||||
CXmlStackNamespaces stackRes = stack.GetById("SignedInfo", true);
|
||||
std::string sXml = stackRes.GetXml();
|
||||
@ -609,6 +611,8 @@ public:
|
||||
sFile = m_arSignaturesFiles.at(i);
|
||||
m_arSignatures.erase(m_arSignatures.begin() + i);
|
||||
delete pSignature;
|
||||
--i;
|
||||
--nCountSignatures;
|
||||
}
|
||||
}
|
||||
|
||||
@ -689,6 +693,41 @@ public:
|
||||
sXml += L"</Relationships>";
|
||||
NSFile::CFileBinary::SaveToFile(m_sFolder + L"/_rels/.rels", sXml);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring sFileFound = sFile.substr(m_sFolder.length());
|
||||
std::wstring::size_type posRemove = sFileFound.find(L"/_xmlsignatures/");
|
||||
if (std::wstring::npos != posRemove)
|
||||
sFileFound = sFileFound.substr(posRemove + 16);
|
||||
|
||||
std::wstring sOriginRels = m_sFolder + L"/_xmlsignatures/_rels/origin.sigs.rels";
|
||||
|
||||
XmlUtils::CXmlNode oRels;
|
||||
if (!oRels.FromXmlFile(sOriginRels))
|
||||
return;
|
||||
|
||||
sXml = L"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">";
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (oRels.GetNodes(L"*", oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
oNodes.GetAt(i, oNode);
|
||||
|
||||
if (L"Relationship" == oNode.GetName() &&
|
||||
L"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature" == oNode.GetAttribute(L"Type") &&
|
||||
sFileFound == oNode.GetAttribute(L"Target"))
|
||||
continue;
|
||||
|
||||
sXml += oNode.GetXml();
|
||||
}
|
||||
}
|
||||
sXml += L"</Relationships>";
|
||||
NSFile::CFileBinary::SaveToFile(sOriginRels, sXml);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2,18 +2,23 @@
|
||||
#include "./XmlSigner_mscrypto.h"
|
||||
#define CCertificate CCertificate_mscrypto
|
||||
|
||||
int ICertificateSelectDialogOpenSsl::LoadKey(std::wstring file, std::string password)
|
||||
namespace NSOpenSSL
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int LoadKey(std::wstring file, std::string password)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ICertificateSelectDialogOpenSsl::LoadCert(std::wstring file, std::string password)
|
||||
{
|
||||
return 0;
|
||||
int LoadCert(std::wstring file, std::string password)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#include "../../../common/File.h"
|
||||
|
||||
#if defined(_LINUX) && !defined(_MAC)
|
||||
#include "./XmlSigner_openssl.h"
|
||||
#define XML_CERTIFICATE_USE_OPENSSL
|
||||
@ -26,29 +31,87 @@ int ICertificateSelectDialogOpenSsl::LoadCert(std::wstring file, std::string pas
|
||||
#define CCertificate CCertificate_openssl
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
ICertificateSelectDialogOpenSsl* g_application_openssl_gialog = NULL;
|
||||
}
|
||||
|
||||
void ICertificateSelectDialogOpenSsl::SetOpenSslDialogApplication(ICertificateSelectDialogOpenSsl* pDialog)
|
||||
{
|
||||
g_application_openssl_gialog = pDialog;
|
||||
}
|
||||
|
||||
int ICertificate::GetOOXMLHashAlg(const std::string& sAlg)
|
||||
{
|
||||
if ("http://www.w3.org/2000/09/xmldsig#rsa-sha1" == sAlg ||
|
||||
"http://www.w3.org/2000/09/xmldsig#sha1" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA1;
|
||||
|
||||
/*
|
||||
if ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha224" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha224" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA224;
|
||||
*/
|
||||
|
||||
if ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha256" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmlenc#sha256" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA256;
|
||||
|
||||
if ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha384" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA384;
|
||||
|
||||
if ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha512" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmlenc#sha512" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA512;
|
||||
|
||||
return OOXML_HASH_ALG_INVALID;
|
||||
}
|
||||
|
||||
std::string ICertificate::GetDigestMethodA(const int& nAlg)
|
||||
{
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA1:
|
||||
return "http://www.w3.org/2000/09/xmldsig#sha1";
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#sha224";
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
return "http://www.w3.org/2001/04/xmlenc#sha256";
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#sha384";
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
return "http://www.w3.org/2001/04/xmlenc#sha512";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "http://www.w3.org/2000/09/xmldsig#sha1";
|
||||
}
|
||||
std::wstring ICertificate::GetDigestMethod(const int& nAlg)
|
||||
{
|
||||
std::string sTmp = GetDigestMethodA(nAlg);
|
||||
return NSFile::CUtf8Converter::GetUnicodeFromCharPtr(sTmp);
|
||||
}
|
||||
std::string ICertificate::GetSignatureMethodA(const int& nAlg)
|
||||
{
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA1:
|
||||
return "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha224";
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384";
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
|
||||
}
|
||||
std::wstring ICertificate::GetSignatureMethod(const int& nAlg)
|
||||
{
|
||||
std::string sTmp = GetSignatureMethodA(nAlg);
|
||||
return NSFile::CUtf8Converter::GetUnicodeFromCharPtr(sTmp);
|
||||
}
|
||||
|
||||
ICertificate* ICertificate::CreateInstance()
|
||||
{
|
||||
ICertificate* pCert = new CCertificate();
|
||||
pCert->SetOpenSslDialog(g_application_openssl_gialog);
|
||||
return pCert;
|
||||
}
|
||||
|
||||
@ -62,6 +125,11 @@ CCertificateInfo ICertificate::GetInfo()
|
||||
return info;
|
||||
}
|
||||
|
||||
bool ICertificate::FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CCertificateInfo ICertificate::GetDefault()
|
||||
{
|
||||
CCertificateInfo info;
|
||||
|
||||
@ -11,6 +11,80 @@
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/BigInteger.h"
|
||||
|
||||
#ifdef MS_CRYPTO_PRIVATE
|
||||
namespace NSMSCryptoPrivate
|
||||
{
|
||||
typedef BOOL (WINAPI * PFNCCERTDISPLAYPROC) (
|
||||
_In_ PCCERT_CONTEXT pCertContext,
|
||||
_In_ HWND hWndSelCertDlg,
|
||||
_In_ void *pvCallbackData
|
||||
);
|
||||
|
||||
typedef struct _CRYPTUI_SELECTCERTIFICATE_STRUCT {
|
||||
DWORD dwSize;
|
||||
HWND hwndParent;
|
||||
DWORD dwFlags;
|
||||
LPCTSTR szTitle;
|
||||
DWORD dwDontUseColumn;
|
||||
LPCTSTR szDisplayString;
|
||||
PFNCFILTERPROC pFilterCallback;
|
||||
PFNCCERTDISPLAYPROC pDisplayCallback;
|
||||
void *pvCallbackData;
|
||||
DWORD cDisplayStores;
|
||||
HCERTSTORE *rghDisplayStores;
|
||||
DWORD cStores;
|
||||
HCERTSTORE *rghStores;
|
||||
DWORD cPropSheetPages;
|
||||
LPCPROPSHEETPAGE rgPropSheetPages;
|
||||
HCERTSTORE hSelectedCertStore;
|
||||
} CRYPTUI_SELECTCERTIFICATE_STRUCT, *PCRYPTUI_SELECTCERTIFICATE_STRUCT;
|
||||
|
||||
typedef PCCERT_CONTEXT (WINAPI * _CryptUIDlgSelectCertificate) (
|
||||
_In_ PCRYPTUI_SELECTCERTIFICATE_STRUCT pcsc
|
||||
);
|
||||
|
||||
class CCertificate_mscrypto_methods
|
||||
{
|
||||
public:
|
||||
HINSTANCE m_instance;
|
||||
_CryptUIDlgSelectCertificate CryptUIDlgSelectCertificate_internal;
|
||||
|
||||
CCertificate_mscrypto_methods()
|
||||
{
|
||||
CryptUIDlgSelectCertificate_internal = NULL;
|
||||
m_instance = LoadLibraryA("Cryptui.dll");
|
||||
|
||||
if (m_instance)
|
||||
{
|
||||
CryptUIDlgSelectCertificate_internal = (_CryptUIDlgSelectCertificate)GetProcAddress(m_instance, "CryptUIDlgSelectCertificate");
|
||||
}
|
||||
}
|
||||
~CCertificate_mscrypto_methods()
|
||||
{
|
||||
if (m_instance)
|
||||
FreeLibrary(m_instance);
|
||||
}
|
||||
|
||||
PCCERT_CONTEXT ShowSelectCertificate(HWND* parent)
|
||||
{
|
||||
if (!CryptUIDlgSelectCertificate_internal)
|
||||
return NULL;
|
||||
|
||||
CRYPTUI_SELECTCERTIFICATE_STRUCT info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.hSelectedCertStore = CertOpenSystemStoreA(NULL, "MY");
|
||||
|
||||
PCCERT_CONTEXT ctx = CryptUIDlgSelectCertificate_internal(&info);
|
||||
|
||||
if (info.hSelectedCertStore != NULL)
|
||||
CertCloseStore(info.hSelectedCertStore, 0);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
class CCertificate_mscrypto : public ICertificate
|
||||
{
|
||||
public:
|
||||
@ -22,6 +96,8 @@ protected:
|
||||
BYTE* m_rawData;
|
||||
int m_rawDataLen;
|
||||
|
||||
int m_alg;
|
||||
|
||||
public:
|
||||
CCertificate_mscrypto() : ICertificate()
|
||||
{
|
||||
@ -32,6 +108,7 @@ public:
|
||||
m_rawDataLen = 0;
|
||||
|
||||
m_release = false;
|
||||
m_alg = OOXML_HASH_ALG_INVALID;
|
||||
}
|
||||
CCertificate_mscrypto(PCCERT_CONTEXT ctx) : ICertificate()
|
||||
{
|
||||
@ -42,6 +119,8 @@ public:
|
||||
m_rawDataLen = 0;
|
||||
|
||||
m_release = false;
|
||||
|
||||
GetHashAlgs();
|
||||
}
|
||||
|
||||
virtual ~CCertificate_mscrypto()
|
||||
@ -101,7 +180,7 @@ public:
|
||||
|
||||
virtual std::string GetCertificateHash()
|
||||
{
|
||||
return GetHash(m_context->pbCertEncoded, (unsigned int)m_context->cbCertEncoded, OOXML_HASH_ALG_SHA1);
|
||||
return GetHash(m_context->pbCertEncoded, (unsigned int)m_context->cbCertEncoded, GetHashAlg());
|
||||
}
|
||||
|
||||
virtual std::string GetDate()
|
||||
@ -136,7 +215,63 @@ public:
|
||||
return OPEN_SSL_WARNING_OK;
|
||||
}
|
||||
|
||||
std::vector<int> GetHashAlgs()
|
||||
{
|
||||
std::vector<int> algs;
|
||||
if (!m_context || !m_context->pCertInfo)
|
||||
return algs;
|
||||
|
||||
std::string sAlg(m_context->pCertInfo->SignatureAlgorithm.pszObjId);
|
||||
|
||||
if ("1.2.840.113549.1.1.5" == sAlg)
|
||||
algs.push_back(OOXML_HASH_ALG_SHA1);
|
||||
else if ("1.2.840.113549.1.1.11" == sAlg)
|
||||
algs.push_back(OOXML_HASH_ALG_SHA256);
|
||||
else if ("1.2.840.113549.1.1.12" == sAlg)
|
||||
algs.push_back(OOXML_HASH_ALG_SHA384);
|
||||
else if ("1.2.840.113549.1.1.13" == sAlg)
|
||||
algs.push_back(OOXML_HASH_ALG_SHA512);
|
||||
else
|
||||
algs.push_back(OOXML_HASH_ALG_SHA1);
|
||||
|
||||
if (algs.empty())
|
||||
m_alg = OOXML_HASH_ALG_SHA1;
|
||||
else
|
||||
m_alg = algs[0];
|
||||
|
||||
m_alg = OOXML_HASH_ALG_SHA1;
|
||||
return algs;
|
||||
}
|
||||
int GetHashAlg()
|
||||
{
|
||||
if (m_alg == OOXML_HASH_ALG_INVALID)
|
||||
GetHashAlgs();
|
||||
return m_alg;
|
||||
}
|
||||
|
||||
public:
|
||||
PCRYPT_KEY_PROV_INFO GetProviderInfo()
|
||||
{
|
||||
LPBYTE pInfoData = NULL;
|
||||
DWORD dwInfoDataLength = 0;
|
||||
|
||||
if (!CertGetCertificateContextProperty(m_context, CERT_KEY_PROV_INFO_PROP_ID, NULL, &dwInfoDataLength))
|
||||
return NULL;
|
||||
|
||||
if (dwInfoDataLength > 0)
|
||||
{
|
||||
pInfoData = (LPBYTE)malloc(dwInfoDataLength * sizeof(BYTE));
|
||||
|
||||
if (!CertGetCertificateContextProperty(m_context, CERT_KEY_PROV_INFO_PROP_ID, pInfoData, &dwInfoDataLength))
|
||||
{
|
||||
free(pInfoData);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return (PCRYPT_KEY_PROV_INFO)pInfoData;
|
||||
}
|
||||
|
||||
virtual std::string Sign(const std::string& sXml)
|
||||
{
|
||||
BOOL bResult = TRUE;
|
||||
@ -144,16 +279,46 @@ public:
|
||||
HCRYPTHASH hHash = NULL;
|
||||
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
bResult = CryptAcquireCertificatePrivateKey(m_context, CRYPT_ACQUIRE_COMPARE_KEY_FLAG, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
|
||||
if (!bResult)
|
||||
return "";
|
||||
|
||||
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
|
||||
int nAlg = GetHashAlg();
|
||||
bResult = CryptCreateHash(hCryptProv, GetHashId(nAlg), 0, 0, &hHash);
|
||||
if (!bResult)
|
||||
{
|
||||
PCRYPT_KEY_PROV_INFO info = GetProviderInfo();
|
||||
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
if (!CryptAcquireContextW(&hCryptProv, info->pwszContainerName, info->pwszProvName, info->dwProvType, 0))
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
free(info);
|
||||
return "";
|
||||
}
|
||||
|
||||
bResult = CryptCreateHash(hCryptProv, GetHashId(nAlg), 0, 0, &hHash);
|
||||
if (!bResult)
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
if (!CryptAcquireContextW(&hCryptProv, info->pwszContainerName, NULL, PROV_RSA_AES, 0))
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
free(info);
|
||||
return "";
|
||||
}
|
||||
|
||||
bResult = CryptCreateHash(hCryptProv, GetHashId(nAlg), 0, 0, &hHash);
|
||||
}
|
||||
|
||||
free(info);
|
||||
|
||||
if (!bResult)
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
bResult = CryptHashData(hHash, (BYTE*)sXml.c_str(), (DWORD)sXml.length(), 0);
|
||||
@ -223,10 +388,23 @@ public:
|
||||
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
|
||||
bResult = (NULL != m_context) ? CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL) : FALSE;
|
||||
bResult = FALSE;//(NULL != m_context) ? CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL) : FALSE;
|
||||
|
||||
DWORD dwProvType = PROV_RSA_FULL;
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
{
|
||||
dwProvType = PROV_RSA_AES;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bResult)
|
||||
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, (nAlg == OOXML_HASH_ALG_SHA256) ? PROV_RSA_AES : PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, dwProvType, CRYPT_VERIFYCONTEXT);
|
||||
|
||||
if (!bResult)
|
||||
return "";
|
||||
@ -308,10 +486,23 @@ public:
|
||||
HCRYPTKEY hPubKey = NULL;
|
||||
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
BOOL bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
BOOL bResult = FALSE;//CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
|
||||
DWORD dwProvType = PROV_RSA_FULL;
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
{
|
||||
dwProvType = PROV_RSA_AES;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bResult)
|
||||
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, dwProvType, CRYPT_VERIFYCONTEXT);
|
||||
|
||||
if (!bResult)
|
||||
return false;
|
||||
@ -365,30 +556,43 @@ public:
|
||||
m_rawDataLen = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
GetHashAlgs();
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int ShowCertificate()
|
||||
virtual int ShowCertificate(void* parent = NULL)
|
||||
{
|
||||
return (int)CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, m_context, NULL, NULL, 0, NULL);
|
||||
return (int)CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, m_context, (NULL == parent) ? NULL : (*((HWND*)parent)), NULL, 0, NULL);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog()
|
||||
virtual int ShowSelectDialog(void* parent = NULL)
|
||||
{
|
||||
#ifdef MS_CRYPTO_PRIVATE
|
||||
NSMSCryptoPrivate::CCertificate_mscrypto_methods methods;
|
||||
m_context = methods.ShowSelectCertificate((HWND*)parent);
|
||||
|
||||
if (m_context)
|
||||
{
|
||||
GetHashAlgs();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_store = CertOpenSystemStoreA(NULL, "MY");
|
||||
if (!m_store)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
m_context = CryptUIDlgSelectCertificateFromStore(m_store, NULL, NULL, NULL, CRYPTUI_SELECT_LOCATION_COLUMN, 0, NULL);
|
||||
m_context = CryptUIDlgSelectCertificateFromStore(m_store, (NULL == parent) ? NULL : (*((HWND*)parent)), NULL, NULL, CRYPTUI_SELECT_LOCATION_COLUMN, 0, NULL);
|
||||
if (!m_context)
|
||||
{
|
||||
CertCloseStore(m_store, 0);
|
||||
m_store = NULL;
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
return true;
|
||||
|
||||
GetHashAlgs();
|
||||
return 1;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -406,6 +610,12 @@ private:
|
||||
return CALG_SHA1;
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
return CALG_SHA_256;
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
return CALG_SHA_384;
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
return CALG_SHA_512;
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
return CALG_SHA1;
|
||||
default:
|
||||
return CALG_SHA1;
|
||||
}
|
||||
|
||||
@ -17,6 +17,36 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/conf.h>
|
||||
|
||||
const EVP_MD* Get_EVP_MD(int nAlg)
|
||||
{
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA1:
|
||||
{
|
||||
return EVP_sha1();
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
{
|
||||
return EVP_sha224();
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
{
|
||||
return EVP_sha256();
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
{
|
||||
return EVP_sha384();
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
{
|
||||
return EVP_sha512();
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return EVP_sha1();
|
||||
}
|
||||
|
||||
void BIO_FREE(BIO*& bio)
|
||||
{
|
||||
if (bio)
|
||||
@ -44,23 +74,20 @@ void X509_FREE(X509*& cert)
|
||||
|
||||
class CCertificate_openssl_private
|
||||
{
|
||||
protected:
|
||||
ICertificateSelectDialogOpenSsl* m_pDialog;
|
||||
|
||||
X509* m_cert;
|
||||
EVP_PKEY* m_key;
|
||||
|
||||
std::string m_separator;
|
||||
std::string m_id;
|
||||
|
||||
int m_alg;
|
||||
|
||||
public:
|
||||
ICertificate* m_pBase;
|
||||
|
||||
public:
|
||||
CCertificate_openssl_private()
|
||||
{
|
||||
m_pDialog = NULL;
|
||||
|
||||
m_cert = NULL;
|
||||
m_key = NULL;
|
||||
|
||||
@ -117,18 +144,25 @@ public:
|
||||
return L"";
|
||||
|
||||
X509_NAME* name = X509_get_issuer_name(m_cert);
|
||||
char buffer[1024];
|
||||
memset(buffer, 0, 1025);
|
||||
char buffer[10000];
|
||||
memset(buffer, 0, 10000);
|
||||
|
||||
X509_NAME_oneline(name, buffer, 1024);
|
||||
X509_NAME_oneline(name, buffer, 10000);
|
||||
|
||||
std::string sName(buffer);
|
||||
std::wstring sNameW = UTF8_TO_U(sName);
|
||||
|
||||
std::wstring::size_type pos = sNameW.find(L"CN=");
|
||||
if (std::wstring::npos != pos)
|
||||
{
|
||||
sNameW = sNameW.substr(pos + 3);
|
||||
pos = sNameW.find(L"/");
|
||||
|
||||
if (std::wstring::npos != pos)
|
||||
{
|
||||
sNameW = sNameW.substr(0, pos);
|
||||
}
|
||||
}
|
||||
return sNameW;
|
||||
}
|
||||
|
||||
@ -137,6 +171,7 @@ public:
|
||||
if (NULL == m_cert)
|
||||
return "";
|
||||
|
||||
#if 0
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
PEM_write_bio_X509_AUX(bio, m_cert);
|
||||
|
||||
@ -157,6 +192,27 @@ public:
|
||||
string_replace(sReturn, "\n", "");
|
||||
|
||||
BIO_free(bio);
|
||||
return sReturn;
|
||||
#endif
|
||||
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
|
||||
i2d_X509_bio(bio, m_cert);
|
||||
BIO_flush(bio);
|
||||
|
||||
BYTE* data = NULL;
|
||||
int size = (int)BIO_get_mem_data(bio, &data);
|
||||
|
||||
char* dataDst = NULL;
|
||||
int lenDst = 0;
|
||||
NSFile::CBase64Converter::Encode(data, size, dataDst, lenDst);
|
||||
|
||||
std::string sReturn(dataDst);
|
||||
|
||||
RELEASEARRAYOBJECTS(dataDst);
|
||||
|
||||
BIO_free(bio);
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
@ -167,7 +223,7 @@ public:
|
||||
int nLen = 0;
|
||||
if (NSFile::CBase64Converter::Decode(sBase64.c_str(), (int)sBase64.length(), pData, nLen))
|
||||
{
|
||||
std::string sHash = GetHash(pData, (unsigned int)nLen, OOXML_HASH_ALG_SHA1);
|
||||
std::string sHash = GetHash(pData, (unsigned int)nLen, GetHashAlg());
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sHash;
|
||||
}
|
||||
@ -209,11 +265,11 @@ public:
|
||||
return GetNumber();
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
std::string Sign(const std::string& sXml)
|
||||
{
|
||||
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
|
||||
const EVP_MD* pDigest = EVP_sha1();
|
||||
const EVP_MD* pDigest = Get_EVP_MD(this->GetHashAlg());
|
||||
|
||||
int n1 = EVP_SignInit(pCtx, pDigest);
|
||||
n1 = n1;
|
||||
@ -241,35 +297,63 @@ public:
|
||||
|
||||
std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg)
|
||||
{
|
||||
if (nAlg == OOXML_HASH_ALG_SHA1)
|
||||
int nBufLen = 0;
|
||||
unsigned char* pBufData = NULL;
|
||||
|
||||
switch (nAlg)
|
||||
{
|
||||
unsigned char obuf[20];
|
||||
SHA1(pData, (size_t)nSize, obuf);
|
||||
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(obuf, 20, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
|
||||
std::string sReturn(pBase64_hash, nBase64Len_hash);
|
||||
delete [] pBase64_hash;
|
||||
|
||||
return sReturn;
|
||||
case OOXML_HASH_ALG_SHA1:
|
||||
{
|
||||
nBufLen = 20;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA1(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
{
|
||||
nBufLen = 28;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA224(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
{
|
||||
nBufLen = 32;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA256(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
{
|
||||
nBufLen = 48;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA384(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
{
|
||||
nBufLen = 64;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA512(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else if (nAlg == OOXML_HASH_ALG_SHA256)
|
||||
{
|
||||
unsigned char obuf[32];
|
||||
SHA256(pData, (size_t)nSize, obuf);
|
||||
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(obuf, 32, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
if (0 == nBufLen)
|
||||
return "";
|
||||
|
||||
std::string sReturn(pBase64_hash, nBase64Len_hash);
|
||||
delete [] pBase64_hash;
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(pBufData, nBufLen, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
return "";
|
||||
std::string sReturn(pBase64_hash, nBase64Len_hash);
|
||||
delete [] pBase64_hash;
|
||||
|
||||
delete [] pBufData;
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
std::string GetHash(const std::string& sXml, int nAlg)
|
||||
@ -295,7 +379,7 @@ public:
|
||||
bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
|
||||
{
|
||||
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
|
||||
const EVP_MD* pDigest = EVP_sha1();
|
||||
const EVP_MD* pDigest = Get_EVP_MD(this->GetHashAlg());
|
||||
|
||||
int n1 = EVP_VerifyInit(pCtx, pDigest);
|
||||
n1 = n1;
|
||||
@ -346,27 +430,39 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
bool ShowSelectDialog()
|
||||
std::vector<int> GetHashAlgs()
|
||||
{
|
||||
if (!m_pDialog)
|
||||
return false;
|
||||
std::vector<int> algs;
|
||||
if (!m_cert)
|
||||
return algs;
|
||||
|
||||
bool bResult = m_pDialog->ShowSelectDialog();
|
||||
// TODO:
|
||||
// Check algs in cert
|
||||
|
||||
std::wstring sKeyPath = m_pDialog->GetKeyPath();
|
||||
std::wstring sKeyPasswordW = m_pDialog->GetKeyPassword();
|
||||
std::string sKeyPassword = U_TO_UTF8(sKeyPasswordW);
|
||||
if (algs.empty())
|
||||
m_alg = OOXML_HASH_ALG_SHA1;
|
||||
else
|
||||
m_alg = algs[0];
|
||||
|
||||
std::wstring sCertPath = m_pDialog->GetCertificatePath();
|
||||
std::wstring sCertPasswordW = m_pDialog->GetCertificatePassword();
|
||||
std::string sCertPassword = U_TO_UTF8(sCertPasswordW);
|
||||
|
||||
return FromFiles(sKeyPath, sKeyPassword, sCertPath, sCertPassword);
|
||||
return algs;
|
||||
}
|
||||
int GetHashAlg()
|
||||
{
|
||||
if (m_alg == OOXML_HASH_ALG_INVALID)
|
||||
GetHashAlgs();
|
||||
return m_alg;
|
||||
}
|
||||
|
||||
bool FromFiles(const std::wstring& sKeyPath, const std::string& sKeyPassword, const std::wstring& certPath, const std::string& certPassword)
|
||||
public:
|
||||
int ShowSelectDialog()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword)
|
||||
{
|
||||
std::wstring sKeyPath = keyPath;
|
||||
std::string sKeyPassword = keyPassword;
|
||||
std::wstring sCertPath = certPath;
|
||||
std::string sCertPassword = certPassword;
|
||||
|
||||
@ -375,6 +471,11 @@ public:
|
||||
sCertPath = sKeyPath;
|
||||
sCertPassword = sKeyPassword;
|
||||
}
|
||||
else if (sKeyPath.empty())
|
||||
{
|
||||
sKeyPath = sCertPath;
|
||||
sKeyPassword = sCertPassword;
|
||||
}
|
||||
|
||||
int nErr = LoadKey(sKeyPath, sKeyPassword, &m_key);
|
||||
|
||||
@ -394,6 +495,7 @@ public:
|
||||
m_id += m_separator;
|
||||
m_id += sCertPassword;
|
||||
|
||||
GetHashAlgs();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -429,18 +531,13 @@ public:
|
||||
|
||||
int ShowCertificate()
|
||||
{
|
||||
if (m_pDialog)
|
||||
return m_pDialog->ShowCertificate(m_pBase);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog)
|
||||
{
|
||||
m_pDialog = pDialog;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int VerifySelf()
|
||||
{
|
||||
return OPEN_SSL_WARNING_OK;
|
||||
|
||||
if (NULL == m_cert)
|
||||
return OPEN_SSL_WARNING_NOVERIFY;
|
||||
|
||||
@ -787,12 +884,12 @@ bool CCertificate_openssl::LoadFromBase64Data(const std::string& data)
|
||||
return m_internal->LoadFromBase64Data(data);
|
||||
}
|
||||
|
||||
bool CCertificate_openssl::ShowSelectDialog()
|
||||
int CCertificate_openssl::ShowSelectDialog(void* parent)
|
||||
{
|
||||
return m_internal->ShowSelectDialog();
|
||||
}
|
||||
|
||||
int CCertificate_openssl::ShowCertificate()
|
||||
int CCertificate_openssl::ShowCertificate(void* parent)
|
||||
{
|
||||
return m_internal->ShowCertificate();
|
||||
}
|
||||
@ -807,17 +904,24 @@ bool CCertificate_openssl::FromId(const std::string& id)
|
||||
return m_internal->FromKey(id);
|
||||
}
|
||||
|
||||
void CCertificate_openssl::SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog)
|
||||
std::vector<int> CCertificate_openssl::GetHashAlgs()
|
||||
{
|
||||
return m_internal->SetOpenSslDialog(pDialog);
|
||||
return m_internal->GetHashAlgs();
|
||||
}
|
||||
int CCertificate_openssl::GetHashAlg()
|
||||
{
|
||||
return m_internal->GetHashAlg();
|
||||
}
|
||||
|
||||
int ICertificateSelectDialogOpenSsl::LoadKey(std::wstring file, std::string password)
|
||||
namespace NSOpenSSL
|
||||
{
|
||||
return CCertificate_openssl_private::LoadKey(file, password, NULL);
|
||||
}
|
||||
int LoadKey(std::wstring file, std::string password)
|
||||
{
|
||||
return CCertificate_openssl_private::LoadKey(file, password, NULL);
|
||||
}
|
||||
|
||||
int ICertificateSelectDialogOpenSsl::LoadCert(std::wstring file, std::string password)
|
||||
{
|
||||
return CCertificate_openssl_private::LoadCert(file, password, NULL);
|
||||
int LoadCert(std::wstring file, std::string password)
|
||||
{
|
||||
return CCertificate_openssl_private::LoadCert(file, password, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,14 +41,15 @@ public:
|
||||
|
||||
virtual bool LoadFromBase64Data(const std::string& data);
|
||||
|
||||
virtual std::vector<int> GetHashAlgs();
|
||||
virtual int GetHashAlg();
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog();
|
||||
virtual int ShowCertificate();
|
||||
virtual int ShowSelectDialog(void* parent = NULL);
|
||||
virtual int ShowCertificate(void* parent = NULL);
|
||||
|
||||
bool FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword);
|
||||
virtual bool FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword);
|
||||
bool FromId(const std::string& id);
|
||||
|
||||
virtual void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog);
|
||||
};
|
||||
|
||||
#endif // _XMLSIGNER_OPENSSL_H_
|
||||
|
||||
@ -39,8 +39,16 @@ COfficeUtils::COfficeUtils(OnProgressCallback* fCallback)
|
||||
m_fCallback = fCallback;
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::ExtractToDirectory(const std::wstring& zipFile, const std::wstring& unzipDir, wchar_t* password, SHORT extract_without_path)
|
||||
HRESULT COfficeUtils::ExtractToDirectory(const std::wstring& _zipFile, const std::wstring& _unzipDir, wchar_t* password, SHORT extract_without_path)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
std::wstring unzipDir = CorrectPathW(_unzipDir);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
std::wstring unzipDir = _unzipDir;
|
||||
#endif
|
||||
|
||||
if( ZLibZipUtils::UnzipToDir( zipFile.c_str(), unzipDir.c_str(), m_fCallback, password, ( extract_without_path > 0 ) ? (true) : (false) ) == 0 )
|
||||
{
|
||||
return S_OK;
|
||||
@ -52,8 +60,16 @@ HRESULT COfficeUtils::ExtractToDirectory(const std::wstring& zipFile, const std:
|
||||
}
|
||||
|
||||
|
||||
HRESULT COfficeUtils::CompressFileOrDirectory(const std::wstring& name, const std::wstring& outputFile, bool bSorted, short level)
|
||||
HRESULT COfficeUtils::CompressFileOrDirectory(const std::wstring& _name, const std::wstring& _outputFile, bool bSorted, short level)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring name = _name;//CorrectPathW(_name);
|
||||
std::wstring outputFile = CorrectPathW(_outputFile);
|
||||
#else
|
||||
std::wstring name = _name;
|
||||
std::wstring outputFile = _outputFile;
|
||||
#endif
|
||||
|
||||
HRESULT result = S_FALSE;
|
||||
if(NSDirectory::Exists(name))
|
||||
{
|
||||
@ -104,8 +120,14 @@ HRESULT COfficeUtils::Compress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf,
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::IsArchive(const std::wstring& filename)
|
||||
HRESULT COfficeUtils::IsArchive(const std::wstring& _filename)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring filename = CorrectPathW(_filename);
|
||||
#else
|
||||
std::wstring filename = _filename;
|
||||
#endif
|
||||
|
||||
if( ZLibZipUtils::IsArchive(filename.c_str()) )
|
||||
{
|
||||
return S_OK;
|
||||
@ -116,8 +138,14 @@ HRESULT COfficeUtils::IsArchive(const std::wstring& filename)
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::IsFileExistInArchive(const std::wstring& zipFile, const std::wstring& filePath)
|
||||
HRESULT COfficeUtils::IsFileExistInArchive(const std::wstring& _zipFile, const std::wstring& filePath)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
if( ZLibZipUtils::IsFileExistInArchive( zipFile.c_str(), filePath.c_str()) )
|
||||
{
|
||||
return S_OK;
|
||||
@ -128,8 +156,14 @@ HRESULT COfficeUtils::IsFileExistInArchive(const std::wstring& zipFile, const st
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::LoadFileFromArchive(const std::wstring& zipFile, const std::wstring& filePath, BYTE** fileInBytes, ULONG& nFileSize)
|
||||
HRESULT COfficeUtils::LoadFileFromArchive(const std::wstring& _zipFile, const std::wstring& filePath, BYTE** fileInBytes, ULONG& nFileSize)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
if( ZLibZipUtils::LoadFileFromArchive( zipFile.c_str(), filePath.c_str(), fileInBytes, nFileSize))
|
||||
{
|
||||
return S_OK;
|
||||
@ -140,20 +174,38 @@ HRESULT COfficeUtils::LoadFileFromArchive(const std::wstring& zipFile, const std
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::ExtractFilesToMemory(const std::wstring& zipFile, const ExtractedFileCallback& data_receiver, void* pParam, bool* result)
|
||||
HRESULT COfficeUtils::ExtractFilesToMemory(const std::wstring& _zipFile, const ExtractedFileCallback& data_receiver, void* pParam, bool* result)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
*result = ZLibZipUtils::ExtractFiles(zipFile.c_str(), data_receiver, pParam) ? true : false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::CompressFilesFromMemory(const std::wstring& zipFile, const RequestFileCallback& data_source, void* pParam, SHORT compression_level, bool* result)
|
||||
HRESULT COfficeUtils::CompressFilesFromMemory(const std::wstring& _zipFile, const RequestFileCallback& data_source, void* pParam, SHORT compression_level, bool* result)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
*result = ZLibZipUtils::CompressFiles(zipFile.c_str(), data_source, pParam, compression_level) ? true : false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::GetFilesSize(const std::wstring& zipFile, const std::wstring& searchPattern, ULONG& nCommpressed, ULONG& nUncommpressed)
|
||||
HRESULT COfficeUtils::GetFilesSize(const std::wstring& _zipFile, const std::wstring& searchPattern, ULONG& nCommpressed, ULONG& nUncommpressed)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
if (ZLibZipUtils::GetFilesSize(zipFile.c_str(), searchPattern, nCommpressed, nUncommpressed))
|
||||
{
|
||||
return S_OK;
|
||||
|
||||
@ -31,7 +31,8 @@
|
||||
*/
|
||||
#include "./UnicodeConverter.h"
|
||||
|
||||
#include "unicode/utypes.h" /* Basic ICU data types */
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/ucnv.h" /* C Converter API */
|
||||
|
||||
#include "../DesktopEditor/common/File.h"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
QT -= core gui
|
||||
|
||||
VERSION = 1.0.0.5
|
||||
VERSION = 1.0.0.6
|
||||
TARGET = UnicodeConverter
|
||||
TEMPLATE = lib
|
||||
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
ICU Version: 55.1
|
||||
HOST: x86_64-unknown-linux-gnu
|
||||
CC Compiler: gcc
|
||||
CXX Compiler: g++
|
||||
@ -1,524 +0,0 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2015 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LEFONTINSTANCE_H
|
||||
#define __LEFONTINSTANCE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Layout Engine Font Instance object
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Instances of this class are used by <code>LEFontInstance::mapCharsToGlyphs</code> and
|
||||
* <code>LEFontInstance::mapCharToGlyph</code> to adjust character codes before the character
|
||||
* to glyph mapping process. Examples of this are filtering out control characters
|
||||
* and character mirroring - replacing a character which has both a left and a right
|
||||
* hand form with the opposite form.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
class LECharMapper /* not : public UObject because this is an interface/mixin class */
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual ~LECharMapper();
|
||||
|
||||
/**
|
||||
* This method does the adjustments.
|
||||
*
|
||||
* @param ch - the input character
|
||||
*
|
||||
* @return the adjusted character
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual LEUnicode32 mapChar(LEUnicode32 ch) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a forward reference to the class which holds the per-glyph
|
||||
* storage.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
class LEGlyphStorage;
|
||||
|
||||
/**
|
||||
* This is a virtual base class that serves as the interface between a LayoutEngine
|
||||
* and the platform font environment. It allows a LayoutEngine to access font tables, do
|
||||
* character to glyph mapping, and obtain metrics information without knowing any platform
|
||||
* specific details. There are also a few utility methods for converting between points,
|
||||
* pixels and funits. (font design units)
|
||||
*
|
||||
* An instance of an <code>LEFontInstance</code> represents a font at a particular point
|
||||
* size. Each instance can represent either a single physical font, or a composite font.
|
||||
* A composite font is a collection of physical fonts, each of which contains a subset of
|
||||
* the characters contained in the composite font.
|
||||
*
|
||||
* Note: with the exception of <code>getSubFont</code>, the methods in this class only
|
||||
* make sense for a physical font. If you have an <code>LEFontInstance</code> which
|
||||
* represents a composite font you should only call the methods below which have
|
||||
* an <code>LEGlyphID</code>, an <code>LEUnicode</code> or an <code>LEUnicode32</code>
|
||||
* as one of the arguments because these can be used to select a particular subfont.
|
||||
*
|
||||
* Subclasses which implement composite fonts should supply an implementation of these
|
||||
* methods with some default behavior such as returning constant values, or using the
|
||||
* values from the first subfont.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
class U_LAYOUT_API LEFontInstance : public UObject
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* This virtual destructor is here so that the subclass
|
||||
* destructors can be invoked through the base class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual ~LEFontInstance();
|
||||
|
||||
/**
|
||||
* Get a physical font which can render the given text. For composite fonts,
|
||||
* if there is no single physical font which can render all of the text,
|
||||
* return a physical font which can render an initial substring of the text,
|
||||
* and set the <code>offset</code> parameter to the end of that substring.
|
||||
*
|
||||
* Internally, the LayoutEngine works with runs of text all in the same
|
||||
* font and script, so it is best to call this method with text which is
|
||||
* in a single script, passing the script code in as a hint. If you don't
|
||||
* know the script of the text, you can use zero, which is the script code
|
||||
* for characters used in more than one script.
|
||||
*
|
||||
* The default implementation of this method is intended for instances of
|
||||
* <code>LEFontInstance</code> which represent a physical font. It returns
|
||||
* <code>this</code> and indicates that the entire string can be rendered.
|
||||
*
|
||||
* This method will return a valid <code>LEFontInstance</code> unless you
|
||||
* have passed illegal parameters, or an internal error has been encountered.
|
||||
* For composite fonts, it may return the warning <code>LE_NO_SUBFONT_WARNING</code>
|
||||
* to indicate that the returned font may not be able to render all of
|
||||
* the text. Whenever a valid font is returned, the <code>offset</code> parameter
|
||||
* will be advanced by at least one.
|
||||
*
|
||||
* Subclasses which implement composite fonts must override this method.
|
||||
* Where it makes sense, they should use the script code as a hint to render
|
||||
* characters from the COMMON script in the font which is used for the given
|
||||
* script. For example, if the input text is a series of Arabic words separated
|
||||
* by spaces, and the script code passed in is <code>arabScriptCode</code> you
|
||||
* should return the font used for Arabic characters for all of the input text,
|
||||
* including the spaces. If, on the other hand, the input text contains characters
|
||||
* which cannot be rendered by the font used for Arabic characters, but which can
|
||||
* be rendered by another font, you should return that font for those characters.
|
||||
*
|
||||
* @param chars - the array of Unicode characters.
|
||||
* @param offset - a pointer to the starting offset in the text. On exit this
|
||||
* will be set the the limit offset of the text which can be
|
||||
* rendered using the returned font.
|
||||
* @param limit - the limit offset for the input text.
|
||||
* @param script - the script hint.
|
||||
* @param success - set to an error code if the arguments are illegal, or no font
|
||||
* can be returned for some reason. May also be set to
|
||||
* <code>LE_NO_SUBFONT_WARNING</code> if the subfont which
|
||||
* was returned cannot render all of the text.
|
||||
*
|
||||
* @return an <code>LEFontInstance</code> for the sub font which can render the characters, or
|
||||
* <code>NULL</code> if there is an error.
|
||||
*
|
||||
* @see LEScripts.h
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const;
|
||||
|
||||
//
|
||||
// Font file access
|
||||
//
|
||||
|
||||
/**
|
||||
* This method reads a table from the font. Note that in general,
|
||||
* it only makes sense to call this method on an <code>LEFontInstance</code>
|
||||
* which represents a physical font - i.e. one which has been returned by
|
||||
* <code>getSubFont()</code>. This is because each subfont in a composite font
|
||||
* will have different tables, and there's no way to know which subfont to access.
|
||||
*
|
||||
* Subclasses which represent composite fonts should always return <code>NULL</code>.
|
||||
*
|
||||
* @param tableTag - the four byte table tag. (e.g. 'cmap')
|
||||
* @param length - ignored on entry, on exit will be the length of the table if known, or -1 if unknown.
|
||||
* @return the address of the table in memory, or <code>NULL</code>
|
||||
* if the table doesn't exist.
|
||||
* @deprecated ICU 54. See {@link LayoutEngine}
|
||||
*/
|
||||
virtual const void* getFontTable(LETag tableTag, size_t &length) const = 0;
|
||||
|
||||
/**
|
||||
* This method is used to determine if the font can
|
||||
* render the given character. This can usually be done
|
||||
* by looking the character up in the font's character
|
||||
* to glyph mapping.
|
||||
*
|
||||
* The default implementation of this method will return
|
||||
* <code>TRUE</code> if <code>mapCharToGlyph(ch)</code>
|
||||
* returns a non-zero value.
|
||||
*
|
||||
* @param ch - the character to be tested
|
||||
*
|
||||
* @return <code>TRUE</code> if the font can render ch.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual le_bool canDisplay(LEUnicode32 ch) const;
|
||||
|
||||
/**
|
||||
* This method returns the number of design units in
|
||||
* the font's EM square.
|
||||
*
|
||||
* @return the number of design units pre EM.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual le_int32 getUnitsPerEM() const = 0;
|
||||
|
||||
/**
|
||||
* This method maps an array of character codes to an array of glyph
|
||||
* indices, using the font's character to glyph map.
|
||||
*
|
||||
* The default implementation iterates over all of the characters and calls
|
||||
* <code>mapCharToGlyph(ch, mapper)</code> on each one. It also handles surrogate
|
||||
* characters, storing the glyph ID for the high surrogate, and a deleted glyph (0xFFFF)
|
||||
* for the low surrogate.
|
||||
*
|
||||
* Most sublcasses will not need to implement this method.
|
||||
*
|
||||
* @param chars - the character array
|
||||
* @param offset - the index of the first character
|
||||
* @param count - the number of characters
|
||||
* @param reverse - if <code>TRUE</code>, store the glyph indices in reverse order.
|
||||
* @param mapper - the character mapper.
|
||||
* @param filterZeroWidth - <code>TRUE</code> if ZWJ / ZWNJ characters should map to a glyph w/ no contours.
|
||||
* @param glyphStorage - the object which contains the output glyph array
|
||||
*
|
||||
* @see LECharMapper
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, le_bool filterZeroWidth, LEGlyphStorage &glyphStorage) const;
|
||||
|
||||
/**
|
||||
* This method maps a single character to a glyph index, using the
|
||||
* font's character to glyph map. The default implementation of this
|
||||
* method calls the mapper, and then calls <code>mapCharToGlyph(mappedCh)</code>.
|
||||
*
|
||||
* @param ch - the character
|
||||
* @param mapper - the character mapper
|
||||
* @param filterZeroWidth - <code>TRUE</code> if ZWJ / ZWNJ characters should map to a glyph w/ no contours.
|
||||
*
|
||||
* @return the glyph index
|
||||
*
|
||||
* @see LECharMapper
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const;
|
||||
|
||||
/**
|
||||
* This method maps a single character to a glyph index, using the
|
||||
* font's character to glyph map. The default implementation of this
|
||||
* method calls the mapper, and then calls <code>mapCharToGlyph(mappedCh)</code>.
|
||||
*
|
||||
* @param ch - the character
|
||||
* @param mapper - the character mapper
|
||||
*
|
||||
* @return the glyph index
|
||||
*
|
||||
* @see LECharMapper
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
|
||||
|
||||
/**
|
||||
* This method maps a single character to a glyph index, using the
|
||||
* font's character to glyph map. There is no default implementation
|
||||
* of this method because it requires information about the platform
|
||||
* font implementation.
|
||||
*
|
||||
* @param ch - the character
|
||||
*
|
||||
* @return the glyph index
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const = 0;
|
||||
|
||||
//
|
||||
// Metrics
|
||||
//
|
||||
|
||||
/**
|
||||
* This method gets the X and Y advance of a particular glyph, in pixels.
|
||||
*
|
||||
* @param glyph - the glyph index
|
||||
* @param advance - the X and Y pixel values will be stored here
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const = 0;
|
||||
|
||||
/**
|
||||
* This method gets the hinted X and Y pixel coordinates of a particular
|
||||
* point in the outline of the given glyph.
|
||||
*
|
||||
* @param glyph - the glyph index
|
||||
* @param pointNumber - the number of the point
|
||||
* @param point - the point's X and Y pixel values will be stored here
|
||||
*
|
||||
* @return <code>TRUE</code> if the point coordinates could be stored.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const = 0;
|
||||
|
||||
/**
|
||||
* This method returns the width of the font's EM square
|
||||
* in pixels.
|
||||
*
|
||||
* @return the pixel width of the EM square
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual float getXPixelsPerEm() const = 0;
|
||||
|
||||
/**
|
||||
* This method returns the height of the font's EM square
|
||||
* in pixels.
|
||||
*
|
||||
* @return the pixel height of the EM square
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual float getYPixelsPerEm() const = 0;
|
||||
|
||||
/**
|
||||
* This method converts font design units in the
|
||||
* X direction to points.
|
||||
*
|
||||
* @param xUnits - design units in the X direction
|
||||
*
|
||||
* @return points in the X direction
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual float xUnitsToPoints(float xUnits) const;
|
||||
|
||||
/**
|
||||
* This method converts font design units in the
|
||||
* Y direction to points.
|
||||
*
|
||||
* @param yUnits - design units in the Y direction
|
||||
*
|
||||
* @return points in the Y direction
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual float yUnitsToPoints(float yUnits) const;
|
||||
|
||||
/**
|
||||
* This method converts font design units to points.
|
||||
*
|
||||
* @param units - X and Y design units
|
||||
* @param points - set to X and Y points
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual void unitsToPoints(LEPoint &units, LEPoint &points) const;
|
||||
|
||||
/**
|
||||
* This method converts pixels in the
|
||||
* X direction to font design units.
|
||||
*
|
||||
* @param xPixels - pixels in the X direction
|
||||
*
|
||||
* @return font design units in the X direction
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual float xPixelsToUnits(float xPixels) const;
|
||||
|
||||
/**
|
||||
* This method converts pixels in the
|
||||
* Y direction to font design units.
|
||||
*
|
||||
* @param yPixels - pixels in the Y direction
|
||||
*
|
||||
* @return font design units in the Y direction
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual float yPixelsToUnits(float yPixels) const;
|
||||
|
||||
/**
|
||||
* This method converts pixels to font design units.
|
||||
*
|
||||
* @param pixels - X and Y pixel
|
||||
* @param units - set to X and Y font design units
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual void pixelsToUnits(LEPoint &pixels, LEPoint &units) const;
|
||||
|
||||
/**
|
||||
* Get the X scale factor from the font's transform. The default
|
||||
* implementation of <code>transformFunits()</code> will call this method.
|
||||
*
|
||||
* @return the X scale factor.
|
||||
*
|
||||
*
|
||||
* @see transformFunits
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual float getScaleFactorX() const = 0;
|
||||
|
||||
/**
|
||||
* Get the Y scale factor from the font's transform. The default
|
||||
* implementation of <code>transformFunits()</code> will call this method.
|
||||
*
|
||||
* @return the Yscale factor.
|
||||
*
|
||||
* @see transformFunits
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual float getScaleFactorY() const = 0;
|
||||
|
||||
/**
|
||||
* This method transforms an X, Y point in font design units to a
|
||||
* pixel coordinate, applying the font's transform. The default
|
||||
* implementation of this method calls <code>getScaleFactorX()</code>
|
||||
* and <code>getScaleFactorY()</code>.
|
||||
*
|
||||
* @param xFunits - the X coordinate in font design units
|
||||
* @param yFunits - the Y coordinate in font design units
|
||||
* @param pixels - the tranformed co-ordinate in pixels
|
||||
*
|
||||
* @see getScaleFactorX
|
||||
* @see getScaleFactorY
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
|
||||
|
||||
/**
|
||||
* This is a convenience method used to convert
|
||||
* values in a 16.16 fixed point format to floating point.
|
||||
*
|
||||
* @param fixed - the fixed point value
|
||||
*
|
||||
* @return the floating point value
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static inline float fixedToFloat(le_int32 fixed);
|
||||
|
||||
/**
|
||||
* This is a convenience method used to convert
|
||||
* floating point values to 16.16 fixed point format.
|
||||
*
|
||||
* @param theFloat - the floating point value
|
||||
*
|
||||
* @return the fixed point value
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static inline le_int32 floatToFixed(float theFloat);
|
||||
|
||||
//
|
||||
// These methods won't ever be called by the LayoutEngine,
|
||||
// but are useful for clients of <code>LEFontInstance</code> who
|
||||
// need to render text.
|
||||
//
|
||||
|
||||
/**
|
||||
* Get the font's ascent.
|
||||
*
|
||||
* @return the font's ascent, in points. This value
|
||||
* will always be positive.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual le_int32 getAscent() const = 0;
|
||||
|
||||
/**
|
||||
* Get the font's descent.
|
||||
*
|
||||
* @return the font's descent, in points. This value
|
||||
* will always be positive.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual le_int32 getDescent() const = 0;
|
||||
|
||||
/**
|
||||
* Get the font's leading.
|
||||
*
|
||||
* @return the font's leading, in points. This value
|
||||
* will always be positive.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual le_int32 getLeading() const = 0;
|
||||
|
||||
/**
|
||||
* Get the line height required to display text in
|
||||
* this font. The default implementation of this method
|
||||
* returns the sum of the ascent, descent, and leading.
|
||||
*
|
||||
* @return the line height, in points. This vaule will
|
||||
* always be positive.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual le_int32 getLineHeight() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static UClassID getStaticClassID();
|
||||
|
||||
};
|
||||
|
||||
inline float LEFontInstance::fixedToFloat(le_int32 fixed)
|
||||
{
|
||||
return (float) (fixed / 65536.0);
|
||||
}
|
||||
|
||||
inline le_int32 LEFontInstance::floatToFixed(float theFloat)
|
||||
{
|
||||
return (le_int32) (theFloat * 65536.0);
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
@ -1,45 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LEGLYPHFILTER__H
|
||||
#define __LEGLYPHFILTER__H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* This is a helper class that is used to
|
||||
* recognize a set of glyph indices.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class LEGlyphFilter /* not : public UObject because this is an interface/mixin class */ {
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @internal
|
||||
*/
|
||||
virtual ~LEGlyphFilter();
|
||||
|
||||
/**
|
||||
* This method is used to test a particular
|
||||
* glyph index to see if it is in the set
|
||||
* recognized by the filter.
|
||||
*
|
||||
* @param glyph - the glyph index to be tested
|
||||
*
|
||||
* @return TRUE if the glyph index is in the set.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual le_bool accept(LEGlyphID glyph) const = 0;
|
||||
};
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
@ -1,546 +0,0 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1998-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __LEGLYPHSTORAGE_H
|
||||
#define __LEGLYPHSTORAGE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
#include "LEInsertionList.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: This class encapsulates the per-glyph storage used by the ICU LayoutEngine.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This class encapsulates the per-glyph storage used by the ICU LayoutEngine.
|
||||
* For each glyph it holds the glyph ID, the index of the backing store character
|
||||
* which produced the glyph, the X and Y position of the glyph and an auxillary data
|
||||
* pointer.
|
||||
*
|
||||
* The storage is growable using the <code>LEInsertionList</code> class.
|
||||
*
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
class U_LAYOUT_API LEGlyphStorage : public UObject, protected LEInsertionCallback
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The number of entries in the per-glyph arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fGlyphCount;
|
||||
|
||||
/**
|
||||
* The glyph ID array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEGlyphID *fGlyphs;
|
||||
|
||||
/**
|
||||
* The char indices array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 *fCharIndices;
|
||||
|
||||
/**
|
||||
* The glyph positions array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
float *fPositions;
|
||||
|
||||
/**
|
||||
* The auxillary data array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_uint32 *fAuxData;
|
||||
|
||||
|
||||
/**
|
||||
* The insertion list, used to grow the above arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEInsertionList *fInsertionList;
|
||||
|
||||
/**
|
||||
* The source index while growing the data arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fSrcIndex;
|
||||
|
||||
/**
|
||||
* The destination index used while growing the data arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fDestIndex;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This implements <code>LEInsertionCallback</code>. The <code>LEInsertionList</code>
|
||||
* will call this method once for each insertion.
|
||||
*
|
||||
* @param atPosition the position of the insertion
|
||||
* @param count the number of glyphs being inserted
|
||||
* @param newGlyphs the address of the new glyph IDs
|
||||
*
|
||||
* @return <code>true</code> if <code>LEInsertionList</code> should stop
|
||||
* processing the insertion list after this insertion.
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Allocates an empty <code>LEGlyphStorage</code> object. You must call
|
||||
* <code>allocateGlyphArray, allocatePositions and allocateAuxData</code>
|
||||
* to allocate the data.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
LEGlyphStorage();
|
||||
|
||||
/**
|
||||
* The destructor. This will deallocate all of the arrays.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
~LEGlyphStorage();
|
||||
|
||||
/**
|
||||
* This method returns the number of glyphs in the glyph array.
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
inline le_int32 getGlyphCount() const;
|
||||
|
||||
/**
|
||||
* This method copies the glyph array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold all
|
||||
* the glyphs.
|
||||
*
|
||||
* @param glyphs - the destiniation glyph array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the glyph array into a caller supplied array,
|
||||
* ORing in extra bits. (This functionality is needed by the JDK,
|
||||
* which uses 32 bits pre glyph idex, with the high 16 bits encoding
|
||||
* the composite font slot number)
|
||||
*
|
||||
* @param glyphs - the destination (32 bit) glyph array
|
||||
* @param extraBits - this value will be ORed with each glyph index
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param indexBase - an offset which will be added to each index
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the position array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold an
|
||||
* X and Y position for each glyph, plus an extra X and Y for the
|
||||
* advance of the last glyph.
|
||||
*
|
||||
* @param positions - the destiniation position array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getGlyphPositions(float positions[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method returns the X and Y position of the glyph at
|
||||
* the given index.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param glyphIndex - the index of the glyph
|
||||
*
|
||||
* Output parameters:
|
||||
* @param x - the glyph's X position
|
||||
* @param y - the glyph's Y position
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method allocates the glyph array, the char indices array and the insertion list. You
|
||||
* must call this method before using the object. This method also initializes the char indices
|
||||
* array.
|
||||
*
|
||||
* @param initialGlyphCount the initial size of the glyph and char indices arrays.
|
||||
* @param rightToLeft <code>true</code> if the original input text is right to left.
|
||||
* @param success set to an error code if the storage cannot be allocated of if the initial
|
||||
* glyph count is not positive.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void allocateGlyphArray(le_int32 initialGlyphCount, le_bool rightToLeft, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method allocates the storage for the glyph positions. It allocates one extra X, Y
|
||||
* position pair for the position just after the last glyph.
|
||||
*
|
||||
* @param success set to an error code if the positions array cannot be allocated.
|
||||
*
|
||||
* @return the number of X, Y position pairs allocated.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
le_int32 allocatePositions(LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method allocates the storage for the auxillary glyph data.
|
||||
*
|
||||
* @param success set to an error code if the aulillary data array cannot be allocated.
|
||||
*
|
||||
* @return the size of the auxillary data array.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
le_int32 allocateAuxData(LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Copy the entire auxillary data array.
|
||||
*
|
||||
* @param auxData the auxillary data array will be copied to this address
|
||||
* @param success set to an error code if the data cannot be copied
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getAuxData(le_uint32 auxData[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* Get the glyph ID for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index into the glyph array
|
||||
* @param success set to an error code if the glyph ID cannot be retrieved.
|
||||
*
|
||||
* @return the glyph ID
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
LEGlyphID getGlyphID(le_int32 glyphIndex, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* Get the char index for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index into the glyph array
|
||||
* @param success set to an error code if the char index cannot be retrieved.
|
||||
*
|
||||
* @return the character index
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
le_int32 getCharIndex(le_int32 glyphIndex, LEErrorCode &success) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get the auxillary data for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index into the glyph array
|
||||
* @param success set to an error code if the auxillary data cannot be retrieved.
|
||||
*
|
||||
* @return the auxillary data
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
le_uint32 getAuxData(le_int32 glyphIndex, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This operator allows direct access to the glyph array
|
||||
* using the index operator.
|
||||
*
|
||||
* @param glyphIndex the index into the glyph array
|
||||
*
|
||||
* @return a reference to the given location in the glyph array
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
inline LEGlyphID &operator[](le_int32 glyphIndex) const;
|
||||
|
||||
/**
|
||||
* Call this method to replace a single glyph in the glyph array
|
||||
* with multiple glyphs. This method uses the <code>LEInsertionList</code>
|
||||
* to do the insertion. It returns the address of storage where the new
|
||||
* glyph IDs can be stored. They will not actually be inserted into the
|
||||
* glyph array until <code>applyInsertions</code> is called.
|
||||
*
|
||||
* @param atIndex the index of the glyph to be replaced
|
||||
* @param insertCount the number of glyphs to replace it with
|
||||
* @param success set to an error code if the auxillary data cannot be retrieved.
|
||||
*
|
||||
* @return the address at which to store the replacement glyphs.
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
LEGlyphID *insertGlyphs(le_int32 atIndex, le_int32 insertCount, LEErrorCode& success);
|
||||
|
||||
/**
|
||||
* Call this method to replace a single glyph in the glyph array
|
||||
* with multiple glyphs. This method uses the <code>LEInsertionList</code>
|
||||
* to do the insertion. It returns the address of storage where the new
|
||||
* glyph IDs can be stored. They will not actually be inserted into the
|
||||
* glyph array until <code>applyInsertions</code> is called.
|
||||
*
|
||||
* Note: Don't use this version, use the other version of this function which has an error code.
|
||||
*
|
||||
* @param atIndex the index of the glyph to be replaced
|
||||
* @param insertCount the number of glyphs to replace it with
|
||||
*
|
||||
* @return the address at which to store the replacement glyphs.
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
LEGlyphID *insertGlyphs(le_int32 atIndex, le_int32 insertCount);
|
||||
|
||||
/**
|
||||
* This method is used to reposition glyphs during Indic v2 processing. It moves
|
||||
* all of the relevant glyph information ( glyph, indices, positions, and auxData ),
|
||||
* from the source position to the target position, and also allows for a marker bit
|
||||
* to be set in the target glyph's auxData so that it won't be reprocessed later in the
|
||||
* cycle.
|
||||
*
|
||||
* @param fromPosition - position of the glyph to be moved
|
||||
* @param toPosition - target position of the glyph
|
||||
* @param marker marker bit
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void moveGlyph(le_int32 fromPosition, le_int32 toPosition, le_uint32 marker);
|
||||
|
||||
/**
|
||||
* This method causes all of the glyph insertions recorded by
|
||||
* <code>insertGlyphs</code> to be applied to the glyph array. The
|
||||
* new slots in the char indices and the auxillary data arrays
|
||||
* will be filled in with the values for the glyph being replaced.
|
||||
*
|
||||
* @return the new size of the glyph array
|
||||
*
|
||||
* @see LEInsertionList.h
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
le_int32 applyInsertions();
|
||||
|
||||
/**
|
||||
* Set the glyph ID for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param glyphID the new glyph ID
|
||||
* @param success will be set to an error code if the glyph ID cannot be set.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void setGlyphID(le_int32 glyphIndex, LEGlyphID glyphID, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Set the char index for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param charIndex the new char index
|
||||
* @param success will be set to an error code if the char index cannot be set.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void setCharIndex(le_int32 glyphIndex, le_int32 charIndex, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Set the X, Y position for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param x the new X position
|
||||
* @param y the new Y position
|
||||
* @param success will be set to an error code if the position cannot be set.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void setPosition(le_int32 glyphIndex, float x, float y, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Adjust the X, Y position for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param xAdjust the adjustment to the glyph's X position
|
||||
* @param yAdjust the adjustment to the glyph's Y position
|
||||
* @param success will be set to an error code if the glyph's position cannot be adjusted.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void adjustPosition(le_int32 glyphIndex, float xAdjust, float yAdjust, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Set the auxillary data for a particular glyph.
|
||||
*
|
||||
* @param glyphIndex the index of the glyph
|
||||
* @param auxData the new auxillary data
|
||||
* @param success will be set to an error code if the auxillary data cannot be set.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void setAuxData(le_int32 glyphIndex, le_uint32 auxData, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Delete the glyph array and replace it with the one
|
||||
* in <code>from</code>. Set the glyph array pointer
|
||||
* in <code>from</code> to <code>NULL</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new glyph array.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void adoptGlyphArray(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Delete the char indices array and replace it with the one
|
||||
* in <code>from</code>. Set the char indices array pointer
|
||||
* in <code>from</code> to <code>NULL</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new char indices array.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void adoptCharIndicesArray(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Delete the position array and replace it with the one
|
||||
* in <code>from</code>. Set the position array pointer
|
||||
* in <code>from</code> to <code>NULL</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new position array.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void adoptPositionArray(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Delete the auxillary data array and replace it with the one
|
||||
* in <code>from</code>. Set the auxillary data array pointer
|
||||
* in <code>from</code> to <code>NULL</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new auxillary data array.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void adoptAuxDataArray(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Change the glyph count of this object to be the same
|
||||
* as the one in <code>from</code>.
|
||||
*
|
||||
* @param from the <code>LEGlyphStorage</code> object from which
|
||||
* to get the new glyph count.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void adoptGlyphCount(LEGlyphStorage &from);
|
||||
|
||||
/**
|
||||
* Change the glyph count of this object to the given value.
|
||||
*
|
||||
* @param newGlyphCount the new glyph count.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void adoptGlyphCount(le_int32 newGlyphCount);
|
||||
|
||||
/**
|
||||
* This method frees the glyph, character index, position and
|
||||
* auxillary data arrays so that the LayoutEngine can be reused
|
||||
* to layout a different characer array. (This method is also called
|
||||
* by the destructor)
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static UClassID getStaticClassID();
|
||||
};
|
||||
|
||||
inline le_int32 LEGlyphStorage::getGlyphCount() const
|
||||
{
|
||||
return fGlyphCount;
|
||||
}
|
||||
|
||||
inline LEGlyphID &LEGlyphStorage::operator[](le_int32 glyphIndex) const
|
||||
{
|
||||
return fGlyphs[glyphIndex];
|
||||
}
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
@ -1,177 +0,0 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1998-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __LEINSERTIONLIST_H
|
||||
#define __LEINSERTIONLIST_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
struct InsertionRecord;
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* This class encapsulates the callback used by <code>LEInsertionList</code>
|
||||
* to apply an insertion from the insertion list.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class U_LAYOUT_API LEInsertionCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This method will be called by <code>LEInsertionList::applyInsertions</code> for each
|
||||
* entry on the insertion list.
|
||||
*
|
||||
* @param atPosition the position of the insertion
|
||||
* @param count the number of glyphs to insert
|
||||
* @param newGlyphs the address of the glyphs to insert
|
||||
*
|
||||
* @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should
|
||||
* stop after applying this insertion.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]) = 0;
|
||||
|
||||
/**
|
||||
* The destructor
|
||||
*/
|
||||
virtual ~LEInsertionCallback();
|
||||
};
|
||||
|
||||
/**
|
||||
* This class is used to keep track of insertions to an array of
|
||||
* <code>LEGlyphIDs</code>. The insertions are kept on a linked
|
||||
* list of <code>InsertionRecords</code> so that the glyph array
|
||||
* doesn't have to be grown for each insertion. The insertions are
|
||||
* stored on the list from leftmost to rightmost to make it easier
|
||||
* to do the insertions.
|
||||
*
|
||||
* The insertions are applied to the array by calling the
|
||||
* <code>applyInsertions</code> method, which calls a client
|
||||
* supplied <code>LEInsertionCallback</code> object to actually
|
||||
* apply the individual insertions.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class LEInsertionList : public UObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct an empty insertion list.
|
||||
*
|
||||
* @param rightToLeft <code>TRUE</code> if the glyphs are stored
|
||||
* in the array in right to left order.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEInsertionList(le_bool rightToLeft);
|
||||
|
||||
/**
|
||||
* The destructor.
|
||||
*/
|
||||
~LEInsertionList();
|
||||
|
||||
/**
|
||||
* Add an entry to the insertion list.
|
||||
*
|
||||
* @param position the glyph at this position in the array will be
|
||||
* replaced by the new glyphs.
|
||||
* @param count the number of new glyphs
|
||||
* @param success set to an error code if the auxillary data cannot be retrieved.
|
||||
*
|
||||
* @return the address of an array in which to store the new glyphs. This will
|
||||
* <em>not</em> be in the glyph array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEGlyphID *insert(le_int32 position, le_int32 count, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Return the number of new glyphs that have been inserted.
|
||||
*
|
||||
* @return the number of new glyphs which have been inserted
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 getGrowAmount();
|
||||
|
||||
/**
|
||||
* Call the <code>LEInsertionCallback</code> once for each
|
||||
* entry on the insertion list.
|
||||
*
|
||||
* @param callback the <code>LEInsertionCallback</code> to call for each insertion.
|
||||
*
|
||||
* @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to
|
||||
* terminate the insertion list processing.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_bool applyInsertions(LEInsertionCallback *callback);
|
||||
|
||||
/**
|
||||
* Empty the insertion list and free all associated
|
||||
* storage.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static UClassID getStaticClassID();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The head of the insertion list.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
InsertionRecord *head;
|
||||
|
||||
/**
|
||||
* The tail of the insertion list.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
InsertionRecord *tail;
|
||||
|
||||
/**
|
||||
* The total number of new glyphs on the insertion list.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 growAmount;
|
||||
|
||||
/**
|
||||
* Set to <code>TRUE</code> if the glyphs are in right
|
||||
* to left order. Since we want the rightmost insertion
|
||||
* to be first on the list, we need to append the
|
||||
* insertions in this case. Otherwise they're prepended.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_bool append;
|
||||
};
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
@ -1,112 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2014. All Rights Reserved.
|
||||
*
|
||||
* WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS
|
||||
* YOU REALLY KNOW WHAT YOU'RE DOING.
|
||||
*
|
||||
* Generated on: 10/26/2010 02:53:33 PM PDT
|
||||
*/
|
||||
|
||||
#ifndef __LELANGUAGES_H
|
||||
#define __LELANGUAGES_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: List of language codes for LayoutEngine
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* A provisional list of language codes. For now,
|
||||
* this is just a list of languages which the LayoutEngine
|
||||
* supports.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
enum LanguageCodes {
|
||||
nullLanguageCode = 0,
|
||||
araLanguageCode = 1,
|
||||
asmLanguageCode = 2,
|
||||
benLanguageCode = 3,
|
||||
farLanguageCode = 4,
|
||||
gujLanguageCode = 5,
|
||||
hinLanguageCode = 6,
|
||||
iwrLanguageCode = 7,
|
||||
jiiLanguageCode = 8,
|
||||
janLanguageCode = 9,
|
||||
kanLanguageCode = 10,
|
||||
kokLanguageCode = 11,
|
||||
korLanguageCode = 12,
|
||||
kshLanguageCode = 13,
|
||||
malLanguageCode = 14,
|
||||
marLanguageCode = 15,
|
||||
mlrLanguageCode = 16,
|
||||
mniLanguageCode = 17,
|
||||
oriLanguageCode = 18,
|
||||
sanLanguageCode = 19,
|
||||
sndLanguageCode = 20,
|
||||
snhLanguageCode = 21,
|
||||
syrLanguageCode = 22,
|
||||
tamLanguageCode = 23,
|
||||
telLanguageCode = 24,
|
||||
thaLanguageCode = 25,
|
||||
urdLanguageCode = 26,
|
||||
zhpLanguageCode = 27,
|
||||
zhsLanguageCode = 28,
|
||||
zhtLanguageCode = 29,
|
||||
|
||||
/** New language codes added 03/13/2008 @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
afkLanguageCode = 30,
|
||||
belLanguageCode = 31,
|
||||
bgrLanguageCode = 32,
|
||||
catLanguageCode = 33,
|
||||
cheLanguageCode = 34,
|
||||
copLanguageCode = 35,
|
||||
csyLanguageCode = 36,
|
||||
danLanguageCode = 37,
|
||||
deuLanguageCode = 38,
|
||||
dznLanguageCode = 39,
|
||||
ellLanguageCode = 40,
|
||||
engLanguageCode = 41,
|
||||
espLanguageCode = 42,
|
||||
etiLanguageCode = 43,
|
||||
euqLanguageCode = 44,
|
||||
finLanguageCode = 45,
|
||||
fraLanguageCode = 46,
|
||||
gaeLanguageCode = 47,
|
||||
hauLanguageCode = 48,
|
||||
hrvLanguageCode = 49,
|
||||
hunLanguageCode = 50,
|
||||
hyeLanguageCode = 51,
|
||||
indLanguageCode = 52,
|
||||
itaLanguageCode = 53,
|
||||
khmLanguageCode = 54,
|
||||
mngLanguageCode = 55,
|
||||
mtsLanguageCode = 56,
|
||||
nepLanguageCode = 57,
|
||||
nldLanguageCode = 58,
|
||||
pasLanguageCode = 59,
|
||||
plkLanguageCode = 60,
|
||||
ptgLanguageCode = 61,
|
||||
romLanguageCode = 62,
|
||||
rusLanguageCode = 63,
|
||||
skyLanguageCode = 64,
|
||||
slvLanguageCode = 65,
|
||||
sqiLanguageCode = 66,
|
||||
srbLanguageCode = 67,
|
||||
sveLanguageCode = 68,
|
||||
tibLanguageCode = 69,
|
||||
trkLanguageCode = 70,
|
||||
welLanguageCode = 71,
|
||||
|
||||
languageCodeCount = 72
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
@ -1,263 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2014. All Rights Reserved.
|
||||
*
|
||||
* WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS
|
||||
* YOU REALLY KNOW WHAT YOU'RE DOING.
|
||||
*
|
||||
* Generated on: 04/08/2014 03:20:04 PM PDT
|
||||
*/
|
||||
|
||||
#ifndef __LESCRIPTS_H
|
||||
#define __LESCRIPTS_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Constants for Unicode script values
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Constants for Unicode script values, generated using
|
||||
* ICU4J's <code>UScript</code> class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
enum ScriptCodes {
|
||||
zyyyScriptCode = 0,
|
||||
zinhScriptCode = 1,
|
||||
qaaiScriptCode = zinhScriptCode, /* manually added alias, for API stability */
|
||||
arabScriptCode = 2,
|
||||
armnScriptCode = 3,
|
||||
bengScriptCode = 4,
|
||||
bopoScriptCode = 5,
|
||||
cherScriptCode = 6,
|
||||
coptScriptCode = 7,
|
||||
cyrlScriptCode = 8,
|
||||
dsrtScriptCode = 9,
|
||||
devaScriptCode = 10,
|
||||
ethiScriptCode = 11,
|
||||
georScriptCode = 12,
|
||||
gothScriptCode = 13,
|
||||
grekScriptCode = 14,
|
||||
gujrScriptCode = 15,
|
||||
guruScriptCode = 16,
|
||||
haniScriptCode = 17,
|
||||
hangScriptCode = 18,
|
||||
hebrScriptCode = 19,
|
||||
hiraScriptCode = 20,
|
||||
kndaScriptCode = 21,
|
||||
kanaScriptCode = 22,
|
||||
khmrScriptCode = 23,
|
||||
laooScriptCode = 24,
|
||||
latnScriptCode = 25,
|
||||
mlymScriptCode = 26,
|
||||
mongScriptCode = 27,
|
||||
mymrScriptCode = 28,
|
||||
ogamScriptCode = 29,
|
||||
italScriptCode = 30,
|
||||
oryaScriptCode = 31,
|
||||
runrScriptCode = 32,
|
||||
sinhScriptCode = 33,
|
||||
syrcScriptCode = 34,
|
||||
tamlScriptCode = 35,
|
||||
teluScriptCode = 36,
|
||||
thaaScriptCode = 37,
|
||||
thaiScriptCode = 38,
|
||||
tibtScriptCode = 39,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
cansScriptCode = 40,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
yiiiScriptCode = 41,
|
||||
tglgScriptCode = 42,
|
||||
hanoScriptCode = 43,
|
||||
buhdScriptCode = 44,
|
||||
tagbScriptCode = 45,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
braiScriptCode = 46,
|
||||
cprtScriptCode = 47,
|
||||
limbScriptCode = 48,
|
||||
linbScriptCode = 49,
|
||||
osmaScriptCode = 50,
|
||||
shawScriptCode = 51,
|
||||
taleScriptCode = 52,
|
||||
ugarScriptCode = 53,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
hrktScriptCode = 54,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
bugiScriptCode = 55,
|
||||
glagScriptCode = 56,
|
||||
kharScriptCode = 57,
|
||||
syloScriptCode = 58,
|
||||
taluScriptCode = 59,
|
||||
tfngScriptCode = 60,
|
||||
xpeoScriptCode = 61,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
baliScriptCode = 62,
|
||||
batkScriptCode = 63,
|
||||
blisScriptCode = 64,
|
||||
brahScriptCode = 65,
|
||||
chamScriptCode = 66,
|
||||
cirtScriptCode = 67,
|
||||
cyrsScriptCode = 68,
|
||||
egydScriptCode = 69,
|
||||
egyhScriptCode = 70,
|
||||
egypScriptCode = 71,
|
||||
geokScriptCode = 72,
|
||||
hansScriptCode = 73,
|
||||
hantScriptCode = 74,
|
||||
hmngScriptCode = 75,
|
||||
hungScriptCode = 76,
|
||||
indsScriptCode = 77,
|
||||
javaScriptCode = 78,
|
||||
kaliScriptCode = 79,
|
||||
latfScriptCode = 80,
|
||||
latgScriptCode = 81,
|
||||
lepcScriptCode = 82,
|
||||
linaScriptCode = 83,
|
||||
mandScriptCode = 84,
|
||||
mayaScriptCode = 85,
|
||||
meroScriptCode = 86,
|
||||
nkooScriptCode = 87,
|
||||
orkhScriptCode = 88,
|
||||
permScriptCode = 89,
|
||||
phagScriptCode = 90,
|
||||
phnxScriptCode = 91,
|
||||
plrdScriptCode = 92,
|
||||
roroScriptCode = 93,
|
||||
saraScriptCode = 94,
|
||||
syreScriptCode = 95,
|
||||
syrjScriptCode = 96,
|
||||
syrnScriptCode = 97,
|
||||
tengScriptCode = 98,
|
||||
vaiiScriptCode = 99,
|
||||
vispScriptCode = 100,
|
||||
xsuxScriptCode = 101,
|
||||
zxxxScriptCode = 102,
|
||||
zzzzScriptCode = 103,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
cariScriptCode = 104,
|
||||
jpanScriptCode = 105,
|
||||
lanaScriptCode = 106,
|
||||
lyciScriptCode = 107,
|
||||
lydiScriptCode = 108,
|
||||
olckScriptCode = 109,
|
||||
rjngScriptCode = 110,
|
||||
saurScriptCode = 111,
|
||||
sgnwScriptCode = 112,
|
||||
sundScriptCode = 113,
|
||||
moonScriptCode = 114,
|
||||
mteiScriptCode = 115,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
armiScriptCode = 116,
|
||||
avstScriptCode = 117,
|
||||
cakmScriptCode = 118,
|
||||
koreScriptCode = 119,
|
||||
kthiScriptCode = 120,
|
||||
maniScriptCode = 121,
|
||||
phliScriptCode = 122,
|
||||
phlpScriptCode = 123,
|
||||
phlvScriptCode = 124,
|
||||
prtiScriptCode = 125,
|
||||
samrScriptCode = 126,
|
||||
tavtScriptCode = 127,
|
||||
zmthScriptCode = 128,
|
||||
zsymScriptCode = 129,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
bamuScriptCode = 130,
|
||||
lisuScriptCode = 131,
|
||||
nkgbScriptCode = 132,
|
||||
sarbScriptCode = 133,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
bassScriptCode = 134,
|
||||
duplScriptCode = 135,
|
||||
elbaScriptCode = 136,
|
||||
granScriptCode = 137,
|
||||
kpelScriptCode = 138,
|
||||
lomaScriptCode = 139,
|
||||
mendScriptCode = 140,
|
||||
mercScriptCode = 141,
|
||||
narbScriptCode = 142,
|
||||
nbatScriptCode = 143,
|
||||
palmScriptCode = 144,
|
||||
sindScriptCode = 145,
|
||||
waraScriptCode = 146,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
afakScriptCode = 147,
|
||||
jurcScriptCode = 148,
|
||||
mrooScriptCode = 149,
|
||||
nshuScriptCode = 150,
|
||||
shrdScriptCode = 151,
|
||||
soraScriptCode = 152,
|
||||
takrScriptCode = 153,
|
||||
tangScriptCode = 154,
|
||||
woleScriptCode = 155,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
hluwScriptCode = 156,
|
||||
khojScriptCode = 157,
|
||||
tirhScriptCode = 158,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
aghbScriptCode = 159,
|
||||
mahjScriptCode = 160,
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
|
||||
ahomScriptCode = 161,
|
||||
hatrScriptCode = 162,
|
||||
modiScriptCode = 163,
|
||||
multScriptCode = 164,
|
||||
paucScriptCode = 165,
|
||||
siddScriptCode = 166,
|
||||
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
scriptCodeCount
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
@ -1,100 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2014 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LESWAPS_H
|
||||
#define __LESWAPS_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Endian independent access to data for LayoutEngine
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* A convenience macro which invokes the swapWord member function
|
||||
* from a concise call.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define SWAPW(value) LESwaps::swapWord((le_uint16)(value))
|
||||
|
||||
/**
|
||||
* A convenience macro which invokes the swapLong member function
|
||||
* from a concise call.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define SWAPL(value) LESwaps::swapLong((le_uint32)(value))
|
||||
|
||||
/**
|
||||
* This class is used to access data which stored in big endian order
|
||||
* regardless of the conventions of the platform.
|
||||
*
|
||||
* All methods are static and inline in an attempt to induce the compiler
|
||||
* to do most of the calculations at compile time.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
class U_LAYOUT_API LESwaps /* not : public UObject because all methods are static */ {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Reads a big-endian 16-bit word and returns a native-endian value.
|
||||
* No-op on a big-endian platform, byte-swaps on a little-endian platform.
|
||||
*
|
||||
* @param value - the word to be byte swapped
|
||||
*
|
||||
* @return the byte swapped word
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static le_uint16 swapWord(le_uint16 value)
|
||||
{
|
||||
#if (defined(U_IS_BIG_ENDIAN) && U_IS_BIG_ENDIAN) || \
|
||||
(defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || \
|
||||
defined(__BIG_ENDIAN__)
|
||||
// Fastpath when we know that the platform is big-endian.
|
||||
return value;
|
||||
#else
|
||||
// Reads a big-endian value on any platform.
|
||||
const le_uint8 *p = reinterpret_cast<const le_uint8 *>(&value);
|
||||
return (le_uint16)((p[0] << 8) | p[1]);
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads a big-endian 32-bit word and returns a native-endian value.
|
||||
* No-op on a big-endian platform, byte-swaps on a little-endian platform.
|
||||
*
|
||||
* @param value - the long to be byte swapped
|
||||
*
|
||||
* @return the byte swapped long
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static le_uint32 swapLong(le_uint32 value)
|
||||
{
|
||||
#if (defined(U_IS_BIG_ENDIAN) && U_IS_BIG_ENDIAN) || \
|
||||
(defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || \
|
||||
defined(__BIG_ENDIAN__)
|
||||
// Fastpath when we know that the platform is big-endian.
|
||||
return value;
|
||||
#else
|
||||
// Reads a big-endian value on any platform.
|
||||
const le_uint8 *p = reinterpret_cast<const le_uint8 *>(&value);
|
||||
return (le_uint32)((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
|
||||
#endif
|
||||
};
|
||||
|
||||
private:
|
||||
LESwaps() {} // private - forbid instantiation
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
@ -1,423 +0,0 @@
|
||||
/*
|
||||
* -*- c++ -*-
|
||||
*
|
||||
* (C) Copyright IBM Corp. and others 2015 - All Rights Reserved
|
||||
*
|
||||
* Range checking
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LETABLEREFERENCE_H
|
||||
#define __LETABLEREFERENCE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
#include "LEFontInstance.h"
|
||||
|
||||
|
||||
#define kQuestionmarkTableTag 0x3F3F3F3FUL
|
||||
#define kTildeTableTag 0x7e7e7e7eUL
|
||||
#ifdef __cplusplus
|
||||
|
||||
// internal - interface for range checking
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
#if LE_ASSERT_BAD_FONT
|
||||
class LETableReference; // fwd
|
||||
/**
|
||||
* defined in OpenTypeUtilities.cpp
|
||||
* @internal
|
||||
*/
|
||||
extern void _debug_LETableReference(const char *f, int l, const char *msg, const LETableReference *what, const void *ptr, size_t len);
|
||||
|
||||
#define LE_DEBUG_TR(x) _debug_LETableReference(__FILE__, __LINE__, x, this, NULL, 0);
|
||||
#define LE_DEBUG_TR3(x,y,z) _debug_LETableReference(__FILE__, __LINE__, x, this, (const void*)y, (size_t)z);
|
||||
#if 0
|
||||
#define LE_TRACE_TR(x) _debug_LETableReference(__FILE__, __LINE__, x, this, NULL, 0);
|
||||
#else
|
||||
#define LE_TRACE_TR(x)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define LE_DEBUG_TR(x)
|
||||
#define LE_DEBUG_TR3(x,y,z)
|
||||
#define LE_TRACE_TR(x)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class LETableReference {
|
||||
public:
|
||||
/**
|
||||
* @internal
|
||||
* Construct from a specific tag
|
||||
*/
|
||||
LETableReference(const LEFontInstance* font, LETag tableTag, LEErrorCode &success) :
|
||||
fFont(font), fTag(tableTag), fParent(NULL), fStart(NULL),fLength(LE_UINTPTR_MAX) {
|
||||
loadTable(success);
|
||||
LE_TRACE_TR("INFO: new table load")
|
||||
}
|
||||
|
||||
LETableReference(const LETableReference &parent, LEErrorCode &success) : fFont(parent.fFont), fTag(parent.fTag), fParent(&parent), fStart(parent.fStart), fLength(parent.fLength) {
|
||||
if(LE_FAILURE(success)) {
|
||||
clear();
|
||||
}
|
||||
LE_TRACE_TR("INFO: new clone")
|
||||
}
|
||||
|
||||
LETableReference(const le_uint8* data, size_t length = LE_UINTPTR_MAX) :
|
||||
fFont(NULL), fTag(kQuestionmarkTableTag), fParent(NULL), fStart(data), fLength(length) {
|
||||
LE_TRACE_TR("INFO: new raw")
|
||||
}
|
||||
LETableReference() :
|
||||
fFont(NULL), fTag(kQuestionmarkTableTag), fParent(NULL), fStart(NULL), fLength(0) {
|
||||
LE_TRACE_TR("INFO: new empty")
|
||||
}
|
||||
|
||||
~LETableReference() {
|
||||
fTag=kTildeTableTag;
|
||||
LE_TRACE_TR("INFO: new dtor")
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param length if LE_UINTPTR_MAX means "whole table"
|
||||
* subset
|
||||
*/
|
||||
LETableReference(const LETableReference &parent, size_t offset, size_t length,
|
||||
LEErrorCode &err) :
|
||||
fFont(parent.fFont), fTag(parent.fTag), fParent(&parent),
|
||||
fStart((parent.fStart)+offset), fLength(length) {
|
||||
if(LE_SUCCESS(err)) {
|
||||
if(isEmpty()) {
|
||||
//err = LE_MISSING_FONT_TABLE_ERROR;
|
||||
clear(); // it's just empty. Not an error.
|
||||
} else if(offset >= fParent->fLength) {
|
||||
LE_DEBUG_TR3("offset out of range: (%p) +%d", NULL, offset);
|
||||
err = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
clear();
|
||||
} else {
|
||||
if(fLength == LE_UINTPTR_MAX &&
|
||||
fParent->fLength != LE_UINTPTR_MAX) {
|
||||
fLength = (fParent->fLength) - offset; // decrement length as base address is incremented
|
||||
}
|
||||
if(fLength != LE_UINTPTR_MAX) { // if we have bounds:
|
||||
if(offset+fLength > fParent->fLength) {
|
||||
LE_DEBUG_TR3("offset+fLength out of range: (%p) +%d", NULL, offset+fLength);
|
||||
err = LE_INDEX_OUT_OF_BOUNDS_ERROR; // exceeded
|
||||
clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
clear();
|
||||
}
|
||||
LE_TRACE_TR("INFO: new subset")
|
||||
}
|
||||
|
||||
const void* getAlias() const { return (const void*)fStart; }
|
||||
const void* getAliasRAW() const { LE_DEBUG_TR("getAliasRAW()"); return (const void*)fStart; }
|
||||
le_bool isEmpty() const { return fStart==NULL || fLength==0; }
|
||||
le_bool isValid() const { return !isEmpty(); }
|
||||
le_bool hasBounds() const { return fLength!=LE_UINTPTR_MAX; }
|
||||
void clear() { fLength=0; fStart=NULL; }
|
||||
size_t getLength() const { return fLength; }
|
||||
const LEFontInstance* getFont() const { return fFont; }
|
||||
LETag getTag() const { return fTag; }
|
||||
const LETableReference* getParent() const { return fParent; }
|
||||
|
||||
void addOffset(size_t offset, LEErrorCode &success) {
|
||||
if(hasBounds()) {
|
||||
if(offset > fLength) {
|
||||
LE_DEBUG_TR("addOffset off end");
|
||||
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
return;
|
||||
} else {
|
||||
fLength -= offset;
|
||||
}
|
||||
}
|
||||
fStart += offset;
|
||||
}
|
||||
|
||||
size_t ptrToOffset(const void *atPtr, LEErrorCode &success) const {
|
||||
if(atPtr==NULL) return 0;
|
||||
if(LE_FAILURE(success)) return LE_UINTPTR_MAX;
|
||||
if((atPtr < fStart) ||
|
||||
(hasBounds() && (atPtr > fStart+fLength))) {
|
||||
LE_DEBUG_TR3("ptrToOffset args out of range: %p", atPtr, 0);
|
||||
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
return LE_UINTPTR_MAX;
|
||||
}
|
||||
return ((const le_uint8*)atPtr)-fStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp down the length, for range checking.
|
||||
*/
|
||||
size_t contractLength(size_t newLength) {
|
||||
if(fLength!=LE_UINTPTR_MAX&&newLength>0&&newLength<=fLength) {
|
||||
fLength = newLength;
|
||||
}
|
||||
return fLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw an error if offset+length off end
|
||||
*/
|
||||
public:
|
||||
size_t verifyLength(size_t offset, size_t length, LEErrorCode &success) {
|
||||
if(isValid()&&
|
||||
LE_SUCCESS(success) &&
|
||||
fLength!=LE_UINTPTR_MAX && length!=LE_UINTPTR_MAX && offset!=LE_UINTPTR_MAX &&
|
||||
(offset+length)>fLength) {
|
||||
LE_DEBUG_TR3("verifyLength failed (%p) %d",NULL, offset+length);
|
||||
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
#if LE_ASSERT_BAD_FONT
|
||||
fprintf(stderr, "offset=%lu, len=%lu, would be at %p, (%lu) off end. End at %p\n", offset,length, fStart+offset+length, (offset+length-fLength), (offset+length-fLength)+fStart);
|
||||
#endif
|
||||
}
|
||||
return fLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change parent link to another
|
||||
*/
|
||||
LETableReference &reparent(const LETableReference &base) {
|
||||
fParent = &base;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove parent link. Factory functions should do this.
|
||||
*/
|
||||
void orphan(void) {
|
||||
fParent=NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
const LEFontInstance* fFont;
|
||||
LETag fTag;
|
||||
const LETableReference *fParent;
|
||||
const le_uint8 *fStart; // keep as 8 bit internally, for pointer math
|
||||
size_t fLength;
|
||||
|
||||
void loadTable(LEErrorCode &success) {
|
||||
if(LE_SUCCESS(success)) {
|
||||
fStart = (const le_uint8*)(fFont->getFontTable(fTag, fLength)); // note - a null table is not an error.
|
||||
}
|
||||
}
|
||||
|
||||
void setRaw(const void *data, size_t length = LE_UINTPTR_MAX) {
|
||||
fFont = NULL;
|
||||
fTag = kQuestionmarkTableTag;
|
||||
fParent = NULL;
|
||||
fStart = (const le_uint8*)data;
|
||||
fLength = length;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
class LETableVarSizer {
|
||||
public:
|
||||
inline static size_t getSize();
|
||||
};
|
||||
|
||||
// base definition- could override for adjustments
|
||||
template<class T> inline
|
||||
size_t LETableVarSizer<T>::getSize() {
|
||||
return sizeof(T);
|
||||
}
|
||||
|
||||
/**
|
||||
* \def LE_VAR_ARRAY
|
||||
* @param x Type (T)
|
||||
* @param y some member that is of length ANY_NUMBER
|
||||
* Call this after defining a class, for example:
|
||||
* LE_VAR_ARRAY(FeatureListTable,featureRecordArray)
|
||||
* this is roughly equivalent to:
|
||||
* template<> inline size_t LETableVarSizer<FeatureListTable>::getSize() { return sizeof(FeatureListTable) - (sizeof(le_uint16)*ANY_NUMBER); }
|
||||
* it's a specialization that informs the LETableReference subclasses to NOT include the variable array in the size.
|
||||
* dereferencing NULL is valid here because we never actually dereference it, just inside sizeof.
|
||||
*/
|
||||
#define LE_VAR_ARRAY(x,y) template<> inline size_t LETableVarSizer<x>::getSize() { return sizeof(x) - (sizeof(((const x*)0)->y)); }
|
||||
/**
|
||||
* \def LE_CORRECT_SIZE
|
||||
* @param x type (T)
|
||||
* @param y fixed size for T
|
||||
*/
|
||||
#define LE_CORRECT_SIZE(x,y) template<> inline size_t LETableVarSizer<x>::getSize() { return y; }
|
||||
|
||||
/**
|
||||
* Open a new entry based on an existing table
|
||||
*/
|
||||
|
||||
/**
|
||||
* \def LE_UNBOUNDED_ARRAY
|
||||
* define an array with no *known* bound. Will trim to available size.
|
||||
* @internal
|
||||
*/
|
||||
#define LE_UNBOUNDED_ARRAY LE_UINT32_MAX
|
||||
|
||||
template<class T>
|
||||
class LEReferenceToArrayOf : public LETableReference {
|
||||
public:
|
||||
LEReferenceToArrayOf(const LETableReference &parent, LEErrorCode &success, size_t offset, le_uint32 count)
|
||||
: LETableReference(parent, offset, LE_UINTPTR_MAX, success), fCount(count) {
|
||||
LE_TRACE_TR("INFO: new RTAO by offset")
|
||||
if(LE_SUCCESS(success)) {
|
||||
if(count == LE_UNBOUNDED_ARRAY) { // not a known length
|
||||
count = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
|
||||
}
|
||||
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*count, success);
|
||||
}
|
||||
if(LE_FAILURE(success)) {
|
||||
fCount=0;
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
LEReferenceToArrayOf(const LETableReference &parent, LEErrorCode &success, const T* array, le_uint32 count)
|
||||
: LETableReference(parent, parent.ptrToOffset(array, success), LE_UINTPTR_MAX, success), fCount(count) {
|
||||
LE_TRACE_TR("INFO: new RTAO")
|
||||
if(LE_SUCCESS(success)) {
|
||||
if(count == LE_UNBOUNDED_ARRAY) { // not a known length
|
||||
count = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
|
||||
}
|
||||
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*count, success);
|
||||
}
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
LEReferenceToArrayOf(const LETableReference &parent, LEErrorCode &success, const T* array, size_t offset, le_uint32 count)
|
||||
: LETableReference(parent, parent.ptrToOffset(array, success)+offset, LE_UINTPTR_MAX, success), fCount(count) {
|
||||
LE_TRACE_TR("INFO: new RTAO")
|
||||
if(LE_SUCCESS(success)) {
|
||||
if(count == LE_UNBOUNDED_ARRAY) { // not a known length
|
||||
count = getLength()/LETableVarSizer<T>::getSize(); // fit to max size
|
||||
}
|
||||
LETableReference::verifyLength(0, LETableVarSizer<T>::getSize()*count, success);
|
||||
}
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
|
||||
LEReferenceToArrayOf() :LETableReference(), fCount(0) {}
|
||||
|
||||
le_uint32 getCount() const { return fCount; }
|
||||
|
||||
using LETableReference::getAlias;
|
||||
|
||||
const T *getAlias(le_uint32 i, LEErrorCode &success) const {
|
||||
return ((const T*)(((const char*)getAlias())+getOffsetFor(i, success)));
|
||||
}
|
||||
|
||||
const T *getAliasRAW() const { LE_DEBUG_TR("getAliasRAW<>"); return (const T*)fStart; }
|
||||
|
||||
const T& getObject(le_uint32 i, LEErrorCode &success) const {
|
||||
const T *ret = getAlias(i, success);
|
||||
if (LE_FAILURE(success) || ret==NULL) {
|
||||
return *(new T(0));
|
||||
} else {
|
||||
return *ret;
|
||||
}
|
||||
}
|
||||
|
||||
const T& operator()(le_uint32 i, LEErrorCode &success) const {
|
||||
return *getAlias(i,success);
|
||||
}
|
||||
|
||||
size_t getOffsetFor(le_uint32 i, LEErrorCode &success) const {
|
||||
if(LE_SUCCESS(success)&&i<getCount()) {
|
||||
return LETableVarSizer<T>::getSize()*i;
|
||||
} else {
|
||||
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LEReferenceToArrayOf<T> &reparent(const LETableReference &base) {
|
||||
fParent = &base;
|
||||
return *this;
|
||||
}
|
||||
|
||||
LEReferenceToArrayOf(const LETableReference& parent, LEErrorCode & success) : LETableReference(parent,0, LE_UINTPTR_MAX, success), fCount(0) {
|
||||
LE_TRACE_TR("INFO: null RTAO")
|
||||
}
|
||||
|
||||
private:
|
||||
le_uint32 fCount;
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
class LEReferenceTo : public LETableReference {
|
||||
public:
|
||||
/**
|
||||
* open a sub reference.
|
||||
* @param parent parent reference
|
||||
* @param success error status
|
||||
* @param atPtr location of reference - if NULL, will be at offset zero (i.e. downcast of parent). Otherwise must be a pointer within parent's bounds.
|
||||
*/
|
||||
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr)
|
||||
: LETableReference(parent, parent.ptrToOffset(atPtr, success), LE_UINTPTR_MAX, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
/**
|
||||
* ptr plus offset
|
||||
*/
|
||||
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr, size_t offset)
|
||||
: LETableReference(parent, parent.ptrToOffset(atPtr, success)+offset, LE_UINTPTR_MAX, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, size_t offset)
|
||||
: LETableReference(parent, offset, LE_UINTPTR_MAX, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success)
|
||||
: LETableReference(parent, 0, LE_UINTPTR_MAX, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
inline LEReferenceTo(const LEFontInstance *font, LETag tableTag, LEErrorCode &success)
|
||||
: LETableReference(font, tableTag, success) {
|
||||
verifyLength(0, LETableVarSizer<T>::getSize(), success);
|
||||
if(LE_FAILURE(success)) clear();
|
||||
}
|
||||
inline LEReferenceTo(const le_uint8 *data, size_t length = LE_UINTPTR_MAX) : LETableReference(data, length) {}
|
||||
inline LEReferenceTo(const T *data, size_t length = LE_UINTPTR_MAX) : LETableReference((const le_uint8*)data, length) {}
|
||||
inline LEReferenceTo() : LETableReference(NULL) {}
|
||||
|
||||
inline LEReferenceTo<T>& operator=(const T* other) {
|
||||
setRaw(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
LEReferenceTo<T> &reparent(const LETableReference &base) {
|
||||
fParent = &base;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* roll forward by one <T> size.
|
||||
* same as addOffset(LETableVarSizer<T>::getSize(),success)
|
||||
*/
|
||||
void addObject(LEErrorCode &success) {
|
||||
addOffset(LETableVarSizer<T>::getSize(), success);
|
||||
}
|
||||
void addObject(size_t count, LEErrorCode &success) {
|
||||
addOffset(LETableVarSizer<T>::getSize()*count, success);
|
||||
}
|
||||
|
||||
const T *operator->() const { return getAlias(); }
|
||||
const T *getAlias() const { return (const T*)fStart; }
|
||||
const T *getAliasRAW() const { LE_DEBUG_TR("getAliasRAW<>"); return (const T*)fStart; }
|
||||
};
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,728 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. and others 1998-2014 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LETYPES_H
|
||||
#define __LETYPES_H
|
||||
|
||||
#if !defined(LE_USE_CMEMORY) && (defined(U_LAYOUT_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION) || defined(U_STATIC_IMPLEMENTATION) || defined(U_COMBINED_IMPLEMENTATION))
|
||||
#define LE_USE_CMEMORY
|
||||
#endif
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "unicode/uobject.h"
|
||||
#endif
|
||||
|
||||
#ifdef LE_USE_CMEMORY
|
||||
#include "cmemory.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \brief C API: Basic definitions for the ICU LayoutEngine
|
||||
*/
|
||||
|
||||
/**
|
||||
* A type used for signed, 32-bit integers.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef int32_t le_int32;
|
||||
|
||||
/**
|
||||
* A type used for unsigned, 32-bit integers.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef uint32_t le_uint32;
|
||||
|
||||
/**
|
||||
* A type used for signed, 16-bit integers.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef int16_t le_int16;
|
||||
|
||||
/**
|
||||
* A type used for unsigned, 16-bit integers.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef uint16_t le_uint16;
|
||||
|
||||
/**
|
||||
* A type used for signed, 8-bit integers.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef int8_t le_int8;
|
||||
|
||||
/**
|
||||
* A type used for unsigned, 8-bit integers.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef uint8_t le_uint8;
|
||||
|
||||
|
||||
/**
|
||||
* A type used for boolean values.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef UBool le_bool;
|
||||
|
||||
#ifndef NULL
|
||||
/**
|
||||
* Used to represent empty pointers.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Used for four character tags.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef le_uint32 LETag;
|
||||
|
||||
/**
|
||||
* Used for 16-bit glyph indices as they're represented
|
||||
* in TrueType font tables.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef le_uint16 TTGlyphID;
|
||||
|
||||
/**
|
||||
* Used for glyph indices. The low-order 16 bits are
|
||||
* the glyph ID within the font. The next 8 bits are
|
||||
* the sub-font ID within a compound font. The high-
|
||||
* order 8 bits are client defined. The LayoutEngine
|
||||
* will never change or look at the client defined bits.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef le_uint32 LEGlyphID;
|
||||
|
||||
/**
|
||||
* Used to mask off the glyph ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_GLYPH_MASK 0x0000FFFF
|
||||
|
||||
/**
|
||||
* Used to shift the glyph ID part of an LEGlyphID
|
||||
* into the low-order bits.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_GLYPH_SHIFT 0
|
||||
|
||||
|
||||
/**
|
||||
* Used to mask off the sub-font ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_SUB_FONT_MASK 0x00FF0000
|
||||
|
||||
/**
|
||||
* Used to shift the sub-font ID part of an LEGlyphID
|
||||
* into the low-order bits.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_SUB_FONT_SHIFT 16
|
||||
|
||||
|
||||
/**
|
||||
* Used to mask off the client-defined part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_CLIENT_MASK 0xFF000000
|
||||
|
||||
/**
|
||||
* Used to shift the sub-font ID part of an LEGlyphID
|
||||
* into the low-order bits.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_CLIENT_SHIFT 24
|
||||
|
||||
|
||||
/**
|
||||
* A convenience macro to get the Glyph ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_GET_GLYPH(gid) ((gid & LE_GLYPH_MASK) >> LE_GLYPH_SHIFT)
|
||||
|
||||
/**
|
||||
* A convenience macro to get the sub-font ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_GET_SUB_FONT(gid) ((gid & LE_SUB_FONT_MASK) >> LE_SUB_FONT_SHIFT)
|
||||
|
||||
/**
|
||||
* A convenience macro to get the client-defined part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_GET_CLIENT(gid) ((gid & LE_CLIENT_MASK) >> LE_CLIENT_SHIFT)
|
||||
|
||||
|
||||
/**
|
||||
* A convenience macro to set the Glyph ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_SET_GLYPH(gid, glyph) ((gid & ~LE_GLYPH_MASK) | ((glyph << LE_GLYPH_SHIFT) & LE_GLYPH_MASK))
|
||||
|
||||
/**
|
||||
* A convenience macro to set the sub-font ID part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_SET_SUB_FONT(gid, font) ((gid & ~LE_SUB_FONT_MASK) | ((font << LE_SUB_FONT_SHIFT) & LE_SUB_FONT_MASK))
|
||||
|
||||
/**
|
||||
* A convenience macro to set the client-defined part of an LEGlyphID.
|
||||
*
|
||||
* @see LEGlyphID
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_SET_CLIENT(gid, client) ((gid & ~LE_CLIENT_MASK) | ((client << LE_CLIENT_SHIFT) & LE_CLIENT_MASK))
|
||||
|
||||
|
||||
/**
|
||||
* Used to represent 16-bit Unicode code points.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef UChar LEUnicode16;
|
||||
|
||||
/**
|
||||
* Used to represent 32-bit Unicode code points.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef UChar32 LEUnicode32;
|
||||
|
||||
#ifndef U_HIDE_DEPRECATED_API
|
||||
/**
|
||||
* Used to represent 16-bit Unicode code points.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef UChar LEUnicode;
|
||||
#endif /* U_HIDE_DEPRECATED_API */
|
||||
|
||||
/**
|
||||
* Used to hold a pair of (x, y) values which represent a point.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
struct LEPoint
|
||||
{
|
||||
/**
|
||||
* The x coordinate of the point.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
float fX;
|
||||
|
||||
/**
|
||||
* The y coordinate of the point.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
float fY;
|
||||
};
|
||||
|
||||
#ifndef __cplusplus
|
||||
/**
|
||||
* Used to hold a pair of (x, y) values which represent a point.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef struct LEPoint LEPoint;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
|
||||
/**
|
||||
* \def
|
||||
* @internal
|
||||
*/
|
||||
#ifndef LE_ASSERT_BAD_FONT
|
||||
#define LE_ASSERT_BAD_FONT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def LE_DEBUG_BAD_FONT
|
||||
* @internal
|
||||
*/
|
||||
#if LE_ASSERT_BAD_FONT
|
||||
#include <stdio.h>
|
||||
#define LE_DEBUG_BAD_FONT(x) fprintf(stderr,"%s:%d: BAD FONT: %s\n", __FILE__, __LINE__, (x));
|
||||
#else
|
||||
#define LE_DEBUG_BAD_FONT(x)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def LE_UINTPTR_MAX
|
||||
* Max value representable by a uintptr
|
||||
*/
|
||||
|
||||
#ifndef UINT32_MAX
|
||||
#define LE_UINT32_MAX 0xFFFFFFFFU
|
||||
#else
|
||||
#define LE_UINT32_MAX UINT32_MAX
|
||||
#endif
|
||||
|
||||
#ifndef UINTPTR_MAX
|
||||
#define LE_UINTPTR_MAX LE_UINT32_MAX
|
||||
#else
|
||||
#define LE_UINTPTR_MAX UINTPTR_MAX
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Range check for overflow
|
||||
*/
|
||||
#define LE_RANGE_CHECK(type, count, ptrfn) (( (LE_UINTPTR_MAX / sizeof(type)) < (size_t)count ) ? NULL : (ptrfn))
|
||||
/**
|
||||
* A convenience macro to get the length of an array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_ARRAY_SIZE(array) (sizeof array / sizeof array[0])
|
||||
|
||||
#ifdef LE_USE_CMEMORY
|
||||
/**
|
||||
* A convenience macro for copying an array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_ARRAY_COPY(dst, src, count) uprv_memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
|
||||
|
||||
/**
|
||||
* Allocate an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_NEW_ARRAY(type, count) (type *) LE_RANGE_CHECK(type,count,uprv_malloc((count) * sizeof(type)))
|
||||
|
||||
/**
|
||||
* Re-allocate an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_GROW_ARRAY(array, newSize) uprv_realloc((void *) (array), (newSize) * sizeof (array)[0])
|
||||
|
||||
/**
|
||||
* Free an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_DELETE_ARRAY(array) uprv_free((void *) (array))
|
||||
#else
|
||||
|
||||
/* Not using ICU memory - use C std lib versions */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* A convenience macro to get the length of an array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_ARRAY_SIZE(array) (sizeof array / sizeof array[0])
|
||||
|
||||
/**
|
||||
* A convenience macro for copying an array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_ARRAY_COPY(dst, src, count) memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
|
||||
|
||||
/**
|
||||
* Allocate an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_NEW_ARRAY(type, count) LE_RANGE_CHECK(type,count,(type *) malloc((count) * sizeof(type)))
|
||||
|
||||
/**
|
||||
* Re-allocate an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_GROW_ARRAY(array, newSize) realloc((void *) (array), (newSize) * sizeof (array)[0])
|
||||
|
||||
/**
|
||||
* Free an array of basic types. This is used to isolate the rest of
|
||||
* the LayoutEngine code from cmemory.h.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
#define LE_DELETE_ARRAY(array) free((void *) (array))
|
||||
|
||||
#endif
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* A macro to construct the four-letter tags used to
|
||||
* label TrueType tables, and for script, language and
|
||||
* feature tags in OpenType tables.
|
||||
*
|
||||
* WARNING: THIS MACRO WILL ONLY WORK CORRECTLY IF
|
||||
* THE ARGUMENT CHARACTERS ARE ASCII.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_MAKE_TAG(a, b, c, d) \
|
||||
(((le_uint32)(a) << 24) | \
|
||||
((le_uint32)(b) << 16) | \
|
||||
((le_uint32)(c) << 8) | \
|
||||
(le_uint32)(d))
|
||||
|
||||
/**
|
||||
* This enumeration defines constants for the standard
|
||||
* TrueType, OpenType and AAT table tags.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
enum LETableTags {
|
||||
LE_ACNT_TABLE_TAG = 0x61636E74UL, /**< 'acnt' */
|
||||
LE_AVAR_TABLE_TAG = 0x61766172UL, /**< 'avar' */
|
||||
LE_BASE_TABLE_TAG = 0x42415345UL, /**< 'BASE' */
|
||||
LE_BDAT_TABLE_TAG = 0x62646174UL, /**< 'bdat' */
|
||||
LE_BHED_TABLE_TAG = 0x62686564UL, /**< 'bhed' */
|
||||
LE_BLOC_TABLE_TAG = 0x626C6F63UL, /**< 'bloc' */
|
||||
LE_BSLN_TABLE_TAG = 0x62736C6EUL, /**< 'bsln' */
|
||||
LE_CFF__TABLE_TAG = 0x43464620UL, /**< 'CFF ' */
|
||||
LE_CMAP_TABLE_TAG = 0x636D6170UL, /**< 'cmap' */
|
||||
LE_CVAR_TABLE_TAG = 0x63766172UL, /**< 'cvar' */
|
||||
LE_CVT__TABLE_TAG = 0x63767420UL, /**< 'cvt ' */
|
||||
LE_DSIG_TABLE_TAG = 0x44534947UL, /**< 'DSIG' */
|
||||
LE_EBDT_TABLE_TAG = 0x45424454UL, /**< 'EBDT' */
|
||||
LE_EBLC_TABLE_TAG = 0x45424C43UL, /**< 'EBLC' */
|
||||
LE_EBSC_TABLE_TAG = 0x45425343UL, /**< 'EBSC' */
|
||||
LE_FDSC_TABLE_TAG = 0x66647363UL, /**< 'fdsc' */
|
||||
LE_FEAT_TABLE_TAG = 0x66656174UL, /**< 'feat' */
|
||||
LE_FMTX_TABLE_TAG = 0x666D7478UL, /**< 'fmtx' */
|
||||
LE_FPGM_TABLE_TAG = 0x6670676DUL, /**< 'fpgm' */
|
||||
LE_FVAR_TABLE_TAG = 0x66766172UL, /**< 'fvar' */
|
||||
LE_GASP_TABLE_TAG = 0x67617370UL, /**< 'gasp' */
|
||||
LE_GDEF_TABLE_TAG = 0x47444546UL, /**< 'GDEF' */
|
||||
LE_GLYF_TABLE_TAG = 0x676C7966UL, /**< 'glyf' */
|
||||
LE_GPOS_TABLE_TAG = 0x47504F53UL, /**< 'GPOS' */
|
||||
LE_GSUB_TABLE_TAG = 0x47535542UL, /**< 'GSUB' */
|
||||
LE_GVAR_TABLE_TAG = 0x67766172UL, /**< 'gvar' */
|
||||
LE_HDMX_TABLE_TAG = 0x68646D78UL, /**< 'hdmx' */
|
||||
LE_HEAD_TABLE_TAG = 0x68656164UL, /**< 'head' */
|
||||
LE_HHEA_TABLE_TAG = 0x68686561UL, /**< 'hhea' */
|
||||
LE_HMTX_TABLE_TAG = 0x686D7478UL, /**< 'hmtx' */
|
||||
LE_HSTY_TABLE_TAG = 0x68737479UL, /**< 'hsty' */
|
||||
LE_JUST_TABLE_TAG = 0x6A757374UL, /**< 'just' */
|
||||
LE_JSTF_TABLE_TAG = 0x4A535446UL, /**< 'JSTF' */
|
||||
LE_KERN_TABLE_TAG = 0x6B65726EUL, /**< 'kern' */
|
||||
LE_LCAR_TABLE_TAG = 0x6C636172UL, /**< 'lcar' */
|
||||
LE_LOCA_TABLE_TAG = 0x6C6F6361UL, /**< 'loca' */
|
||||
LE_LTSH_TABLE_TAG = 0x4C545348UL, /**< 'LTSH' */
|
||||
LE_MAXP_TABLE_TAG = 0x6D617870UL, /**< 'maxp' */
|
||||
LE_MORT_TABLE_TAG = 0x6D6F7274UL, /**< 'mort' */
|
||||
LE_MORX_TABLE_TAG = 0x6D6F7278UL, /**< 'morx' */
|
||||
LE_NAME_TABLE_TAG = 0x6E616D65UL, /**< 'name' */
|
||||
LE_OPBD_TABLE_TAG = 0x6F706264UL, /**< 'opbd' */
|
||||
LE_OS_2_TABLE_TAG = 0x4F532F32UL, /**< 'OS/2' */
|
||||
LE_PCLT_TABLE_TAG = 0x50434C54UL, /**< 'PCLT' */
|
||||
LE_POST_TABLE_TAG = 0x706F7374UL, /**< 'post' */
|
||||
LE_PREP_TABLE_TAG = 0x70726570UL, /**< 'prep' */
|
||||
LE_PROP_TABLE_TAG = 0x70726F70UL, /**< 'prop' */
|
||||
LE_TRAK_TABLE_TAG = 0x7472616BUL, /**< 'trak' */
|
||||
LE_VDMX_TABLE_TAG = 0x56444D58UL, /**< 'VDMX' */
|
||||
LE_VHEA_TABLE_TAG = 0x76686561UL, /**< 'vhea' */
|
||||
LE_VMTX_TABLE_TAG = 0x766D7478UL, /**< 'vmtx' */
|
||||
LE_VORG_TABLE_TAG = 0x564F5247UL, /**< 'VORG' */
|
||||
LE_ZAPF_TABLE_TAG = 0x5A617066UL /**< 'Zapf' */
|
||||
};
|
||||
|
||||
/**
|
||||
* This enumeration defines constants for all
|
||||
* the common OpenType feature tags.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
enum LEFeatureTags {
|
||||
LE_AALT_FEATURE_TAG = 0x61616C74UL, /**< 'aalt' */
|
||||
LE_ABVF_FEATURE_TAG = 0x61627666UL, /**< 'abvf' */
|
||||
LE_ABVM_FEATURE_TAG = 0x6162766DUL, /**< 'abvm' */
|
||||
LE_ABVS_FEATURE_TAG = 0x61627673UL, /**< 'abvs' */
|
||||
LE_AFRC_FEATURE_TAG = 0x61667263UL, /**< 'afrc' */
|
||||
LE_AKHN_FEATURE_TAG = 0x616B686EUL, /**< 'akhn' */
|
||||
LE_BLWF_FEATURE_TAG = 0x626C7766UL, /**< 'blwf' */
|
||||
LE_BLWM_FEATURE_TAG = 0x626C776DUL, /**< 'blwm' */
|
||||
LE_BLWS_FEATURE_TAG = 0x626C7773UL, /**< 'blws' */
|
||||
LE_CALT_FEATURE_TAG = 0x63616C74UL, /**< 'calt' */
|
||||
LE_CASE_FEATURE_TAG = 0x63617365UL, /**< 'case' */
|
||||
LE_CCMP_FEATURE_TAG = 0x63636D70UL, /**< 'ccmp' */
|
||||
LE_CJCT_FEATURE_TAG = 0x636A6374UL, /**< 'cjct' */
|
||||
LE_CLIG_FEATURE_TAG = 0x636C6967UL, /**< 'clig' */
|
||||
LE_CPSP_FEATURE_TAG = 0x63707370UL, /**< 'cpsp' */
|
||||
LE_CSWH_FEATURE_TAG = 0x63737768UL, /**< 'cswh' */
|
||||
LE_CURS_FEATURE_TAG = 0x63757273UL, /**< 'curs' */
|
||||
LE_C2SC_FEATURE_TAG = 0x63327363UL, /**< 'c2sc' */
|
||||
LE_C2PC_FEATURE_TAG = 0x63327063UL, /**< 'c2pc' */
|
||||
LE_DIST_FEATURE_TAG = 0x64697374UL, /**< 'dist' */
|
||||
LE_DLIG_FEATURE_TAG = 0x646C6967UL, /**< 'dlig' */
|
||||
LE_DNOM_FEATURE_TAG = 0x646E6F6DUL, /**< 'dnom' */
|
||||
LE_EXPT_FEATURE_TAG = 0x65787074UL, /**< 'expt' */
|
||||
LE_FALT_FEATURE_TAG = 0x66616C74UL, /**< 'falt' */
|
||||
LE_FIN2_FEATURE_TAG = 0x66696E32UL, /**< 'fin2' */
|
||||
LE_FIN3_FEATURE_TAG = 0x66696E33UL, /**< 'fin3' */
|
||||
LE_FINA_FEATURE_TAG = 0x66696E61UL, /**< 'fina' */
|
||||
LE_FRAC_FEATURE_TAG = 0x66726163UL, /**< 'frac' */
|
||||
LE_FWID_FEATURE_TAG = 0x66776964UL, /**< 'fwid' */
|
||||
LE_HALF_FEATURE_TAG = 0x68616C66UL, /**< 'half' */
|
||||
LE_HALN_FEATURE_TAG = 0x68616C6EUL, /**< 'haln' */
|
||||
LE_HALT_FEATURE_TAG = 0x68616C74UL, /**< 'halt' */
|
||||
LE_HIST_FEATURE_TAG = 0x68697374UL, /**< 'hist' */
|
||||
LE_HKNA_FEATURE_TAG = 0x686B6E61UL, /**< 'hkna' */
|
||||
LE_HLIG_FEATURE_TAG = 0x686C6967UL, /**< 'hlig' */
|
||||
LE_HNGL_FEATURE_TAG = 0x686E676CUL, /**< 'hngl' */
|
||||
LE_HWID_FEATURE_TAG = 0x68776964UL, /**< 'hwid' */
|
||||
LE_INIT_FEATURE_TAG = 0x696E6974UL, /**< 'init' */
|
||||
LE_ISOL_FEATURE_TAG = 0x69736F6CUL, /**< 'isol' */
|
||||
LE_ITAL_FEATURE_TAG = 0x6974616CUL, /**< 'ital' */
|
||||
LE_JALT_FEATURE_TAG = 0x6A616C74UL, /**< 'jalt' */
|
||||
LE_JP78_FEATURE_TAG = 0x6A703738UL, /**< 'jp78' */
|
||||
LE_JP83_FEATURE_TAG = 0x6A703833UL, /**< 'jp83' */
|
||||
LE_JP90_FEATURE_TAG = 0x6A703930UL, /**< 'jp90' */
|
||||
LE_KERN_FEATURE_TAG = 0x6B65726EUL, /**< 'kern' */
|
||||
LE_LFBD_FEATURE_TAG = 0x6C666264UL, /**< 'lfbd' */
|
||||
LE_LIGA_FEATURE_TAG = 0x6C696761UL, /**< 'liga' */
|
||||
LE_LJMO_FEATURE_TAG = 0x6C6A6D6FUL, /**< 'ljmo' */
|
||||
LE_LNUM_FEATURE_TAG = 0x6C6E756DUL, /**< 'lnum' */
|
||||
LE_LOCL_FEATURE_TAG = 0x6C6F636CUL, /**< 'locl' */
|
||||
LE_MARK_FEATURE_TAG = 0x6D61726BUL, /**< 'mark' */
|
||||
LE_MED2_FEATURE_TAG = 0x6D656432UL, /**< 'med2' */
|
||||
LE_MEDI_FEATURE_TAG = 0x6D656469UL, /**< 'medi' */
|
||||
LE_MGRK_FEATURE_TAG = 0x6D67726BUL, /**< 'mgrk' */
|
||||
LE_MKMK_FEATURE_TAG = 0x6D6B6D6BUL, /**< 'mkmk' */
|
||||
LE_MSET_FEATURE_TAG = 0x6D736574UL, /**< 'mset' */
|
||||
LE_NALT_FEATURE_TAG = 0x6E616C74UL, /**< 'nalt' */
|
||||
LE_NLCK_FEATURE_TAG = 0x6E6C636BUL, /**< 'nlck' */
|
||||
LE_NUKT_FEATURE_TAG = 0x6E756B74UL, /**< 'nukt' */
|
||||
LE_NUMR_FEATURE_TAG = 0x6E756D72UL, /**< 'numr' */
|
||||
LE_ONUM_FEATURE_TAG = 0x6F6E756DUL, /**< 'onum' */
|
||||
LE_OPBD_FEATURE_TAG = 0x6F706264UL, /**< 'opbd' */
|
||||
LE_ORDN_FEATURE_TAG = 0x6F72646EUL, /**< 'ordn' */
|
||||
LE_ORNM_FEATURE_TAG = 0x6F726E6DUL, /**< 'ornm' */
|
||||
LE_PALT_FEATURE_TAG = 0x70616C74UL, /**< 'palt' */
|
||||
LE_PCAP_FEATURE_TAG = 0x70636170UL, /**< 'pcap' */
|
||||
LE_PNUM_FEATURE_TAG = 0x706E756DUL, /**< 'pnum' */
|
||||
LE_PREF_FEATURE_TAG = 0x70726566UL, /**< 'pref' */
|
||||
LE_PRES_FEATURE_TAG = 0x70726573UL, /**< 'pres' */
|
||||
LE_PSTF_FEATURE_TAG = 0x70737466UL, /**< 'pstf' */
|
||||
LE_PSTS_FEATURE_TAG = 0x70737473UL, /**< 'psts' */
|
||||
LE_PWID_FEATURE_TAG = 0x70776964UL, /**< 'pwid' */
|
||||
LE_QWID_FEATURE_TAG = 0x71776964UL, /**< 'qwid' */
|
||||
LE_RAND_FEATURE_TAG = 0x72616E64UL, /**< 'rand' */
|
||||
LE_RLIG_FEATURE_TAG = 0x726C6967UL, /**< 'rlig' */
|
||||
LE_RPHF_FEATURE_TAG = 0x72706866UL, /**< 'rphf' */
|
||||
LE_RKRF_FEATURE_TAG = 0x726B7266UL, /**< 'rkrf' */
|
||||
LE_RTBD_FEATURE_TAG = 0x72746264UL, /**< 'rtbd' */
|
||||
LE_RTLA_FEATURE_TAG = 0x72746C61UL, /**< 'rtla' */
|
||||
LE_RUBY_FEATURE_TAG = 0x72756279UL, /**< 'ruby' */
|
||||
LE_SALT_FEATURE_TAG = 0x73616C74UL, /**< 'salt' */
|
||||
LE_SINF_FEATURE_TAG = 0x73696E66UL, /**< 'sinf' */
|
||||
LE_SIZE_FEATURE_TAG = 0x73697A65UL, /**< 'size' */
|
||||
LE_SMCP_FEATURE_TAG = 0x736D6370UL, /**< 'smcp' */
|
||||
LE_SMPL_FEATURE_TAG = 0x736D706CUL, /**< 'smpl' */
|
||||
LE_SS01_FEATURE_TAG = 0x73733031UL, /**< 'ss01' */
|
||||
LE_SS02_FEATURE_TAG = 0x73733032UL, /**< 'ss02' */
|
||||
LE_SS03_FEATURE_TAG = 0x73733033UL, /**< 'ss03' */
|
||||
LE_SS04_FEATURE_TAG = 0x73733034UL, /**< 'ss04' */
|
||||
LE_SS05_FEATURE_TAG = 0x73733035UL, /**< 'ss05' */
|
||||
LE_SS06_FEATURE_TAG = 0x73733036UL, /**< 'ss06' */
|
||||
LE_SS07_FEATURE_TAG = 0x73733037UL, /**< 'ss07' */
|
||||
LE_SS08_FEATURE_TAG = 0x73733038UL, /**< 'ss08' */
|
||||
LE_SS09_FEATURE_TAG = 0x73733039UL, /**< 'ss09' */
|
||||
LE_SS10_FEATURE_TAG = 0x73733130UL, /**< 'ss10' */
|
||||
LE_SS11_FEATURE_TAG = 0x73733131UL, /**< 'ss11' */
|
||||
LE_SS12_FEATURE_TAG = 0x73733132UL, /**< 'ss12' */
|
||||
LE_SS13_FEATURE_TAG = 0x73733133UL, /**< 'ss13' */
|
||||
LE_SS14_FEATURE_TAG = 0x73733134UL, /**< 'ss14' */
|
||||
LE_SS15_FEATURE_TAG = 0x73733135UL, /**< 'ss15' */
|
||||
LE_SS16_FEATURE_TAG = 0x73733136UL, /**< 'ss16' */
|
||||
LE_SS17_FEATURE_TAG = 0x73733137UL, /**< 'ss17' */
|
||||
LE_SS18_FEATURE_TAG = 0x73733138UL, /**< 'ss18' */
|
||||
LE_SS19_FEATURE_TAG = 0x73733139UL, /**< 'ss19' */
|
||||
LE_SS20_FEATURE_TAG = 0x73733230UL, /**< 'ss20' */
|
||||
LE_SUBS_FEATURE_TAG = 0x73756273UL, /**< 'subs' */
|
||||
LE_SUPS_FEATURE_TAG = 0x73757073UL, /**< 'sups' */
|
||||
LE_SWSH_FEATURE_TAG = 0x73777368UL, /**< 'swsh' */
|
||||
LE_TITL_FEATURE_TAG = 0x7469746CUL, /**< 'titl' */
|
||||
LE_TJMO_FEATURE_TAG = 0x746A6D6FUL, /**< 'tjmo' */
|
||||
LE_TNAM_FEATURE_TAG = 0x746E616DUL, /**< 'tnam' */
|
||||
LE_TNUM_FEATURE_TAG = 0x746E756DUL, /**< 'tnum' */
|
||||
LE_TRAD_FEATURE_TAG = 0x74726164UL, /**< 'trad' */
|
||||
LE_TWID_FEATURE_TAG = 0x74776964UL, /**< 'twid' */
|
||||
LE_UNIC_FEATURE_TAG = 0x756E6963UL, /**< 'unic' */
|
||||
LE_VALT_FEATURE_TAG = 0x76616C74UL, /**< 'valt' */
|
||||
LE_VATU_FEATURE_TAG = 0x76617475UL, /**< 'vatu' */
|
||||
LE_VERT_FEATURE_TAG = 0x76657274UL, /**< 'vert' */
|
||||
LE_VHAL_FEATURE_TAG = 0x7668616CUL, /**< 'vhal' */
|
||||
LE_VJMO_FEATURE_TAG = 0x766A6D6FUL, /**< 'vjmo' */
|
||||
LE_VKNA_FEATURE_TAG = 0x766B6E61UL, /**< 'vkna' */
|
||||
LE_VKRN_FEATURE_TAG = 0x766B726EUL, /**< 'vkrn' */
|
||||
LE_VPAL_FEATURE_TAG = 0x7670616CUL, /**< 'vpal' */
|
||||
LE_VRT2_FEATURE_TAG = 0x76727432UL, /**< 'vrt2' */
|
||||
LE_ZERO_FEATURE_TAG = 0x7A65726FUL /**< 'zero' */
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
enum LEFeatureENUMs {
|
||||
LE_Kerning_FEATURE_ENUM = 0, /**< Requests Kerning. Formerly LayoutEngine::kTypoFlagKern */
|
||||
LE_Ligatures_FEATURE_ENUM = 1, /**< Requests Ligatures. Formerly LayoutEngine::kTypoFlagLiga */
|
||||
LE_CLIG_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_DLIG_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_HLIG_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_LIGA_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_RLIG_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SMCP_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_FRAC_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_AFRC_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_ZERO_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SWSH_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_CSWH_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SALT_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_NALT_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_RUBY_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS01_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS02_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS03_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS04_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS05_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS06_FEATURE_ENUM, /**< Feature specific enum */
|
||||
LE_SS07_FEATURE_ENUM, /**< Feature specific enum */
|
||||
|
||||
LE_CHAR_FILTER_FEATURE_ENUM = 31, /**< Apply CharSubstitutionFilter */
|
||||
LE_FEATURE_ENUM_MAX = LE_CHAR_FILTER_FEATURE_ENUM
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Flags for typographic features.
|
||||
* @internal
|
||||
* @{
|
||||
*/
|
||||
#define LE_Kerning_FEATURE_FLAG (1 << LE_Kerning_FEATURE_ENUM)
|
||||
#define LE_Ligatures_FEATURE_FLAG (1 << LE_Ligatures_FEATURE_ENUM)
|
||||
#define LE_CLIG_FEATURE_FLAG (1 << LE_CLIG_FEATURE_ENUM)
|
||||
#define LE_DLIG_FEATURE_FLAG (1 << LE_DLIG_FEATURE_ENUM)
|
||||
#define LE_HLIG_FEATURE_FLAG (1 << LE_HLIG_FEATURE_ENUM)
|
||||
#define LE_LIGA_FEATURE_FLAG (1 << LE_LIGA_FEATURE_ENUM)
|
||||
#define LE_RLIG_FEATURE_FLAG (1 << LE_RLIG_FEATURE_ENUM)
|
||||
#define LE_SMCP_FEATURE_FLAG (1 << LE_SMCP_FEATURE_ENUM)
|
||||
#define LE_FRAC_FEATURE_FLAG (1 << LE_FRAC_FEATURE_ENUM)
|
||||
#define LE_AFRC_FEATURE_FLAG (1 << LE_AFRC_FEATURE_ENUM)
|
||||
#define LE_ZERO_FEATURE_FLAG (1 << LE_ZERO_FEATURE_ENUM)
|
||||
#define LE_SWSH_FEATURE_FLAG (1 << LE_SWSH_FEATURE_ENUM)
|
||||
#define LE_CSWH_FEATURE_FLAG (1 << LE_CSWH_FEATURE_ENUM)
|
||||
#define LE_SALT_FEATURE_FLAG (1 << LE_SALT_FEATURE_ENUM)
|
||||
#define LE_NALT_FEATURE_FLAG (1 << LE_NALT_FEATURE_ENUM)
|
||||
#define LE_RUBY_FEATURE_FLAG (1 << LE_RUBY_FEATURE_ENUM)
|
||||
#define LE_SS01_FEATURE_FLAG (1 << LE_SS01_FEATURE_ENUM)
|
||||
#define LE_SS02_FEATURE_FLAG (1 << LE_SS02_FEATURE_ENUM)
|
||||
#define LE_SS03_FEATURE_FLAG (1 << LE_SS03_FEATURE_ENUM)
|
||||
#define LE_SS04_FEATURE_FLAG (1 << LE_SS04_FEATURE_ENUM)
|
||||
#define LE_SS05_FEATURE_FLAG (1 << LE_SS05_FEATURE_ENUM)
|
||||
#define LE_SS06_FEATURE_FLAG (1 << LE_SS06_FEATURE_ENUM)
|
||||
#define LE_SS07_FEATURE_FLAG (1 << LE_SS07_FEATURE_ENUM)
|
||||
|
||||
#define LE_CHAR_FILTER_FEATURE_FLAG (1 << LE_CHAR_FILTER_FEATURE_ENUM)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define LE_DEFAULT_FEATURE_FLAG (LE_Kerning_FEATURE_FLAG | LE_Ligatures_FEATURE_FLAG) /**< default features */
|
||||
|
||||
/**
|
||||
* Error codes returned by the LayoutEngine.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
enum LEErrorCode {
|
||||
/* informational */
|
||||
LE_NO_SUBFONT_WARNING = U_USING_DEFAULT_WARNING, /**< The font does not contain subfonts. */
|
||||
|
||||
/* success */
|
||||
LE_NO_ERROR = U_ZERO_ERROR, /**< No error, no warning. */
|
||||
|
||||
/* failures */
|
||||
LE_ILLEGAL_ARGUMENT_ERROR = U_ILLEGAL_ARGUMENT_ERROR, /**< An illegal argument was detected. */
|
||||
LE_MEMORY_ALLOCATION_ERROR = U_MEMORY_ALLOCATION_ERROR, /**< Memory allocation error. */
|
||||
LE_INDEX_OUT_OF_BOUNDS_ERROR = U_INDEX_OUTOFBOUNDS_ERROR, /**< Trying to access an index that is out of bounds. */
|
||||
LE_NO_LAYOUT_ERROR = U_UNSUPPORTED_ERROR, /**< You must call layoutChars() first. */
|
||||
LE_INTERNAL_ERROR = U_INTERNAL_PROGRAM_ERROR, /**< An internal error was encountered. */
|
||||
LE_FONT_FILE_NOT_FOUND_ERROR = U_FILE_ACCESS_ERROR, /**< The requested font file cannot be opened. */
|
||||
LE_MISSING_FONT_TABLE_ERROR = U_MISSING_RESOURCE_ERROR /**< The requested font table does not exist. */
|
||||
};
|
||||
|
||||
#ifndef __cplusplus
|
||||
/**
|
||||
* Error codes returned by the LayoutEngine.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
typedef enum LEErrorCode LEErrorCode;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A convenience macro to test for the success of a LayoutEngine call.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_SUCCESS(code) (U_SUCCESS((UErrorCode)code))
|
||||
|
||||
/**
|
||||
* A convenience macro to test for the failure of a LayoutEngine call.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
#define LE_FAILURE(code) (U_FAILURE((UErrorCode)code))
|
||||
|
||||
|
||||
#endif
|
||||
@ -1,518 +0,0 @@
|
||||
/*
|
||||
* (C) Copyright IBM Corp. and others 1998-2014 - All Rights Reserved
|
||||
*/
|
||||
|
||||
#ifndef __LAYOUTENGINE_H
|
||||
#define __LAYOUTENGINE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: DEPRECATED: Virtual base class for complex text layout.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class LEFontInstance;
|
||||
class LEGlyphFilter;
|
||||
class LEGlyphStorage;
|
||||
|
||||
/**
|
||||
* NOTE: This class is deprecated, please instead use HarfBuzz.
|
||||
* See: http://www.freedesktop.org/wiki/Software/HarfBuzz/
|
||||
* and http://userguide.icu-project.org/layoutengine
|
||||
*
|
||||
* This is a virtual base class used to do complex text layout. The text must all
|
||||
* be in a single font, script, and language. An instance of a LayoutEngine can be
|
||||
* created by calling the layoutEngineFactory method. Fonts are identified by
|
||||
* instances of the LEFontInstance class. Script and language codes are identified
|
||||
* by integer codes, which are defined in ScriptAndLanuageTags.h.
|
||||
*
|
||||
* Note that this class is not public API. It is declared public so that it can be
|
||||
* exported from the library that it is a part of.
|
||||
*
|
||||
* The input to the layout process is an array of characters in logical order,
|
||||
* and a starting X, Y position for the text. The output is an array of glyph indices,
|
||||
* an array of character indices for the glyphs, and an array of glyph positions.
|
||||
* These arrays are protected members of LayoutEngine which can be retreived by a
|
||||
* public method. The reset method can be called to free these arrays so that the
|
||||
* LayoutEngine can be reused.
|
||||
*
|
||||
* The layout process is done in three steps. There is a protected virtual method
|
||||
* for each step. These methods have a default implementation which only does
|
||||
* character to glyph mapping and default positioning using the glyph's advance
|
||||
* widths. Subclasses can override these methods for more advanced layout.
|
||||
* There is a public method which invokes the steps in the correct order.
|
||||
*
|
||||
* The steps are:
|
||||
*
|
||||
* 1) Glyph processing - character to glyph mapping and any other glyph processing
|
||||
* such as ligature substitution and contextual forms.
|
||||
*
|
||||
* 2) Glyph positioning - position the glyphs based on their advance widths.
|
||||
*
|
||||
* 3) Glyph position adjustments - adjustment of glyph positions for kerning,
|
||||
* accent placement, etc.
|
||||
*
|
||||
* NOTE: in all methods below, output parameters are references to pointers so
|
||||
* the method can allocate and free the storage as needed. All storage allocated
|
||||
* in this way is owned by the object which created it, and will be freed when it
|
||||
* is no longer needed, or when the object's destructor is invoked.
|
||||
*
|
||||
* @see LEFontInstance
|
||||
* @see ScriptAndLanguageTags.h
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
* Instead, please use HarfBuzz.
|
||||
* see http://www.freedesktop.org/wiki/Software/HarfBuzz/
|
||||
* and http://userguide.icu-project.org/layoutengine
|
||||
*/
|
||||
class U_LAYOUT_API LayoutEngine : public UObject {
|
||||
public:
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/** @internal Flag to request kerning. Use LE_Kerning_FEATURE_FLAG instead. */
|
||||
static const le_int32 kTypoFlagKern;
|
||||
/** @internal Flag to request ligatures. Use LE_Ligatures_FEATURE_FLAG instead. */
|
||||
static const le_int32 kTypoFlagLiga;
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The object which holds the glyph storage
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LEGlyphStorage *fGlyphStorage;
|
||||
|
||||
/**
|
||||
* The font instance for the text font.
|
||||
*
|
||||
* @see LEFontInstance
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const LEFontInstance *fFontInstance;
|
||||
|
||||
/**
|
||||
* The script code for the text
|
||||
*
|
||||
* @see ScriptAndLanguageTags.h for script codes.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fScriptCode;
|
||||
|
||||
/**
|
||||
* The langauge code for the text
|
||||
*
|
||||
* @see ScriptAndLanguageTags.h for language codes.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fLanguageCode;
|
||||
|
||||
/**
|
||||
* The typographic control flags
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_int32 fTypoFlags;
|
||||
|
||||
/**
|
||||
* <code>TRUE</code> if <code>mapCharsToGlyphs</code> should replace ZWJ / ZWNJ with a glyph
|
||||
* with no contours.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
le_bool fFilterZeroWidth;
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* This constructs an instance for a given font, script and language. Subclass constructors
|
||||
* must call this constructor.
|
||||
*
|
||||
* @param fontInstance - the font for the text
|
||||
* @param scriptCode - the script for the text
|
||||
* @param languageCode - the language for the text
|
||||
* @param typoFlags - the typographic control flags for the text (a bitfield). Use kTypoFlagKern
|
||||
* if kerning is desired, kTypoFlagLiga if ligature formation is desired. Others are reserved.
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @see LEFontInstance
|
||||
* @see ScriptAndLanguageTags.h
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LayoutEngine(const LEFontInstance *fontInstance,
|
||||
le_int32 scriptCode,
|
||||
le_int32 languageCode,
|
||||
le_int32 typoFlags,
|
||||
LEErrorCode &success);
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
// Do not enclose the protected default constructor with #ifndef U_HIDE_INTERNAL_API
|
||||
// or else the compiler will create a public default constructor.
|
||||
/**
|
||||
* This overrides the default no argument constructor to make it
|
||||
* difficult for clients to call it. Clients are expected to call
|
||||
* layoutEngineFactory.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
LayoutEngine();
|
||||
|
||||
/**
|
||||
* This method does any required pre-processing to the input characters. It
|
||||
* may generate output characters that differ from the input charcters due to
|
||||
* insertions, deletions, or reorderings. In such cases, it will also generate an
|
||||
* output character index array reflecting these changes.
|
||||
*
|
||||
* Subclasses must override this method.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param chars - the input character context
|
||||
* @param offset - the index of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param max - the number of characters in the input context
|
||||
* @param rightToLeft - TRUE if the characters are in a right to left directional run
|
||||
* @param outChars - the output character array, if different from the input
|
||||
* @param glyphStorage - the object that holds the per-glyph storage. The character index array may be set.
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @return the output character count (input character count if no change)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
|
||||
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method does the glyph processing. It converts an array of characters
|
||||
* into an array of glyph indices and character indices. The characters to be
|
||||
* processed are passed in a surrounding context. The context is specified as
|
||||
* a starting address and a maximum character count. An offset and a count are
|
||||
* used to specify the characters to be processed.
|
||||
*
|
||||
* The default implementation of this method only does character to glyph mapping.
|
||||
* Subclasses needing more elaborate glyph processing must override this method.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param chars - the character context
|
||||
* @param offset - the offset of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param max - the number of characters in the context.
|
||||
* @param rightToLeft - TRUE if the text is in a right to left directional run
|
||||
* @param glyphStorage - the object which holds the per-glyph storage. The glyph and char indices arrays
|
||||
* will be set.
|
||||
*
|
||||
* Output parameters:
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @return the number of glyphs in the glyph index array
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method does basic glyph positioning. The default implementation positions
|
||||
* the glyphs based on their advance widths. This is sufficient for most uses. It
|
||||
* is not expected that many subclasses will override this method.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param glyphStorage - the object which holds the per-glyph storage. The glyph position array will be set.
|
||||
* @param x - the starting X position
|
||||
* @param y - the starting Y position
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual void positionGlyphs(LEGlyphStorage &glyphStorage, float x, float y, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method does positioning adjustments like accent positioning and
|
||||
* kerning. The default implementation does nothing. Subclasses needing
|
||||
* position adjustments must override this method.
|
||||
*
|
||||
* Note that this method has both characters and glyphs as input so that
|
||||
* it can use the character codes to determine glyph types if that information
|
||||
* isn't directly available. (e.g. Some Arabic OpenType fonts don't have a GDEF
|
||||
* table)
|
||||
*
|
||||
* @param chars - the input character context
|
||||
* @param offset - the offset of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
|
||||
* @param glyphStorage - the object which holds the per-glyph storage. The glyph positions will be
|
||||
* adjusted as needed.
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method gets a table from the font associated with
|
||||
* the text. The default implementation gets the table from
|
||||
* the font instance. Subclasses which need to get the tables
|
||||
* some other way must override this method.
|
||||
*
|
||||
* @param tableTag - the four byte table tag.
|
||||
* @param length - length to use
|
||||
*
|
||||
* @return the address of the table.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual const void *getFontTable(LETag tableTag, size_t &length) const;
|
||||
|
||||
/**
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual const void *getFontTable(LETag tableTag) const { size_t ignored; return getFontTable(tableTag, ignored); }
|
||||
|
||||
/**
|
||||
* This method does character to glyph mapping. The default implementation
|
||||
* uses the font instance to do the mapping. It will allocate the glyph and
|
||||
* character index arrays if they're not already allocated. If it allocates the
|
||||
* character index array, it will fill it it.
|
||||
*
|
||||
* This method supports right to left
|
||||
* text with the ability to store the glyphs in reverse order, and by supporting
|
||||
* character mirroring, which will replace a character which has a left and right
|
||||
* form, such as parens, with the opposite form before mapping it to a glyph index.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param chars - the input character context
|
||||
* @param offset - the offset of the first character to be mapped
|
||||
* @param count - the number of characters to be mapped
|
||||
* @param reverse - if <code>TRUE</code>, the output will be in reverse order
|
||||
* @param mirror - if <code>TRUE</code>, do character mirroring
|
||||
* @param glyphStorage - the object which holds the per-glyph storage. The glyph and char
|
||||
* indices arrays will be filled in.
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @see LEFontInstance
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror, LEGlyphStorage &glyphStorage, LEErrorCode &success);
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* This is a convenience method that forces the advance width of mark
|
||||
* glyphs to be zero, which is required for proper selection and highlighting.
|
||||
*
|
||||
* @param glyphStorage - the object containing the per-glyph storage. The positions array will be modified.
|
||||
* @param markFilter - used to identify mark glyphs
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @see LEGlyphFilter
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static void adjustMarkGlyphs(LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success);
|
||||
|
||||
|
||||
/**
|
||||
* This is a convenience method that forces the advance width of mark
|
||||
* glyphs to be zero, which is required for proper selection and highlighting.
|
||||
* This method uses the input characters to identify marks. This is required in
|
||||
* cases where the font does not contain enough information to identify them based
|
||||
* on the glyph IDs.
|
||||
*
|
||||
* @param chars - the array of input characters
|
||||
* @param charCount - the number of input characers
|
||||
* @param glyphStorage - the object containing the per-glyph storage. The positions array will be modified.
|
||||
* @param reverse - <code>TRUE</code> if the glyph array has been reordered
|
||||
* @param markFilter - used to identify mark glyphs
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @see LEGlyphFilter
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 charCount, le_bool reverse, LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success);
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
public:
|
||||
/**
|
||||
* The destructor. It will free any storage allocated for the
|
||||
* glyph, character index and position arrays by calling the reset
|
||||
* method. It is declared virtual so that it will be invoked by the
|
||||
* subclass destructors.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual ~LayoutEngine();
|
||||
|
||||
/**
|
||||
* This method will invoke the layout steps in their correct order by calling
|
||||
* the computeGlyphs, positionGlyphs and adjustGlyphPosition methods. It will
|
||||
* compute the glyph, character index and position arrays.
|
||||
*
|
||||
* @param chars - the input character context
|
||||
* @param offset - the offset of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param max - the number of characters in the input context
|
||||
* @param rightToLeft - TRUE if the characers are in a right to left directional run
|
||||
* @param x - the initial X position
|
||||
* @param y - the initial Y position
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* Note: The glyph, character index and position array can be accessed
|
||||
* using the getter methods below.
|
||||
*
|
||||
* Note: If you call this method more than once, you must call the reset()
|
||||
* method first to free the glyph, character index and position arrays
|
||||
* allocated by the previous call.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual le_int32 layoutChars(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, float x, float y, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* This method returns the number of glyphs in the glyph array. Note
|
||||
* that the number of glyphs will be greater than or equal to the number
|
||||
* of characters used to create the LayoutEngine.
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
le_int32 getGlyphCount() const;
|
||||
|
||||
/**
|
||||
* This method copies the glyph array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold all
|
||||
* the glyphs.
|
||||
*
|
||||
* @param glyphs - the destiniation glyph array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the glyph array into a caller supplied array,
|
||||
* ORing in extra bits. (This functionality is needed by the JDK,
|
||||
* which uses 32 bits pre glyph idex, with the high 16 bits encoding
|
||||
* the composite font slot number)
|
||||
*
|
||||
* @param glyphs - the destination (32 bit) glyph array
|
||||
* @param extraBits - this value will be ORed with each glyph index
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param indexBase - an offset which will be added to each index
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method copies the position array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold an
|
||||
* X and Y position for each glyph, plus an extra X and Y for the
|
||||
* advance of the last glyph.
|
||||
*
|
||||
* @param positions - the destiniation position array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getGlyphPositions(float positions[], LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method returns the X and Y position of the glyph at
|
||||
* the given index.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param glyphIndex - the index of the glyph
|
||||
*
|
||||
* Output parameters:
|
||||
* @param x - the glyph's X position
|
||||
* @param y - the glyph's Y position
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const;
|
||||
|
||||
/**
|
||||
* This method frees the glyph, character index and position arrays
|
||||
* so that the LayoutEngine can be reused to layout a different
|
||||
* characer array. (This method is also called by the destructor)
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual void reset();
|
||||
|
||||
/**
|
||||
* This method returns a LayoutEngine capable of laying out text
|
||||
* in the given font, script and langauge. Note that the LayoutEngine
|
||||
* returned may be a subclass of LayoutEngine.
|
||||
*
|
||||
* @param fontInstance - the font of the text
|
||||
* @param scriptCode - the script of the text
|
||||
* @param languageCode - the language of the text
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @return a LayoutEngine which can layout text in the given font.
|
||||
*
|
||||
* @see LEFontInstance
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* Override of existing call that provides flags to control typography.
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typo_flags, LEErrorCode &success);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @deprecated ICU 54. See {@link icu::LayoutEngine}
|
||||
*/
|
||||
static UClassID getStaticClassID();
|
||||
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
@ -1,747 +0,0 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 2002-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __PARAGRAPHLAYOUT_H
|
||||
|
||||
#define __PARAGRAPHLAYOUT_H
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Paragraph Layout
|
||||
*/
|
||||
|
||||
/*
|
||||
* ParagraphLayout doesn't make much sense without
|
||||
* BreakIterator...
|
||||
*/
|
||||
#include "unicode/uscript.h"
|
||||
#if ! UCONFIG_NO_BREAK_ITERATION
|
||||
|
||||
#include "layout/LETypes.h"
|
||||
#include "layout/LEFontInstance.h"
|
||||
#include "layout/LayoutEngine.h"
|
||||
#include "unicode/ubidi.h"
|
||||
#include "unicode/brkiter.h"
|
||||
|
||||
#include "layout/RunArrays.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* ParagraphLayout.
|
||||
*
|
||||
* The <code>ParagraphLayout</code> object will analyze the text into runs of text in the
|
||||
* same font, script and direction, and will create a <code>LayoutEngine</code> object for each run.
|
||||
* The <code>LayoutEngine</code> will transform the characters into glyph codes in visual order.
|
||||
*
|
||||
* Clients can use this to break a paragraph into lines, and to display the glyphs in each line.
|
||||
*
|
||||
* Note that {@link icu::LayoutEngine} is deprecated, but this class is not.
|
||||
* You may use this class with the HarfBuzz icu-le-hb wrapper,
|
||||
* see http://www.freedesktop.org/wiki/Software/HarfBuzz/
|
||||
*
|
||||
* See http://userguide.icu-project.org/layoutengine for special build instructions.
|
||||
*
|
||||
* @see icu::LayoutEngine
|
||||
*/
|
||||
class U_LAYOUTEX_API ParagraphLayout : public UObject
|
||||
{
|
||||
public:
|
||||
class VisualRun;
|
||||
|
||||
/**
|
||||
* This class represents a single line of text in a <code>ParagraphLayout</code>. They
|
||||
* can only be created by calling <code>ParagraphLayout::nextLine()</code>. Each line
|
||||
* consists of multiple visual runs, represented by <code>ParagraphLayout::VisualRun</code>
|
||||
* objects.
|
||||
*
|
||||
* @see ParagraphLayout
|
||||
* @see ParagraphLayout::VisualRun
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API Line : public UObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The constructor is private since these objects can only be
|
||||
* created by <code>ParagraphLayout</code>. However, it is the
|
||||
* clients responsibility to destroy the objects, so the destructor
|
||||
* is public.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
~Line();
|
||||
|
||||
/**
|
||||
* Count the number of visual runs in the line.
|
||||
*
|
||||
* @return the number of visual runs.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 countRuns() const;
|
||||
|
||||
/**
|
||||
* Get the ascent of the line. This is the maximum ascent
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @return the ascent of the line.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 getAscent() const;
|
||||
|
||||
/**
|
||||
* Get the descent of the line. This is the maximum descent
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @return the descent of the line.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 getDescent() const;
|
||||
|
||||
/**
|
||||
* Get the leading of the line. This is the maximum leading
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @return the leading of the line.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 getLeading() const;
|
||||
|
||||
/**
|
||||
* Get the width of the line. This is a convenience method
|
||||
* which returns the last X position of the last visual run
|
||||
* in the line.
|
||||
*
|
||||
* @return the width of the line.
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
le_int32 getWidth() const;
|
||||
|
||||
/**
|
||||
* Get a <code>ParagraphLayout::VisualRun</code> object for a given
|
||||
* visual run in the line.
|
||||
*
|
||||
* @param runIndex is the index of the run, in visual order.
|
||||
*
|
||||
* @return the <code>ParagraphLayout::VisualRun</code> object representing the
|
||||
* visual run. This object is owned by the <code>Line</code> object which
|
||||
* created it, and will remain valid for as long as the <code>Line</code>
|
||||
* object is valid.
|
||||
*
|
||||
* @see ParagraphLayout::VisualRun
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
const VisualRun *getVisualRun(le_int32 runIndex) const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
friend class ParagraphLayout;
|
||||
|
||||
le_int32 fAscent;
|
||||
le_int32 fDescent;
|
||||
le_int32 fLeading;
|
||||
|
||||
le_int32 fRunCount;
|
||||
le_int32 fRunCapacity;
|
||||
|
||||
VisualRun **fRuns;
|
||||
|
||||
inline Line();
|
||||
inline Line(const Line &other);
|
||||
inline Line &operator=(const Line & /*other*/) { return *this; };
|
||||
|
||||
void computeMetrics();
|
||||
|
||||
void append(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
|
||||
const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
|
||||
};
|
||||
|
||||
/**
|
||||
* This object represents a single visual run in a line of text in
|
||||
* a paragraph. A visual run is text which is in the same font,
|
||||
* script, and direction. The text is represented by an array of
|
||||
* <code>LEGlyphIDs</code>, an array of (x, y) glyph positions and
|
||||
* a table which maps indices into the glyph array to indices into
|
||||
* the original character array which was used to create the paragraph.
|
||||
*
|
||||
* These objects are only created by <code>ParagraphLayout::Line</code> objects,
|
||||
* so their constructors and destructors are private.
|
||||
*
|
||||
* @see ParagraphLayout::Line
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API VisualRun : public UObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Get the <code>LEFontInstance</code> object which
|
||||
* represents the font of the visual run. This will always
|
||||
* be a non-composite font.
|
||||
*
|
||||
* @return the <code>LEFontInstance</code> object which represents the
|
||||
* font of the visual run.
|
||||
*
|
||||
* @see LEFontInstance
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline const LEFontInstance *getFont() const;
|
||||
|
||||
/**
|
||||
* Get the direction of the visual run.
|
||||
*
|
||||
* @return the direction of the run. This will be UBIDI_LTR if the
|
||||
* run is left-to-right and UBIDI_RTL if the line is right-to-left.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline UBiDiDirection getDirection() const;
|
||||
|
||||
/**
|
||||
* Get the number of glyphs in the visual run.
|
||||
*
|
||||
* @return the number of glyphs.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getGlyphCount() const;
|
||||
|
||||
/**
|
||||
* Get the glyphs in the visual run. Glyphs with the values <code>0xFFFE</code> and
|
||||
* <code>0xFFFF</code> should be ignored.
|
||||
*
|
||||
* @return the address of the array of glyphs for this visual run. The storage
|
||||
* is owned by the <code>VisualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>VisualRun</code> object is valid.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline const LEGlyphID *getGlyphs() const;
|
||||
|
||||
/**
|
||||
* Get the (x, y) positions of the glyphs in the visual run. To simplify storage
|
||||
* management, the x and y positions are stored in a single array with the x positions
|
||||
* at even offsets in the array and the corresponding y position in the following odd offset.
|
||||
* There is an extra (x, y) pair at the end of the array which represents the advance of
|
||||
* the final glyph in the run.
|
||||
*
|
||||
* @return the address of the array of glyph positions for this visual run. The storage
|
||||
* is owned by the <code>VisualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>VisualRun</code> object is valid.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline const float *getPositions() const;
|
||||
|
||||
/**
|
||||
* Get the glyph-to-character map for this visual run. This maps the indices into
|
||||
* the glyph array to indices into the character array used to create the paragraph.
|
||||
*
|
||||
* @return the address of the character-to-glyph map for this visual run. The storage
|
||||
* is owned by the <code>VisualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>VisualRun</code> object is valid.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline const le_int32 *getGlyphToCharMap() const;
|
||||
|
||||
/**
|
||||
* A convenience method which returns the ascent value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @return the ascent value of this run's font.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getAscent() const;
|
||||
|
||||
/**
|
||||
* A convenience method which returns the descent value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @return the descent value of this run's font.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getDescent() const;
|
||||
|
||||
/**
|
||||
* A convenience method which returns the leading value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @return the leading value of this run's font.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getLeading() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
const LEFontInstance *fFont;
|
||||
const UBiDiDirection fDirection;
|
||||
|
||||
const le_int32 fGlyphCount;
|
||||
|
||||
const LEGlyphID *fGlyphs;
|
||||
const float *fPositions;
|
||||
const le_int32 *fGlyphToCharMap;
|
||||
|
||||
friend class Line;
|
||||
|
||||
inline VisualRun();
|
||||
inline VisualRun(const VisualRun &other);
|
||||
inline VisualRun &operator=(const VisualRun &/*other*/) { return *this; };
|
||||
|
||||
inline VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
|
||||
const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[]);
|
||||
|
||||
~VisualRun();
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct a <code>ParagraphLayout</code> object for a styled paragraph. The paragraph is specified
|
||||
* as runs of text all in the same font. An <code>LEFontInstance</code> object and a limit offset
|
||||
* are specified for each font run. The limit offset is the offset of the character immediately
|
||||
* after the font run.
|
||||
*
|
||||
* Clients can optionally specify directional runs and / or script runs. If these aren't specified
|
||||
* they will be computed.
|
||||
*
|
||||
* If any errors are encountered during construction, <code>status</code> will be set, and the object
|
||||
* will be set to be empty.
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @param fontRuns a pointer to a <code>FontRuns</code> object representing the font runs.
|
||||
*
|
||||
* @param levelRuns is a pointer to a <code>ValueRuns</code> object representing the directional levels.
|
||||
* If this pointer in <code>NULL</code> the levels will be determined by running the Unicde
|
||||
* Bidi algorithm.
|
||||
*
|
||||
* @param scriptRuns is a pointer to a <code>ValueRuns</code> object representing script runs.
|
||||
* If this pointer in <code>NULL</code> the script runs will be determined using the
|
||||
* Unicode code points.
|
||||
*
|
||||
* @param localeRuns is a pointer to a <code>LocaleRuns</code> object representing locale runs.
|
||||
* The <code>Locale</code> objects are used to determind the language of the text. If this
|
||||
* pointer is <code>NULL</code> the default locale will be used for all of the text.
|
||||
*
|
||||
* @param paragraphLevel is the directionality of the paragraph, as in the UBiDi object.
|
||||
*
|
||||
* @param vertical is <code>TRUE</code> if the paragraph should be set vertically.
|
||||
*
|
||||
* @param status will be set to any error code encountered during construction.
|
||||
*
|
||||
* @see ubidi.h
|
||||
* @see LEFontInstance.h
|
||||
* @see LayoutEngine.h
|
||||
* @see RunArrays.h
|
||||
*
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
ParagraphLayout(const LEUnicode chars[], le_int32 count,
|
||||
const FontRuns *fontRuns,
|
||||
const ValueRuns *levelRuns,
|
||||
const ValueRuns *scriptRuns,
|
||||
const LocaleRuns *localeRuns,
|
||||
UBiDiLevel paragraphLevel, le_bool vertical,
|
||||
LEErrorCode &status);
|
||||
|
||||
/**
|
||||
* The destructor. Virtual so that it works correctly with
|
||||
* sublcasses.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
~ParagraphLayout();
|
||||
|
||||
// Note: the following is #if 0'd out because there's no good
|
||||
// way to implement it without either calling layoutEngineFactory()
|
||||
// or duplicating the logic there...
|
||||
#if 0
|
||||
/**
|
||||
* Examine the given styled paragraph and determine if it contains any text which
|
||||
* requires complex processing. (i.e. that cannot be correctly rendered by
|
||||
* just mapping the characters to glyphs and rendering them in order)
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @param fontRuns is a pointer to a <code>FontRuns</code> object representing the font runs.
|
||||
*
|
||||
* @return <code>TRUE</code> if the paragraph contains complex text.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static le_bool isComplex(const LEUnicode chars[], le_int32 count, const FontRuns *fontRuns);
|
||||
#else
|
||||
/**
|
||||
* Examine the given text and determine if it contains characters in any
|
||||
* script which requires complex processing to be rendered correctly.
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @return <code>TRUE</code> if any of the text requires complex processing.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static le_bool isComplex(const LEUnicode chars[], le_int32 count);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return the resolved paragraph level. This is useful for those cases
|
||||
* where the bidi analysis has determined the level based on the first
|
||||
* strong character in the paragraph.
|
||||
*
|
||||
* @return the resolved paragraph level.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline UBiDiLevel getParagraphLevel();
|
||||
|
||||
/**
|
||||
* Return the directionality of the text in the paragraph.
|
||||
*
|
||||
* @return <code>UBIDI_LTR</code> if the text is all left to right,
|
||||
* <code>UBIDI_RTL</code> if the text is all right to left,
|
||||
* or <code>UBIDI_MIXED</code> if the text has mixed direction.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline UBiDiDirection getTextDirection();
|
||||
|
||||
/**
|
||||
* Return the max ascent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @return the ascent value.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getAscent() const;
|
||||
|
||||
/**
|
||||
* Return the max descent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @return the decent value.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getDescent() const;
|
||||
|
||||
/**
|
||||
* Return the max leading value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @return the leading value.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual le_int32 getLeading() const;
|
||||
|
||||
/**
|
||||
* Reset line breaking to start from the beginning of the paragraph.
|
||||
*
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline void reflow();
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
*
|
||||
* Convenience method for determining if paragraph layout processing is complete ( i.e. there
|
||||
* are no more lines left to process. )
|
||||
*
|
||||
* @return true if there are no more lines to be processed
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
inline le_bool isDone() const;
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* Return a <code>ParagraphLayout::Line</code> object which represents next line
|
||||
* in the paragraph. The width of the line is specified each time so that it can
|
||||
* be varied to support arbitrary paragraph shapes.
|
||||
*
|
||||
* @param width is the width of the line. If <code>width</code> is less than or equal
|
||||
* to zero, a <code>ParagraphLayout::Line</code> object representing the
|
||||
* rest of the paragraph will be returned.
|
||||
*
|
||||
* @return a <code>ParagraphLayout::Line</code> object which represents the line. The caller
|
||||
* is responsible for deleting the object. Returns <code>NULL</code> if there are no
|
||||
* more lines in the paragraph.
|
||||
*
|
||||
* @see ParagraphLayout::Line
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
Line *nextLine(float width);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
struct StyleRunInfo
|
||||
{
|
||||
LayoutEngine *engine;
|
||||
const LEFontInstance *font;
|
||||
const Locale *locale;
|
||||
LEGlyphID *glyphs;
|
||||
float *positions;
|
||||
UScriptCode script;
|
||||
UBiDiLevel level;
|
||||
le_int32 runBase;
|
||||
le_int32 runLimit;
|
||||
le_int32 glyphBase;
|
||||
le_int32 glyphCount;
|
||||
};
|
||||
|
||||
ParagraphLayout() {};
|
||||
ParagraphLayout(const ParagraphLayout & /*other*/) : UObject( ){};
|
||||
inline ParagraphLayout &operator=(const ParagraphLayout & /*other*/) { return *this; };
|
||||
|
||||
void computeLevels(UBiDiLevel paragraphLevel);
|
||||
|
||||
Line *computeVisualRuns();
|
||||
void appendRun(Line *line, le_int32 run, le_int32 firstChar, le_int32 lastChar);
|
||||
|
||||
void computeScripts();
|
||||
|
||||
void computeLocales();
|
||||
|
||||
void computeSubFonts(const FontRuns *fontRuns, LEErrorCode &status);
|
||||
|
||||
void computeMetrics();
|
||||
|
||||
le_int32 getLanguageCode(const Locale *locale);
|
||||
|
||||
le_int32 getCharRun(le_int32 charIndex);
|
||||
|
||||
static le_bool isComplex(UScriptCode script);
|
||||
|
||||
le_int32 previousBreak(le_int32 charIndex);
|
||||
|
||||
|
||||
const LEUnicode *fChars;
|
||||
le_int32 fCharCount;
|
||||
|
||||
const FontRuns *fFontRuns;
|
||||
const ValueRuns *fLevelRuns;
|
||||
const ValueRuns *fScriptRuns;
|
||||
const LocaleRuns *fLocaleRuns;
|
||||
|
||||
le_bool fVertical;
|
||||
le_bool fClientLevels;
|
||||
le_bool fClientScripts;
|
||||
le_bool fClientLocales;
|
||||
|
||||
UBiDiLevel *fEmbeddingLevels;
|
||||
|
||||
le_int32 fAscent;
|
||||
le_int32 fDescent;
|
||||
le_int32 fLeading;
|
||||
|
||||
le_int32 *fGlyphToCharMap;
|
||||
le_int32 *fCharToMinGlyphMap;
|
||||
le_int32 *fCharToMaxGlyphMap;
|
||||
float *fGlyphWidths;
|
||||
le_int32 fGlyphCount;
|
||||
|
||||
UBiDi *fParaBidi;
|
||||
UBiDi *fLineBidi;
|
||||
|
||||
le_int32 *fStyleRunLimits;
|
||||
le_int32 *fStyleIndices;
|
||||
StyleRunInfo *fStyleRunInfo;
|
||||
le_int32 fStyleRunCount;
|
||||
|
||||
BreakIterator *fBreakIterator;
|
||||
le_int32 fLineStart;
|
||||
le_int32 fLineEnd;
|
||||
|
||||
le_int32 fFirstVisualRun;
|
||||
le_int32 fLastVisualRun;
|
||||
float fVisualRunLastX;
|
||||
float fVisualRunLastY;
|
||||
};
|
||||
|
||||
inline UBiDiLevel ParagraphLayout::getParagraphLevel()
|
||||
{
|
||||
return ubidi_getParaLevel(fParaBidi);
|
||||
}
|
||||
|
||||
inline UBiDiDirection ParagraphLayout::getTextDirection()
|
||||
{
|
||||
return ubidi_getDirection(fParaBidi);
|
||||
}
|
||||
|
||||
inline void ParagraphLayout::reflow()
|
||||
{
|
||||
fLineEnd = 0;
|
||||
}
|
||||
|
||||
inline ParagraphLayout::Line::Line()
|
||||
: UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
|
||||
{
|
||||
// nothing else to do
|
||||
}
|
||||
|
||||
inline ParagraphLayout::Line::Line(const Line & /*other*/)
|
||||
: UObject(), fAscent(0), fDescent(0), fLeading(0), fRunCount(0), fRunCapacity(0), fRuns(NULL)
|
||||
{
|
||||
// nothing else to do
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::Line::countRuns() const
|
||||
{
|
||||
return fRunCount;
|
||||
}
|
||||
|
||||
inline const LEFontInstance *ParagraphLayout::VisualRun::getFont() const
|
||||
{
|
||||
return fFont;
|
||||
}
|
||||
|
||||
inline UBiDiDirection ParagraphLayout::VisualRun::getDirection() const
|
||||
{
|
||||
return fDirection;
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::VisualRun::getGlyphCount() const
|
||||
{
|
||||
return fGlyphCount;
|
||||
}
|
||||
|
||||
inline const LEGlyphID *ParagraphLayout::VisualRun::getGlyphs() const
|
||||
{
|
||||
return fGlyphs;
|
||||
}
|
||||
|
||||
inline const float *ParagraphLayout::VisualRun::getPositions() const
|
||||
{
|
||||
return fPositions;
|
||||
}
|
||||
|
||||
inline const le_int32 *ParagraphLayout::VisualRun::getGlyphToCharMap() const
|
||||
{
|
||||
return fGlyphToCharMap;
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::VisualRun::getAscent() const
|
||||
{
|
||||
return fFont->getAscent();
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::VisualRun::getDescent() const
|
||||
{
|
||||
return fFont->getDescent();
|
||||
}
|
||||
|
||||
inline le_int32 ParagraphLayout::VisualRun::getLeading() const
|
||||
{
|
||||
return fFont->getLeading();
|
||||
}
|
||||
|
||||
inline ParagraphLayout::VisualRun::VisualRun()
|
||||
: UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
inline ParagraphLayout::VisualRun::VisualRun(const VisualRun &/*other*/)
|
||||
: UObject(), fFont(NULL), fDirection(UBIDI_LTR), fGlyphCount(0), fGlyphs(NULL), fPositions(NULL), fGlyphToCharMap(NULL)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
inline ParagraphLayout::VisualRun::VisualRun(const LEFontInstance *font, UBiDiDirection direction, le_int32 glyphCount,
|
||||
const LEGlyphID glyphs[], const float positions[], const le_int32 glyphToCharMap[])
|
||||
: fFont(font), fDirection(direction), fGlyphCount(glyphCount),
|
||||
fGlyphs(glyphs), fPositions(positions), fGlyphToCharMap(glyphToCharMap)
|
||||
{
|
||||
// nothing else needs to be done!
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
#endif
|
||||
@ -1,676 +0,0 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 2003-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __RUNARRAYS_H
|
||||
|
||||
#define __RUNARRAYS_H
|
||||
|
||||
#include "layout/LETypes.h"
|
||||
#include "layout/LEFontInstance.h"
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/locid.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: base class for building classes which represent data that is associated with runs of text.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* The initial size of an array if it is unspecified.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define INITIAL_CAPACITY 16
|
||||
|
||||
/**
|
||||
* When an array needs to grow, it will double in size until
|
||||
* it becomes this large, then it will grow by this amount.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
#define CAPACITY_GROW_LIMIT 128
|
||||
|
||||
/**
|
||||
* The <code>RunArray</code> class is a base class for building classes
|
||||
* which represent data that is associated with runs of text. This class
|
||||
* maintains an array of limit indices into the text, subclasses
|
||||
* provide one or more arrays of data.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API RunArray : public UObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a <code>RunArray</code> object from a pre-existing
|
||||
* array of limit indices.
|
||||
*
|
||||
* @param limits is an array of limit indices. This array must remain
|
||||
* valid until the <code>RunArray</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the limit array.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline RunArray(const le_int32 *limits, le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>RunArray</code> object. Clients can add limit
|
||||
* indices array using the <code>add</code> method.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the limit indices array. If
|
||||
* this value is zero, no array will be allocated.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
RunArray(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* The destructor; virtual so that subclass destructors are invoked as well.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual ~RunArray();
|
||||
|
||||
/**
|
||||
* Get the number of entries in the limit indices array.
|
||||
*
|
||||
* @return the number of entries in the limit indices array.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getCount() const;
|
||||
|
||||
/**
|
||||
* Reset the limit indices array. This method sets the number of entries in the
|
||||
* limit indices array to zero. It does not delete the array.
|
||||
*
|
||||
* Note: Subclass arrays will also be reset and not deleted.
|
||||
*
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
inline void reset();
|
||||
|
||||
/**
|
||||
* Get the last limit index. This is the number of characters in
|
||||
* the text.
|
||||
*
|
||||
* @return the last limit index.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getLimit() const;
|
||||
|
||||
/**
|
||||
* Get the limit index for a particular run of text.
|
||||
*
|
||||
* @param run is the run. This is an index into the limit index array.
|
||||
*
|
||||
* @return the limit index for the run, or -1 if <code>run</code> is out of bounds.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline le_int32 getLimit(le_int32 run) const;
|
||||
|
||||
/**
|
||||
* Add a limit index to the limit indices array and return the run index
|
||||
* where it was stored. If the array does not exist, it will be created by
|
||||
* calling the <code>init</code> method. If it is full, it will be grown by
|
||||
* calling the <code>grow</code> method.
|
||||
*
|
||||
* If the <code>RunArray</code> object was created with a client-supplied
|
||||
* limit indices array, this method will return a run index of -1.
|
||||
*
|
||||
* Subclasses should not override this method. Rather they should provide
|
||||
* a new <code>add</code> method which takes a limit index along with whatever
|
||||
* other data they implement. The new <code>add</code> method should
|
||||
* first call this method to grow the data arrays, and use the return value
|
||||
* to store the data in their own arrays.
|
||||
*
|
||||
* @param limit is the limit index to add to the array.
|
||||
*
|
||||
* @return the run index where the limit index was stored, or -1 if the limit index cannt be stored.
|
||||
*
|
||||
* @see init
|
||||
* @see grow
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 add(le_int32 limit);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Create a data array with the given initial size. This method will be
|
||||
* called by the <code>add</code> method if there is no limit indices
|
||||
* array. Subclasses which override this method must also call it from
|
||||
* the overriding method to create the limit indices array.
|
||||
*
|
||||
* @param capacity is the initial size of the data array.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual void init(le_int32 capacity);
|
||||
|
||||
/**
|
||||
* Grow a data array to the given initial size. This method will be
|
||||
* called by the <code>add</code> method if the limit indices
|
||||
* array is full. Subclasses which override this method must also call it from
|
||||
* the overriding method to grow the limit indices array.
|
||||
*
|
||||
* @param capacity is the initial size of the data array.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual void grow(le_int32 capacity);
|
||||
|
||||
/**
|
||||
* Set by the constructors to indicate whether
|
||||
* or not the client supplied the data arrays.
|
||||
* If they were supplied by the client, the
|
||||
* <code>add</code> method won't change the arrays
|
||||
* and the destructor won't delete them.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_bool fClientArrays;
|
||||
|
||||
private:
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
le_int32 ensureCapacity();
|
||||
|
||||
inline RunArray();
|
||||
inline RunArray(const RunArray & /*other*/);
|
||||
inline RunArray &operator=(const RunArray & /*other*/) { return *this; };
|
||||
|
||||
const le_int32 *fLimits;
|
||||
le_int32 fCount;
|
||||
le_int32 fCapacity;
|
||||
};
|
||||
|
||||
inline RunArray::RunArray()
|
||||
: UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline RunArray::RunArray(const RunArray & /*other*/)
|
||||
: UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline RunArray::RunArray(const le_int32 *limits, le_int32 count)
|
||||
: UObject(), fClientArrays(TRUE), fLimits(limits), fCount(count), fCapacity(count)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline le_int32 RunArray::getCount() const
|
||||
{
|
||||
return fCount;
|
||||
}
|
||||
|
||||
inline void RunArray::reset()
|
||||
{
|
||||
fCount = 0;
|
||||
}
|
||||
|
||||
inline le_int32 RunArray::getLimit(le_int32 run) const
|
||||
{
|
||||
if (run < 0 || run >= fCount) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fLimits[run];
|
||||
}
|
||||
|
||||
inline le_int32 RunArray::getLimit() const
|
||||
{
|
||||
return getLimit(fCount - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>FontRuns</code> class associates pointers to <code>LEFontInstance</code>
|
||||
* objects with runs of text.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API FontRuns : public RunArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a <code>FontRuns</code> object from pre-existing arrays of fonts
|
||||
* and limit indices.
|
||||
*
|
||||
* @param fonts is the address of an array of pointers to <code>LEFontInstance</code> objects. This
|
||||
* array, and the <code>LEFontInstance</code> objects to which it points must remain
|
||||
* valid until the <code>FontRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>FontRuns</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>FontRuns</code> object. Clients can add font and limit
|
||||
* indices arrays using the <code>add</code> method.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the font and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
FontRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* The destructor; virtual so that subclass destructors are invoked as well.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual ~FontRuns();
|
||||
|
||||
/**
|
||||
* Get the <code>LEFontInstance</code> object assoicated with the given run
|
||||
* of text. Use <code>RunArray::getLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the <code>LEFontInstance</code> associated with the given text run.
|
||||
*
|
||||
* @see RunArray::getLimit
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
const LEFontInstance *getFont(le_int32 run) const;
|
||||
|
||||
|
||||
/**
|
||||
* Add an <code>LEFontInstance</code> and limit index pair to the data arrays and return
|
||||
* the run index where the data was stored. This method calls
|
||||
* <code>RunArray::add(limit)</code> which will create or grow the arrays as needed.
|
||||
*
|
||||
* If the <code>FontRuns</code> object was created with a client-supplied
|
||||
* font and limit indices arrays, this method will return a run index of -1.
|
||||
*
|
||||
* Subclasses should not override this method. Rather they should provide a new <code>add</code>
|
||||
* method which takes a font and a limit index along with whatever other data they implement.
|
||||
* The new <code>add</code> method should first call this method to grow the font and limit indices
|
||||
* arrays, and use the returned run index to store data their own arrays.
|
||||
*
|
||||
* @param font is the address of the <code>LEFontInstance</code> to add. This object must
|
||||
* remain valid until the <code>FontRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the font and limit index were stored, or -1 if the data cannot be stored.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 add(const LEFontInstance *font, le_int32 limit);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
protected:
|
||||
virtual void init(le_int32 capacity);
|
||||
virtual void grow(le_int32 capacity);
|
||||
|
||||
private:
|
||||
|
||||
inline FontRuns();
|
||||
inline FontRuns(const FontRuns &other);
|
||||
inline FontRuns &operator=(const FontRuns & /*other*/) { return *this; };
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
const LEFontInstance **fFonts;
|
||||
};
|
||||
|
||||
inline FontRuns::FontRuns()
|
||||
: RunArray(0), fFonts(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline FontRuns::FontRuns(const FontRuns & /*other*/)
|
||||
: RunArray(0), fFonts(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
|
||||
: RunArray(limits, count), fFonts(fonts)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>LocaleRuns</code> class associates pointers to <code>Locale</code>
|
||||
* objects with runs of text.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API LocaleRuns : public RunArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a <code>LocaleRuns</code> object from pre-existing arrays of locales
|
||||
* and limit indices.
|
||||
*
|
||||
* @param locales is the address of an array of pointers to <code>Locale</code> objects. This array,
|
||||
* and the <code>Locale</code> objects to which it points, must remain valid until
|
||||
* the <code>LocaleRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until the
|
||||
* <code>LocaleRuns</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>LocaleRuns</code> object. Clients can add locale and limit
|
||||
* indices arrays using the <code>add</code> method.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the locale and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
LocaleRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* The destructor; virtual so that subclass destructors are invoked as well.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual ~LocaleRuns();
|
||||
|
||||
/**
|
||||
* Get the <code>Locale</code> object assoicated with the given run
|
||||
* of text. Use <code>RunArray::getLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the <code>Locale</code> associated with the given text run.
|
||||
*
|
||||
* @see RunArray::getLimit
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
const Locale *getLocale(le_int32 run) const;
|
||||
|
||||
|
||||
/**
|
||||
* Add a <code>Locale</code> and limit index pair to the data arrays and return
|
||||
* the run index where the data was stored. This method calls
|
||||
* <code>RunArray::add(limit)</code> which will create or grow the arrays as needed.
|
||||
*
|
||||
* If the <code>LocaleRuns</code> object was created with a client-supplied
|
||||
* locale and limit indices arrays, this method will return a run index of -1.
|
||||
*
|
||||
* Subclasses should not override this method. Rather they should provide a new <code>add</code>
|
||||
* method which takes a locale and a limit index along with whatever other data they implement.
|
||||
* The new <code>add</code> method should first call this method to grow the font and limit indices
|
||||
* arrays, and use the returned run index to store data their own arrays.
|
||||
*
|
||||
* @param locale is the address of the <code>Locale</code> to add. This object must remain valid
|
||||
* until the <code>LocaleRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the locale and limit index were stored, or -1 if the data cannot be stored.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 add(const Locale *locale, le_int32 limit);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
protected:
|
||||
virtual void init(le_int32 capacity);
|
||||
virtual void grow(le_int32 capacity);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const Locale **fLocales;
|
||||
|
||||
private:
|
||||
|
||||
inline LocaleRuns();
|
||||
inline LocaleRuns(const LocaleRuns &other);
|
||||
inline LocaleRuns &operator=(const LocaleRuns & /*other*/) { return *this; };
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
};
|
||||
|
||||
inline LocaleRuns::LocaleRuns()
|
||||
: RunArray(0), fLocales(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline LocaleRuns::LocaleRuns(const LocaleRuns & /*other*/)
|
||||
: RunArray(0), fLocales(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
|
||||
: RunArray(limits, count), fLocales(locales)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ValueRuns</code> class associates integer values with runs of text.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
class U_LAYOUTEX_API ValueRuns : public RunArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a <code>ValueRuns</code> object from pre-existing arrays of values
|
||||
* and limit indices.
|
||||
*
|
||||
* @param values is the address of an array of integer. This array must remain valid until
|
||||
* the <code>ValueRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>ValueRuns</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>ValueRuns</code> object. Clients can add value and limit
|
||||
* indices arrays using the <code>add</code> method.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the value and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see add
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
ValueRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* The destructor; virtual so that subclass destructors are invoked as well.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual ~ValueRuns();
|
||||
|
||||
/**
|
||||
* Get the integer value assoicated with the given run
|
||||
* of text. Use <code>RunArray::getLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the integer value associated with the given text run.
|
||||
*
|
||||
* @see RunArray::getLimit
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 getValue(le_int32 run) const;
|
||||
|
||||
|
||||
/**
|
||||
* Add an integer value and limit index pair to the data arrays and return
|
||||
* the run index where the data was stored. This method calls
|
||||
* <code>RunArray::add(limit)</code> which will create or grow the arrays as needed.
|
||||
*
|
||||
* If the <code>ValueRuns</code> object was created with a client-supplied
|
||||
* font and limit indices arrays, this method will return a run index of -1.
|
||||
*
|
||||
* Subclasses should not override this method. Rather they should provide a new <code>add</code>
|
||||
* method which takes an integer value and a limit index along with whatever other data they implement.
|
||||
* The new <code>add</code> method should first call this method to grow the font and limit indices
|
||||
* arrays, and use the returned run index to store data their own arrays.
|
||||
*
|
||||
* @param value is the integer value to add
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the value and limit index were stored, or -1 if the data cannot be stored.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
le_int32 add(le_int32 value, le_int32 limit);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
||||
|
||||
protected:
|
||||
virtual void init(le_int32 capacity);
|
||||
virtual void grow(le_int32 capacity);
|
||||
|
||||
private:
|
||||
|
||||
inline ValueRuns();
|
||||
inline ValueRuns(const ValueRuns &other);
|
||||
inline ValueRuns &operator=(const ValueRuns & /*other*/) { return *this; };
|
||||
|
||||
/**
|
||||
* The address of this static class variable serves as this class's ID
|
||||
* for ICU "poor man's RTTI".
|
||||
*/
|
||||
static const char fgClassID;
|
||||
|
||||
const le_int32 *fValues;
|
||||
};
|
||||
|
||||
inline ValueRuns::ValueRuns()
|
||||
: RunArray(0), fValues(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline ValueRuns::ValueRuns(const ValueRuns & /*other*/)
|
||||
: RunArray(0), fValues(NULL)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
|
||||
: RunArray(limits, count), fValues(values)
|
||||
{
|
||||
// nothing else to do...
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
@ -1,225 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LOENGINE_H
|
||||
#define __LOENGINE_H
|
||||
|
||||
#include "LETypes.h"
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* \file
|
||||
* \brief C API for complex text layout.
|
||||
* \internal
|
||||
*
|
||||
* This is a technology preview. The API may
|
||||
* change significantly.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The opaque type for a LayoutEngine.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void le_engine;
|
||||
|
||||
/**
|
||||
* The opaque type for a font instance.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void le_font;
|
||||
|
||||
/**
|
||||
* This function returns an le_engine capable of laying out text
|
||||
* in the given font, script and langauge. Note that the LayoutEngine
|
||||
* returned may be a subclass of LayoutEngine.
|
||||
*
|
||||
* @param font - the font of the text
|
||||
* @param scriptCode - the script of the text
|
||||
* @param languageCode - the language of the text
|
||||
* @param typo_flags - flags that control layout features like kerning and ligatures.
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @return an le_engine which can layout text in the given font.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_engine * U_EXPORT2
|
||||
le_create(const le_font *font,
|
||||
le_int32 scriptCode,
|
||||
le_int32 languageCode,
|
||||
le_int32 typo_flags,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function closes the given LayoutEngine. After
|
||||
* it returns, the le_engine is no longer valid.
|
||||
*
|
||||
* @param engine - the LayoutEngine to close.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_close(le_engine *engine);
|
||||
|
||||
/**
|
||||
* This routine will compute the glyph, character index and position arrays.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param chars - the input character context
|
||||
* @param offset - the offset of the first character to process
|
||||
* @param count - the number of characters to process
|
||||
* @param max - the number of characters in the input context
|
||||
* @param rightToLeft - TRUE if the characers are in a right to left directional run
|
||||
* @param x - the initial X position
|
||||
* @param y - the initial Y position
|
||||
* @param success - output parameter set to an error code if the operation fails
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* Note: The glyph, character index and position array can be accessed
|
||||
* using the getter routines below.
|
||||
*
|
||||
* Note: If you call this function more than once, you must call the reset()
|
||||
* function first to free the glyph, character index and position arrays
|
||||
* allocated by the previous call.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
le_layoutChars(le_engine *engine,
|
||||
const LEUnicode chars[],
|
||||
le_int32 offset,
|
||||
le_int32 count,
|
||||
le_int32 max,
|
||||
le_bool rightToLeft,
|
||||
float x,
|
||||
float y,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function returns the number of glyphs in the glyph array. Note
|
||||
* that the number of glyphs will be greater than or equal to the number
|
||||
* of characters used to create the LayoutEngine.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param success - output parameter set to an error code if the operation fails.
|
||||
*
|
||||
* @return the number of glyphs in the glyph array
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
le_getGlyphCount(le_engine *engine,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function copies the glyph array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold all
|
||||
* the glyphs.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param glyphs - the destiniation glyph array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getGlyphs(le_engine *engine,
|
||||
LEGlyphID glyphs[],
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getCharIndices(le_engine *engine,
|
||||
le_int32 charIndices[],
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function copies the character index array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold a
|
||||
* character index for each glyph.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param charIndices - the destiniation character index array
|
||||
* @param indexBase - an offset that will be added to each index.
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getCharIndicesWithBase(le_engine *engine,
|
||||
le_int32 charIndices[],
|
||||
le_int32 indexBase,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function copies the position array into a caller supplied array.
|
||||
* The caller must ensure that the array is large enough to hold an
|
||||
* X and Y position for each glyph, plus an extra X and Y for the
|
||||
* advance of the last glyph.
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param positions - the destiniation position array
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getGlyphPositions(le_engine *engine,
|
||||
float positions[],
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function returns the X and Y position of the glyph at
|
||||
* the given index.
|
||||
*
|
||||
* Input parameters:
|
||||
* @param engine - the LayoutEngine
|
||||
* @param glyphIndex - the index of the glyph
|
||||
*
|
||||
* Output parameters:
|
||||
* @param x - the glyph's X position
|
||||
* @param y - the glyph's Y position
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_getGlyphPosition(le_engine *engine,
|
||||
le_int32 glyphIndex,
|
||||
float *x,
|
||||
float *y,
|
||||
LEErrorCode *success);
|
||||
|
||||
/**
|
||||
* This function frees the glyph, character index and position arrays
|
||||
* so that the LayoutEngine can be reused to layout a different
|
||||
* characer array. (This function is also called by le_close)
|
||||
*
|
||||
* @param engine - the LayoutEngine
|
||||
* @param success - set to an error code if the operation fails
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
le_reset(le_engine *engine,
|
||||
LEErrorCode *success);
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
#endif
|
||||
@ -1,466 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PLAYOUT_H
|
||||
#define __PLAYOUT_H
|
||||
|
||||
/*
|
||||
* ParagraphLayout doesn't make much sense without
|
||||
* BreakIterator...
|
||||
*/
|
||||
#include "unicode/ubidi.h"
|
||||
#if ! UCONFIG_NO_BREAK_ITERATION
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
|
||||
#include "layout/LETypes.h"
|
||||
#include "plruns.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C API for paragraph layout.
|
||||
*
|
||||
* This is a technology preview. The API may
|
||||
* change significantly.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The opaque type for a paragraph layout.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void pl_paragraph;
|
||||
|
||||
/**
|
||||
* The opaque type for a line in a paragraph layout.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void pl_line;
|
||||
|
||||
/**
|
||||
* The opaque type for a visual run in a line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
typedef void pl_visualRun;
|
||||
|
||||
/**
|
||||
* Construct a <code>ParagraphLayout</code> object for a styled paragraph. The paragraph is specified
|
||||
* as runs of text all in the same font. An <code>LEFontInstance</code> object and a limit offset
|
||||
* are specified for each font run. The limit offset is the offset of the character immediately
|
||||
* after the font run.
|
||||
*
|
||||
* Clients can optionally specify directional runs and / or script runs. If these aren't specified
|
||||
* they will be computed.
|
||||
*
|
||||
* If any errors are encountered during construction, <code>status</code> will be set, and the object
|
||||
* will be set to be empty.
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @param fontRuns a pointer to a <code>pl_fontRuns</code> object representing the font runs.
|
||||
*
|
||||
* @param levelRuns is a pointer to a <code>pl_valueRuns</code> object representing the directional levels.
|
||||
* If this pointer in <code>NULL</code> the levels will be determined by running the Unicde
|
||||
* Bidi algorithm.
|
||||
*
|
||||
* @param scriptRuns is a pointer to a <code>pl_valueRuns</code> object representing script runs.
|
||||
* If this pointer in <code>NULL</code> the script runs will be determined using the
|
||||
* Unicode code points.
|
||||
*
|
||||
* @param localeRuns is a pointer to a <code>pl_localeRuns</code> object representing locale runs.
|
||||
* The <code>Locale</code> objects are used to determind the language of the text. If this
|
||||
* pointer is <code>NULL</code> the default locale will be used for all of the text.
|
||||
*
|
||||
* @param paragraphLevel is the directionality of the paragraph, as in the UBiDi object.
|
||||
*
|
||||
* @param vertical is <code>TRUE</code> if the paragraph should be set vertically.
|
||||
*
|
||||
* @param status will be set to any error code encountered during construction.
|
||||
*
|
||||
* @return a pointer to the newly created <code>pl_paragraph</code> object. The object
|
||||
* will remain valid until <code>pl_close</code> is called.
|
||||
*
|
||||
* @see ubidi.h
|
||||
* @see longine.h
|
||||
* @see plruns.h
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_paragraph * U_EXPORT2
|
||||
pl_create(const LEUnicode chars[],
|
||||
le_int32 count,
|
||||
const pl_fontRuns *fontRuns,
|
||||
const pl_valueRuns *levelRuns,
|
||||
const pl_valueRuns *scriptRuns,
|
||||
const pl_localeRuns *localeRuns,
|
||||
UBiDiLevel paragraphLevel,
|
||||
le_bool vertical,
|
||||
LEErrorCode *status);
|
||||
|
||||
/**
|
||||
* Close the given paragraph layout object.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code> object to be
|
||||
* closed. Once this routine returns the object
|
||||
* can no longer be referenced
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_close(pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Examine the given text and determine if it contains characters in any
|
||||
* script which requires complex processing to be rendered correctly.
|
||||
*
|
||||
* @param chars is an array of the characters in the paragraph
|
||||
*
|
||||
* @param count is the number of characters in the paragraph.
|
||||
*
|
||||
* @return <code>TRUE</code> if any of the text requires complex processing.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
||||
U_INTERNAL le_bool U_EXPORT2
|
||||
pl_isComplex(const LEUnicode chars[],
|
||||
le_int32 count);
|
||||
|
||||
/**
|
||||
* Return the resolved paragraph level. This is useful for those cases
|
||||
* where the bidi analysis has determined the level based on the first
|
||||
* strong character in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return the resolved paragraph level.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL UBiDiLevel U_EXPORT2
|
||||
pl_getParagraphLevel(pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Return the directionality of the text in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return <code>UBIDI_LTR</code> if the text is all left to right,
|
||||
* <code>UBIDI_RTL</code> if the text is all right to left,
|
||||
* or <code>UBIDI_MIXED</code> if the text has mixed direction.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL UBiDiDirection U_EXPORT2
|
||||
pl_getTextDirection(pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Get the max ascent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* Return the max ascent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return the ascent value.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getAscent(const pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Return the max descent value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return the decent value.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getDescent(const pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Return the max leading value for all the fonts
|
||||
* in the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @return the leading value.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLeading(const pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Reset line breaking to start from the beginning of the paragraph.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_reflow(pl_paragraph *paragraph);
|
||||
|
||||
/**
|
||||
* Return a <code>pl_line</code> object which represents next line
|
||||
* in the paragraph. The width of the line is specified each time so that it can
|
||||
* be varied to support arbitrary paragraph shapes.
|
||||
*
|
||||
* @param paragraph the <code>pl_paragraph</code>
|
||||
* @param width is the width of the line. If <code>width</code> is less than or equal
|
||||
* to zero, a <code>ParagraphLayout::Line</code> object representing the
|
||||
* rest of the paragraph will be returned.
|
||||
*
|
||||
* @return a <code>ParagraphLayout::Line</code> object which represents the line. The caller
|
||||
* is responsible for deleting the object. Returns <code>NULL</code> if there are no
|
||||
* more lines in the paragraph.
|
||||
*
|
||||
* @see pl_line
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_line * U_EXPORT2
|
||||
pl_nextLine(pl_paragraph *paragraph, float width);
|
||||
|
||||
/**
|
||||
* Close the given line object. Line objects are created
|
||||
* by <code>pl_nextLine</code> but it is the client's responsibility
|
||||
* to close them by calling this routine.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object to close.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_closeLine(pl_line *line);
|
||||
|
||||
/**
|
||||
* Count the number of visual runs in the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the number of visual runs.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_countLineRuns(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get the ascent of the line. This is the maximum ascent
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the ascent of the line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLineAscent(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get the descent of the line. This is the maximum descent
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the descent of the line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLineDescent(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get the leading of the line. This is the maximum leading
|
||||
* of all the fonts on the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the leading of the line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLineLeading(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get the width of the line. This is a convenience method
|
||||
* which returns the last X position of the last visual run
|
||||
* in the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
*
|
||||
* @return the width of the line.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLineWidth(const pl_line *line);
|
||||
|
||||
/**
|
||||
* Get a <code>ParagraphLayout::VisualRun</code> object for a given
|
||||
* visual run in the line.
|
||||
*
|
||||
* @param line the <code>pl_line</code> object.
|
||||
* @param runIndex is the index of the run, in visual order.
|
||||
*
|
||||
* @return the <code>pl_visualRun</code> object representing the
|
||||
* visual run. This object is owned by the <code>pl_line</code> object which
|
||||
* created it, and will remain valid for as long as the <code>pl_line</code>
|
||||
* object is valid.
|
||||
*
|
||||
* @see pl_visualRun
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const pl_visualRun * U_EXPORT2
|
||||
pl_getLineVisualRun(const pl_line *line, le_int32 runIndex);
|
||||
|
||||
/**
|
||||
* Get the <code>le_font</code> object which
|
||||
* represents the font of the visual run. This will always
|
||||
* be a non-composite font.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the <code>le_font</code> object which represents the
|
||||
* font of the visual run.
|
||||
*
|
||||
* @see le_font
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const le_font * U_EXPORT2
|
||||
pl_getVisualRunFont(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the direction of the visual run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the direction of the run. This will be <code>UBIDI_LTR</code> if the
|
||||
* run is left-to-right and <code>UBIDI_RTL</code> if the line is right-to-left.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL UBiDiDirection U_EXPORT2
|
||||
pl_getVisualRunDirection(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the number of glyphs in the visual run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the number of glyphs.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getVisualRunGlyphCount(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the glyphs in the visual run. Glyphs with the values <code>0xFFFE</code> and
|
||||
* <code>0xFFFF</code> should be ignored.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the address of the array of glyphs for this visual run. The storage
|
||||
* is owned by the <code>pl_visualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>pl_visualRun</code> object is valid.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const LEGlyphID * U_EXPORT2
|
||||
pl_getVisualRunGlyphs(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the (x, y) positions of the glyphs in the visual run. To simplify storage
|
||||
* management, the x and y positions are stored in a single array with the x positions
|
||||
* at even offsets in the array and the corresponding y position in the following odd offset.
|
||||
* There is an extra (x, y) pair at the end of the array which represents the advance of
|
||||
* the final glyph in the run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the address of the array of glyph positions for this visual run. The storage
|
||||
* is owned by the <code>pl_visualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>pl_visualRun</code> object is valid.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const float * U_EXPORT2
|
||||
pl_getVisualRunPositions(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* Get the glyph-to-character map for this visual run. This maps the indices into
|
||||
* the glyph array to indices into the character array used to create the paragraph.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the address of the character-to-glyph map for this visual run. The storage
|
||||
* is owned by the <code>pl_visualRun</code> object and must not be deleted.
|
||||
* It will remain valid as long as the <code>pl_visualRun</code> object is valid.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const le_int32 * U_EXPORT2
|
||||
pl_getVisualRunGlyphToCharMap(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* A convenience method which returns the ascent value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the ascent value of this run's font.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getVisualRunAscent(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* A convenience method which returns the descent value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the descent value of this run's font.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getVisualRunDescent(const pl_visualRun *run);
|
||||
|
||||
/**
|
||||
* A convenience method which returns the leading value for the font
|
||||
* associated with this run.
|
||||
*
|
||||
* @param run the <code>pl_visualRun</code> object.
|
||||
*
|
||||
* @return the leading value of this run's font.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getVisualRunLeading(const pl_visualRun *run);
|
||||
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
#endif
|
||||
#endif
|
||||
@ -1,441 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PLRUNS_H
|
||||
#define __PLRUNS_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
|
||||
#include "unicode/ubidi.h"
|
||||
#include "layout/LETypes.h"
|
||||
|
||||
#include "layout/loengine.h"
|
||||
|
||||
/**
|
||||
* Opaque datatype representing an array of font runs
|
||||
*/
|
||||
typedef void pl_fontRuns;
|
||||
/**
|
||||
* Opaque datatype representing an array of value runs
|
||||
*/
|
||||
typedef void pl_valueRuns;
|
||||
/**
|
||||
* Opaque datatype representing an array of locale runs
|
||||
*/
|
||||
typedef void pl_localeRuns;
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C API for run arrays.
|
||||
*
|
||||
* This is a technology preview. The API may
|
||||
* change significantly.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Construct a <code>pl_fontRuns</code> object from pre-existing arrays of fonts
|
||||
* and limit indices.
|
||||
*
|
||||
* @param fonts is the address of an array of pointers to <code>le_font</code> objects. This
|
||||
* array, and the <code>le_font</code> objects to which it points must remain
|
||||
* valid until the <code>pl_fontRuns</code> object is closed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>pl_fontRuns</code> object is closed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_fontRuns * U_EXPORT2
|
||||
pl_openFontRuns(const le_font **fonts,
|
||||
const le_int32 *limits,
|
||||
le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>pl_fontRuns</code> object. Clients can add font and limit
|
||||
* indices arrays using the <code>pl_addFontRun</code> routine.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the font and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see pl_addFontRun
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_fontRuns * U_EXPORT2
|
||||
pl_openEmptyFontRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* Close the given <code>pl_fontRuns</code> object. Once this
|
||||
* call returns, the object can no longer be referenced.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_closeFontRuns(pl_fontRuns *fontRuns);
|
||||
|
||||
/**
|
||||
* Get the number of font runs.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @return the number of entries in the limit indices array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getFontRunCount(const pl_fontRuns *fontRuns);
|
||||
|
||||
/**
|
||||
* Reset the number of font runs to zero.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_resetFontRuns(pl_fontRuns *fontRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for the last font run. This is the
|
||||
* number of characters in the text.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @return the last limit index.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getFontRunLastLimit(const pl_fontRuns *fontRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for a particular font run.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
* @param run is the run. This is an index into the limit index array.
|
||||
*
|
||||
* @return the limit index for the run, or -1 if <code>run</code> is out of bounds.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getFontRunLimit(const pl_fontRuns *fontRuns,
|
||||
le_int32 run);
|
||||
|
||||
/**
|
||||
* Get the <code>le_font</code> object assoicated with the given run
|
||||
* of text. Use <code>pl_getFontRunLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the <code>le_font</code> associated with the given text run.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const le_font * U_EXPORT2
|
||||
pl_getFontRunFont(const pl_fontRuns *fontRuns,
|
||||
le_int32 run);
|
||||
|
||||
|
||||
/**
|
||||
* Add a new font run to the given <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* If the <code>pl_fontRuns</code> object was not created by calling
|
||||
* <code>pl_openEmptyFontRuns</code>, this method will return a run index of -1.
|
||||
*
|
||||
* @param fontRuns is the <code>pl_fontRuns</code> object.
|
||||
*
|
||||
* @param font is the address of the <code>le_font</code> to add. This object must
|
||||
* remain valid until the <code>pl_fontRuns</code> object is closed.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the font and limit index were stored, or -1 if
|
||||
* the run cannot be added.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_addFontRun(pl_fontRuns *fontRuns,
|
||||
const le_font *font,
|
||||
le_int32 limit);
|
||||
|
||||
/**
|
||||
* Construct a <code>pl_valueRuns</code> object from pre-existing arrays of values
|
||||
* and limit indices.
|
||||
*
|
||||
* @param values is the address of an array of values. This array must remain valid until
|
||||
the <code>pl_valueRuns</code> object is closed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>pl_valueRuns</code> object is closed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_valueRuns * U_EXPORT2
|
||||
pl_openValueRuns(const le_int32 *values,
|
||||
const le_int32 *limits,
|
||||
le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>pl_valueRuns</code> object. Clients can add values and limits
|
||||
* using the <code>pl_addValueRun</code> routine.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the value and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see pl_addValueRun
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_valueRuns * U_EXPORT2
|
||||
pl_openEmptyValueRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* Close the given <code>pl_valueRuns</code> object. Once this
|
||||
* call returns, the object can no longer be referenced.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_closeValueRuns(pl_valueRuns *valueRuns);
|
||||
|
||||
/**
|
||||
* Get the number of value runs.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @return the number of value runs.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getValueRunCount(const pl_valueRuns *valueRuns);
|
||||
|
||||
/**
|
||||
* Reset the number of value runs to zero.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_resetValueRuns(pl_valueRuns *valueRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for the last value run. This is the
|
||||
* number of characters in the text.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @return the last limit index.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getValueRunLastLimit(const pl_valueRuns *valueRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for a particular value run.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
* @param run is the run index.
|
||||
*
|
||||
* @return the limit index for the run, or -1 if <code>run</code> is out of bounds.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getValueRunLimit(const pl_valueRuns *valueRuns,
|
||||
le_int32 run);
|
||||
|
||||
/**
|
||||
* Get the value assoicated with the given run * of text. Use
|
||||
* <code>pl_getValueRunLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
* @param run is the run index.
|
||||
*
|
||||
* @return the value associated with the given text run.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getValueRunValue(const pl_valueRuns *valueRuns,
|
||||
le_int32 run);
|
||||
|
||||
|
||||
/**
|
||||
* Add a new font run to the given <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* If the <code>pl_valueRuns</code> object was not created by calling
|
||||
* <code>pl_openEmptyFontRuns</code>, this method will return a run index of -1.
|
||||
*
|
||||
* @param valueRuns is the <code>pl_valueRuns</code> object.
|
||||
*
|
||||
* @param value is the value to add.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the font and limit index were stored, or -1 if
|
||||
* the run cannot be added.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_addValueRun(pl_valueRuns *valueRuns,
|
||||
le_int32 value,
|
||||
le_int32 limit);
|
||||
|
||||
/**
|
||||
* Construct a <code>pl_localeRuns</code> object from pre-existing arrays of fonts
|
||||
* and limit indices.
|
||||
*
|
||||
* @param locales is the address of an array of pointers to locale name strings. This
|
||||
* array must remain valid until the <code>pl_localeRuns</code> object is destroyed.
|
||||
*
|
||||
* @param limits is the address of an array of limit indices. This array must remain valid until
|
||||
* the <code>pl_valueRuns</code> object is destroyed.
|
||||
*
|
||||
* @param count is the number of entries in the two arrays.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_localeRuns * U_EXPORT2
|
||||
pl_openLocaleRuns(const char **locales,
|
||||
const le_int32 *limits,
|
||||
le_int32 count);
|
||||
|
||||
/**
|
||||
* Construct an empty <code>pl_localeRuns</code> object. Clients can add font and limit
|
||||
* indices arrays using the <code>pl_addFontRun</code> routine.
|
||||
*
|
||||
* @param initialCapacity is the initial size of the font and limit indices arrays. If
|
||||
* this value is zero, no arrays will be allocated.
|
||||
*
|
||||
* @see pl_addLocaleRun
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL pl_localeRuns * U_EXPORT2
|
||||
pl_openEmptyLocaleRuns(le_int32 initialCapacity);
|
||||
|
||||
/**
|
||||
* Close the given <code>pl_localeRuns</code> object. Once this
|
||||
* call returns, the object can no longer be referenced.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_closeLocaleRuns(pl_localeRuns *localeRuns);
|
||||
|
||||
/**
|
||||
* Get the number of font runs.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @return the number of entries in the limit indices array.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLocaleRunCount(const pl_localeRuns *localeRuns);
|
||||
|
||||
/**
|
||||
* Reset the number of locale runs to zero.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL void U_EXPORT2
|
||||
pl_resetLocaleRuns(pl_localeRuns *localeRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for the last font run. This is the
|
||||
* number of characters in the text.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @return the last limit index.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLocaleRunLastLimit(const pl_localeRuns *localeRuns);
|
||||
|
||||
/**
|
||||
* Get the limit index for a particular font run.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
* @param run is the run. This is an index into the limit index array.
|
||||
*
|
||||
* @return the limit index for the run, or -1 if <code>run</code> is out of bounds.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_getLocaleRunLimit(const pl_localeRuns *localeRuns,
|
||||
le_int32 run);
|
||||
|
||||
/**
|
||||
* Get the <code>le_font</code> object assoicated with the given run
|
||||
* of text. Use <code>pl_getLocaleRunLimit(run)</code> to get the corresponding
|
||||
* limit index.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
* @param run is the index into the font and limit indices arrays.
|
||||
*
|
||||
* @return the <code>le_font</code> associated with the given text run.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL const char * U_EXPORT2
|
||||
pl_getLocaleRunLocale(const pl_localeRuns *localeRuns,
|
||||
le_int32 run);
|
||||
|
||||
|
||||
/**
|
||||
* Add a new run to the given <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* If the <code>pl_localeRuns</code> object was not created by calling
|
||||
* <code>pl_openEmptyLocaleRuns</code>, this method will return a run index of -1.
|
||||
*
|
||||
* @param localeRuns is the <code>pl_localeRuns</code> object.
|
||||
*
|
||||
* @param locale is the name of the locale to add. This name must
|
||||
* remain valid until the <code>pl_localeRuns</code> object is closed.
|
||||
*
|
||||
* @param limit is the limit index to add
|
||||
*
|
||||
* @return the run index where the font and limit index were stored, or -1 if
|
||||
* the run cannot be added.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
U_INTERNAL le_int32 U_EXPORT2
|
||||
pl_addLocaleRun(pl_localeRuns *localeRuns,
|
||||
const char *locale,
|
||||
le_int32 limit);
|
||||
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
#endif
|
||||
@ -1,752 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2011-2014 International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef INDEXCHARS_H
|
||||
#define INDEXCHARS_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/locid.h"
|
||||
|
||||
#if !UCONFIG_NO_COLLATION
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Index Characters
|
||||
*/
|
||||
|
||||
U_CDECL_BEGIN
|
||||
|
||||
/**
|
||||
* Constants for Alphabetic Index Label Types.
|
||||
* The form of these enum constants anticipates having a plain C API
|
||||
* for Alphabetic Indexes that will also use them.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
typedef enum UAlphabeticIndexLabelType {
|
||||
/**
|
||||
* Normal Label, typically the starting letter of the names
|
||||
* in the bucket with this label.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
U_ALPHAINDEX_NORMAL = 0,
|
||||
|
||||
/**
|
||||
* Undeflow Label. The bucket with this label contains names
|
||||
* in scripts that sort before any of the bucket labels in this index.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
U_ALPHAINDEX_UNDERFLOW = 1,
|
||||
|
||||
/**
|
||||
* Inflow Label. The bucket with this label contains names
|
||||
* in scripts that sort between two of the bucket labels in this index.
|
||||
* Inflow labels are created when an index contains normal labels for
|
||||
* multiple scripts, and skips other scripts that sort between some of the
|
||||
* included scripts.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
U_ALPHAINDEX_INFLOW = 2,
|
||||
|
||||
/**
|
||||
* Overflow Label. Te bucket with this label contains names in scripts
|
||||
* that sort after all of the bucket labels in this index.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
U_ALPHAINDEX_OVERFLOW = 3
|
||||
} UAlphabeticIndexLabelType;
|
||||
|
||||
|
||||
struct UHashtable;
|
||||
U_CDECL_END
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// Forward Declarations
|
||||
|
||||
class BucketList;
|
||||
class Collator;
|
||||
class RuleBasedCollator;
|
||||
class StringEnumeration;
|
||||
class UnicodeSet;
|
||||
class UVector;
|
||||
|
||||
/**
|
||||
* AlphabeticIndex supports the creation of a UI index appropriate for a given language.
|
||||
* It can support either direct use, or use with a client that doesn't support localized collation.
|
||||
* The following is an example of what an index might look like in a UI:
|
||||
*
|
||||
* <pre>
|
||||
* <b>... A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ...</b>
|
||||
*
|
||||
* <b>A</b>
|
||||
* Addison
|
||||
* Albertson
|
||||
* Azensky
|
||||
* <b>B</b>
|
||||
* Baker
|
||||
* ...
|
||||
* </pre>
|
||||
*
|
||||
* The class can generate a list of labels for use as a UI "index", that is, a list of
|
||||
* clickable characters (or character sequences) that allow the user to see a segment
|
||||
* (bucket) of a larger "target" list. That is, each label corresponds to a bucket in
|
||||
* the target list, where everything in the bucket is greater than or equal to the character
|
||||
* (according to the locale's collation). Strings can be added to the index;
|
||||
* they will be in sorted order in the right bucket.
|
||||
* <p>
|
||||
* The class also supports having buckets for strings before the first (underflow),
|
||||
* after the last (overflow), and between scripts (inflow). For example, if the index
|
||||
* is constructed with labels for Russian and English, Greek characters would fall
|
||||
* into an inflow bucket between the other two scripts.
|
||||
* <p>
|
||||
* The AlphabeticIndex class is not intended for public subclassing.
|
||||
*
|
||||
* <p><em>Note:</em> If you expect to have a lot of ASCII or Latin characters
|
||||
* as well as characters from the user's language,
|
||||
* then it is a good idea to call addLabels(Locale::getEnglish(), status).</p>
|
||||
*
|
||||
* <h2>Direct Use</h2>
|
||||
* <p>The following shows an example of building an index directly.
|
||||
* The "show..." methods below are just to illustrate usage.
|
||||
*
|
||||
* <pre>
|
||||
* // Create a simple index. "Item" is assumed to be an application
|
||||
* // defined type that the application's UI and other processing knows about,
|
||||
* // and that has a name.
|
||||
*
|
||||
* UErrorCode status = U_ZERO_ERROR;
|
||||
* AlphabeticIndex index = new AlphabeticIndex(desiredLocale, status);
|
||||
* index->addLabels(additionalLocale, status);
|
||||
* for (Item *item in some source of Items ) {
|
||||
* index->addRecord(item->name(), item, status);
|
||||
* }
|
||||
* ...
|
||||
* // Show index at top. We could skip or gray out empty buckets
|
||||
*
|
||||
* while (index->nextBucket(status)) {
|
||||
* if (showAll || index->getBucketRecordCount() != 0) {
|
||||
* showLabelAtTop(UI, index->getBucketLabel());
|
||||
* }
|
||||
* }
|
||||
* ...
|
||||
* // Show the buckets with their contents, skipping empty buckets
|
||||
*
|
||||
* index->resetBucketIterator(status);
|
||||
* while (index->nextBucket(status)) {
|
||||
* if (index->getBucketRecordCount() != 0) {
|
||||
* showLabelInList(UI, index->getBucketLabel());
|
||||
* while (index->nextRecord(status)) {
|
||||
* showIndexedItem(UI, static_cast<Item *>(index->getRecordData()))
|
||||
* </pre>
|
||||
*
|
||||
* The caller can build different UIs using this class.
|
||||
* For example, an index character could be omitted or grayed-out
|
||||
* if its bucket is empty. Small buckets could also be combined based on size, such as:
|
||||
*
|
||||
* <pre>
|
||||
* <b>... A-F G-N O-Z ...</b>
|
||||
* </pre>
|
||||
*
|
||||
* <h2>Client Support</h2>
|
||||
* <p>Callers can also use the AlphabeticIndex::ImmutableIndex, or the AlphabeticIndex itself,
|
||||
* to support sorting on a client that doesn't support AlphabeticIndex functionality.
|
||||
*
|
||||
* <p>The ImmutableIndex is both immutable and thread-safe.
|
||||
* The corresponding AlphabeticIndex methods are not thread-safe because
|
||||
* they "lazily" build the index buckets.
|
||||
* <ul>
|
||||
* <li>ImmutableIndex.getBucket(index) provides random access to all
|
||||
* buckets and their labels and label types.
|
||||
* <li>The AlphabeticIndex bucket iterator or ImmutableIndex.getBucket(0..getBucketCount-1)
|
||||
* can be used to get a list of the labels,
|
||||
* such as "...", "A", "B",..., and send that list to the client.
|
||||
* <li>When the client has a new name, it sends that name to the server.
|
||||
* The server needs to call the following methods,
|
||||
* and communicate the bucketIndex and collationKey back to the client.
|
||||
*
|
||||
* <pre>
|
||||
* int32_t bucketIndex = index.getBucketIndex(name, status);
|
||||
* const UnicodeString &label = immutableIndex.getBucket(bucketIndex)->getLabel(); // optional
|
||||
* int32_t skLength = collator.getSortKey(name, sk, skCapacity);
|
||||
* </pre>
|
||||
*
|
||||
* <li>The client would put the name (and associated information) into its bucket for bucketIndex. The sort key sk is a
|
||||
* sequence of bytes that can be compared with a binary compare, and produce the right localized result.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
class U_I18N_API AlphabeticIndex: public UObject {
|
||||
public:
|
||||
/**
|
||||
* An index "bucket" with a label string and type.
|
||||
* It is referenced by getBucketIndex(),
|
||||
* and returned by ImmutableIndex.getBucket().
|
||||
*
|
||||
* The Bucket class is not intended for public subclassing.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
class U_I18N_API Bucket : public UObject {
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual ~Bucket();
|
||||
|
||||
/**
|
||||
* Returns the label string.
|
||||
*
|
||||
* @return the label string for the bucket
|
||||
* @stable ICU 51
|
||||
*/
|
||||
const UnicodeString &getLabel() const { return label_; }
|
||||
/**
|
||||
* Returns whether this bucket is a normal, underflow, overflow, or inflow bucket.
|
||||
*
|
||||
* @return the bucket label type
|
||||
* @stable ICU 51
|
||||
*/
|
||||
UAlphabeticIndexLabelType getLabelType() const { return labelType_; }
|
||||
|
||||
private:
|
||||
friend class AlphabeticIndex;
|
||||
friend class BucketList;
|
||||
|
||||
UnicodeString label_;
|
||||
UnicodeString lowerBoundary_;
|
||||
UAlphabeticIndexLabelType labelType_;
|
||||
Bucket *displayBucket_;
|
||||
int32_t displayIndex_;
|
||||
UVector *records_; // Records are owned by the inputList_ vector.
|
||||
|
||||
Bucket(const UnicodeString &label, // Parameter strings are copied.
|
||||
const UnicodeString &lowerBoundary,
|
||||
UAlphabeticIndexLabelType type);
|
||||
};
|
||||
|
||||
/**
|
||||
* Immutable, thread-safe version of AlphabeticIndex.
|
||||
* This class provides thread-safe methods for bucketing,
|
||||
* and random access to buckets and their properties,
|
||||
* but does not offer adding records to the index.
|
||||
*
|
||||
* The ImmutableIndex class is not intended for public subclassing.
|
||||
*
|
||||
* @stable ICU 51
|
||||
*/
|
||||
class U_I18N_API ImmutableIndex : public UObject {
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual ~ImmutableIndex();
|
||||
|
||||
/**
|
||||
* Returns the number of index buckets and labels, including underflow/inflow/overflow.
|
||||
*
|
||||
* @return the number of index buckets
|
||||
* @stable ICU 51
|
||||
*/
|
||||
int32_t getBucketCount() const;
|
||||
|
||||
/**
|
||||
* Finds the index bucket for the given name and returns the number of that bucket.
|
||||
* Use getBucket() to get the bucket's properties.
|
||||
*
|
||||
* @param name the string to be sorted into an index bucket
|
||||
* @return the bucket number for the name
|
||||
* @stable ICU 51
|
||||
*/
|
||||
int32_t getBucketIndex(const UnicodeString &name, UErrorCode &errorCode) const;
|
||||
|
||||
/**
|
||||
* Returns the index-th bucket. Returns NULL if the index is out of range.
|
||||
*
|
||||
* @param index bucket number
|
||||
* @return the index-th bucket
|
||||
* @stable ICU 51
|
||||
*/
|
||||
const Bucket *getBucket(int32_t index) const;
|
||||
|
||||
private:
|
||||
friend class AlphabeticIndex;
|
||||
|
||||
ImmutableIndex(BucketList *bucketList, Collator *collatorPrimaryOnly)
|
||||
: buckets_(bucketList), collatorPrimaryOnly_(collatorPrimaryOnly) {}
|
||||
|
||||
BucketList *buckets_;
|
||||
Collator *collatorPrimaryOnly_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct an AlphabeticIndex object for the specified locale. If the locale's
|
||||
* data does not include index characters, a set of them will be
|
||||
* synthesized based on the locale's exemplar characters. The locale
|
||||
* determines the sorting order for both the index characters and the
|
||||
* user item names appearing under each Index character.
|
||||
*
|
||||
* @param locale the desired locale.
|
||||
* @param status Error code, will be set with the reason if the construction
|
||||
* of the AlphabeticIndex object fails.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
AlphabeticIndex(const Locale &locale, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Construct an AlphabeticIndex that uses a specific collator.
|
||||
*
|
||||
* The index will be created with no labels; the addLabels() function must be called
|
||||
* after creation to add the desired labels to the index.
|
||||
*
|
||||
* The index adopts the collator, and is responsible for deleting it.
|
||||
* The caller should make no further use of the collator after creating the index.
|
||||
*
|
||||
* @param collator The collator to use to order the contents of this index.
|
||||
* @param status Error code, will be set with the reason if the
|
||||
* operation fails.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
AlphabeticIndex(RuleBasedCollator *collator, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Add Labels to this Index. The labels are additions to those
|
||||
* that are already in the index; they do not replace the existing
|
||||
* ones.
|
||||
* @param additions The additional characters to add to the index, such as A-Z.
|
||||
* @param status Error code, will be set with the reason if the
|
||||
* operation fails.
|
||||
* @return this, for chaining
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &addLabels(const UnicodeSet &additions, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Add the index characters from a Locale to the index. The labels
|
||||
* are added to those that are already in the index; they do not replace the
|
||||
* existing index characters. The collation order for this index is not
|
||||
* changed; it remains that of the locale that was originally specified
|
||||
* when creating this Index.
|
||||
*
|
||||
* @param locale The locale whose index characters are to be added.
|
||||
* @param status Error code, will be set with the reason if the
|
||||
* operation fails.
|
||||
* @return this, for chaining
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &addLabels(const Locale &locale, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual ~AlphabeticIndex();
|
||||
|
||||
/**
|
||||
* Builds an immutable, thread-safe version of this instance, without data records.
|
||||
*
|
||||
* @return an immutable index instance
|
||||
* @stable ICU 51
|
||||
*/
|
||||
ImmutableIndex *buildImmutableIndex(UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Get the Collator that establishes the ordering of the items in this index.
|
||||
* Ownership of the collator remains with the AlphabeticIndex instance.
|
||||
*
|
||||
* The returned collator is a reference to the internal collator used by this
|
||||
* index. It may be safely used to compare the names of items or to get
|
||||
* sort keys for names. However if any settings need to be changed,
|
||||
* or other non-const methods called, a cloned copy must be made first.
|
||||
*
|
||||
* @return The collator
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual const RuleBasedCollator &getCollator() const;
|
||||
|
||||
|
||||
/**
|
||||
* Get the default label used for abbreviated buckets <i>between</i> other index characters.
|
||||
* For example, consider the labels when Latin and Greek are used:
|
||||
* X Y Z ... Α Β Γ.
|
||||
*
|
||||
* @return inflow label
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual const UnicodeString &getInflowLabel() const;
|
||||
|
||||
/**
|
||||
* Set the default label used for abbreviated buckets <i>between</i> other index characters.
|
||||
* An inflow label will be automatically inserted if two otherwise-adjacent label characters
|
||||
* are from different scripts, e.g. Latin and Cyrillic, and a third script, e.g. Greek,
|
||||
* sorts between the two. The default inflow character is an ellipsis (...)
|
||||
*
|
||||
* @param inflowLabel the new Inflow label.
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* @return this
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &setInflowLabel(const UnicodeString &inflowLabel, UErrorCode &status);
|
||||
|
||||
|
||||
/**
|
||||
* Get the special label used for items that sort after the last normal label,
|
||||
* and that would not otherwise have an appropriate label.
|
||||
*
|
||||
* @return the overflow label
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual const UnicodeString &getOverflowLabel() const;
|
||||
|
||||
|
||||
/**
|
||||
* Set the label used for items that sort after the last normal label,
|
||||
* and that would not otherwise have an appropriate label.
|
||||
*
|
||||
* @param overflowLabel the new overflow label.
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* @return this
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &setOverflowLabel(const UnicodeString &overflowLabel, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Get the special label used for items that sort before the first normal label,
|
||||
* and that would not otherwise have an appropriate label.
|
||||
*
|
||||
* @return underflow label
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual const UnicodeString &getUnderflowLabel() const;
|
||||
|
||||
/**
|
||||
* Set the label used for items that sort before the first normal label,
|
||||
* and that would not otherwise have an appropriate label.
|
||||
*
|
||||
* @param underflowLabel the new underflow label.
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* @return this
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &setUnderflowLabel(const UnicodeString &underflowLabel, UErrorCode &status);
|
||||
|
||||
|
||||
/**
|
||||
* Get the limit on the number of labels permitted in the index.
|
||||
* The number does not include over, under and inflow labels.
|
||||
*
|
||||
* @return maxLabelCount maximum number of labels.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual int32_t getMaxLabelCount() const;
|
||||
|
||||
/**
|
||||
* Set a limit on the number of labels permitted in the index.
|
||||
* The number does not include over, under and inflow labels.
|
||||
* Currently, if the number is exceeded, then every
|
||||
* nth item is removed to bring the count down.
|
||||
* A more sophisticated mechanism may be available in the future.
|
||||
*
|
||||
* @param maxLabelCount the maximum number of labels.
|
||||
* @param status error code
|
||||
* @return This, for chaining
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &setMaxLabelCount(int32_t maxLabelCount, UErrorCode &status);
|
||||
|
||||
|
||||
/**
|
||||
* Add a record to the index. Each record will be associated with an index Bucket
|
||||
* based on the record's name. The list of records for each bucket will be sorted
|
||||
* based on the collation ordering of the names in the index's locale.
|
||||
* Records with duplicate names are permitted; they will be kept in the order
|
||||
* that they were added.
|
||||
*
|
||||
* @param name The display name for the Record. The Record will be placed in
|
||||
* a bucket based on this name.
|
||||
* @param data An optional pointer to user data associated with this
|
||||
* item. When iterating the contents of a bucket, both the
|
||||
* data pointer the name will be available for each Record.
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* @return This, for chaining.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &addRecord(const UnicodeString &name, const void *data, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Remove all Records from the Index. The set of Buckets, which define the headings under
|
||||
* which records are classified, is not altered.
|
||||
*
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* @return This, for chaining.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &clearRecords(UErrorCode &status);
|
||||
|
||||
|
||||
/** Get the number of labels in this index.
|
||||
* Note: may trigger lazy index construction.
|
||||
*
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* @return The number of labels in this index, including any under, over or
|
||||
* in-flow labels.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual int32_t getBucketCount(UErrorCode &status);
|
||||
|
||||
|
||||
/** Get the total number of Records in this index, that is, the number
|
||||
* of <name, data> pairs added.
|
||||
*
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* @return The number of records in this index, that is, the total number
|
||||
* of (name, data) items added with addRecord().
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual int32_t getRecordCount(UErrorCode &status);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Given the name of a record, return the zero-based index of the Bucket
|
||||
* in which the item should appear. The name need not be in the index.
|
||||
* A Record will not be added to the index by this function.
|
||||
* Bucket numbers are zero-based, in Bucket iteration order.
|
||||
*
|
||||
* @param itemName The name whose bucket position in the index is to be determined.
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* @return The bucket number for this name.
|
||||
* @stable ICU 4.8
|
||||
*
|
||||
*/
|
||||
virtual int32_t getBucketIndex(const UnicodeString &itemName, UErrorCode &status);
|
||||
|
||||
|
||||
/**
|
||||
* Get the zero based index of the current Bucket from an iteration
|
||||
* over the Buckets of this index. Return -1 if no iteration is in process.
|
||||
* @return the index of the current Bucket
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual int32_t getBucketIndex() const;
|
||||
|
||||
|
||||
/**
|
||||
* Advance the iteration over the Buckets of this index. Return FALSE if
|
||||
* there are no more Buckets.
|
||||
*
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* U_ENUM_OUT_OF_SYNC_ERROR will be reported if the index is modified while
|
||||
* an enumeration of its contents are in process.
|
||||
*
|
||||
* @return TRUE if success, FALSE if at end of iteration
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool nextBucket(UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Return the name of the Label of the current bucket from an iteration over the buckets.
|
||||
* If the iteration is before the first Bucket (nextBucket() has not been called),
|
||||
* or after the last, return an empty string.
|
||||
*
|
||||
* @return the bucket label.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual const UnicodeString &getBucketLabel() const;
|
||||
|
||||
/**
|
||||
* Return the type of the label for the current Bucket (selected by the
|
||||
* iteration over Buckets.)
|
||||
*
|
||||
* @return the label type.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UAlphabeticIndexLabelType getBucketLabelType() const;
|
||||
|
||||
/**
|
||||
* Get the number of <name, data> Records in the current Bucket.
|
||||
* If the current bucket iteration position is before the first label or after the
|
||||
* last, return 0.
|
||||
*
|
||||
* @return the number of Records.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual int32_t getBucketRecordCount() const;
|
||||
|
||||
|
||||
/**
|
||||
* Reset the Bucket iteration for this index. The next call to nextBucket()
|
||||
* will restart the iteration at the first label.
|
||||
*
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* @return this, for chaining.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &resetBucketIterator(UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Advance to the next record in the current Bucket.
|
||||
* When nextBucket() is called, Record iteration is reset to just before the
|
||||
* first Record in the new Bucket.
|
||||
*
|
||||
* @param status Error code, will be set with the reason if the operation fails.
|
||||
* U_ENUM_OUT_OF_SYNC_ERROR will be reported if the index is modified while
|
||||
* an enumeration of its contents are in process.
|
||||
* @return TRUE if successful, FALSE when the iteration advances past the last item.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool nextRecord(UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Get the name of the current Record.
|
||||
* Return an empty string if the Record iteration position is before first
|
||||
* or after the last.
|
||||
*
|
||||
* @return The name of the current index item.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual const UnicodeString &getRecordName() const;
|
||||
|
||||
|
||||
/**
|
||||
* Return the data pointer of the Record currently being iterated over.
|
||||
* Return NULL if the current iteration position before the first item in this Bucket,
|
||||
* or after the last.
|
||||
*
|
||||
* @return The current Record's data pointer.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual const void *getRecordData() const;
|
||||
|
||||
|
||||
/**
|
||||
* Reset the Record iterator position to before the first Record in the current Bucket.
|
||||
*
|
||||
* @return This, for chaining.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual AlphabeticIndex &resetRecordIterator();
|
||||
|
||||
private:
|
||||
/**
|
||||
* No Copy constructor.
|
||||
* @internal
|
||||
*/
|
||||
AlphabeticIndex(const AlphabeticIndex &other);
|
||||
|
||||
/**
|
||||
* No assignment.
|
||||
*/
|
||||
AlphabeticIndex &operator =(const AlphabeticIndex & /*other*/) { return *this;};
|
||||
|
||||
/**
|
||||
* No Equality operators.
|
||||
* @internal
|
||||
*/
|
||||
virtual UBool operator==(const AlphabeticIndex& other) const;
|
||||
|
||||
/**
|
||||
* Inequality operator.
|
||||
* @internal
|
||||
*/
|
||||
virtual UBool operator!=(const AlphabeticIndex& other) const;
|
||||
|
||||
// Common initialization, for use from all constructors.
|
||||
void init(const Locale *locale, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* This method is called to get the index exemplars. Normally these come from the locale directly,
|
||||
* but if they aren't available, we have to synthesize them.
|
||||
*/
|
||||
void addIndexExemplars(const Locale &locale, UErrorCode &status);
|
||||
/**
|
||||
* Add Chinese index characters from the tailoring.
|
||||
*/
|
||||
UBool addChineseIndexCharacters(UErrorCode &errorCode);
|
||||
|
||||
UVector *firstStringsInScript(UErrorCode &status);
|
||||
|
||||
static UnicodeString separated(const UnicodeString &item);
|
||||
|
||||
/**
|
||||
* Determine the best labels to use.
|
||||
* This is based on the exemplars, but we also process to make sure that they are unique,
|
||||
* and sort differently, and that the overall list is small enough.
|
||||
*/
|
||||
void initLabels(UVector &indexCharacters, UErrorCode &errorCode) const;
|
||||
BucketList *createBucketList(UErrorCode &errorCode) const;
|
||||
void initBuckets(UErrorCode &errorCode);
|
||||
void clearBuckets();
|
||||
void internalResetBucketIterator();
|
||||
|
||||
public:
|
||||
|
||||
// The Record is declared public only to allow access from
|
||||
// implementation code written in plain C.
|
||||
// It is not intended for public use.
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* A (name, data) pair, to be sorted by name into one of the index buckets.
|
||||
* The user data is not used by the index implementation.
|
||||
* @internal
|
||||
*/
|
||||
struct Record: public UMemory {
|
||||
const UnicodeString name_;
|
||||
const void *data_;
|
||||
Record(const UnicodeString &name, const void *data);
|
||||
~Record();
|
||||
};
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Holds all user records before they are distributed into buckets.
|
||||
* Type of contents is (Record *)
|
||||
* @internal
|
||||
*/
|
||||
UVector *inputList_;
|
||||
|
||||
int32_t labelsIterIndex_; // Index of next item to return.
|
||||
int32_t itemsIterIndex_;
|
||||
Bucket *currentBucket_; // While an iteration of the index in underway,
|
||||
// point to the bucket for the current label.
|
||||
// NULL when no iteration underway.
|
||||
|
||||
int32_t maxLabelCount_; // Limit on # of labels permitted in the index.
|
||||
|
||||
UnicodeSet *initialLabels_; // Initial (unprocessed) set of Labels. Union
|
||||
// of those explicitly set by the user plus
|
||||
// those from locales. Raw values, before
|
||||
// crunching into bucket labels.
|
||||
|
||||
UVector *firstCharsInScripts_; // The first character from each script,
|
||||
// in collation order.
|
||||
|
||||
RuleBasedCollator *collator_;
|
||||
RuleBasedCollator *collatorPrimaryOnly_;
|
||||
|
||||
// Lazy evaluated: null means that we have not built yet.
|
||||
BucketList *buckets_;
|
||||
|
||||
UnicodeString inflowLabel_;
|
||||
UnicodeString overflowLabel_;
|
||||
UnicodeString underflowLabel_;
|
||||
UnicodeString overflowComparisonString_;
|
||||
|
||||
UnicodeString emptyString_;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // !UCONFIG_NO_COLLATION
|
||||
#endif
|
||||
@ -1,232 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011-2012, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: appendable.h
|
||||
* encoding: US-ASCII
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2010dec07
|
||||
* created by: Markus W. Scherer
|
||||
*/
|
||||
|
||||
#ifndef __APPENDABLE_H__
|
||||
#define __APPENDABLE_H__
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (UChars).
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uobject.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class UnicodeString;
|
||||
|
||||
/**
|
||||
* Base class for objects to which Unicode characters and strings can be appended.
|
||||
* Combines elements of Java Appendable and ICU4C ByteSink.
|
||||
*
|
||||
* This class can be used in APIs where it does not matter whether the actual destination is
|
||||
* a UnicodeString, a UChar[] array, a UnicodeSet, or any other object
|
||||
* that receives and processes characters and/or strings.
|
||||
*
|
||||
* Implementation classes must implement at least appendCodeUnit(UChar).
|
||||
* The base class provides default implementations for the other methods.
|
||||
*
|
||||
* The methods do not take UErrorCode parameters.
|
||||
* If an error occurs (e.g., out-of-memory),
|
||||
* in addition to returning FALSE from failing operations,
|
||||
* the implementation must prevent unexpected behavior (e.g., crashes)
|
||||
* from further calls and should make the error condition available separately
|
||||
* (e.g., store a UErrorCode, make/keep a UnicodeString bogus).
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
class U_COMMON_API Appendable : public UObject {
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
~Appendable();
|
||||
|
||||
/**
|
||||
* Appends a 16-bit code unit.
|
||||
* @param c code unit
|
||||
* @return TRUE if the operation succeeded
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool appendCodeUnit(UChar c) = 0;
|
||||
|
||||
/**
|
||||
* Appends a code point.
|
||||
* The default implementation calls appendCodeUnit(UChar) once or twice.
|
||||
* @param c code point 0..0x10ffff
|
||||
* @return TRUE if the operation succeeded
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool appendCodePoint(UChar32 c);
|
||||
|
||||
/**
|
||||
* Appends a string.
|
||||
* The default implementation calls appendCodeUnit(UChar) for each code unit.
|
||||
* @param s string, must not be NULL if length!=0
|
||||
* @param length string length, or -1 if NUL-terminated
|
||||
* @return TRUE if the operation succeeded
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool appendString(const UChar *s, int32_t length);
|
||||
|
||||
/**
|
||||
* Tells the object that the caller is going to append roughly
|
||||
* appendCapacity UChars. A subclass might use this to pre-allocate
|
||||
* a larger buffer if necessary.
|
||||
* The default implementation does nothing. (It always returns TRUE.)
|
||||
* @param appendCapacity estimated number of UChars that will be appended
|
||||
* @return TRUE if the operation succeeded
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool reserveAppendCapacity(int32_t appendCapacity);
|
||||
|
||||
/**
|
||||
* Returns a writable buffer for appending and writes the buffer's capacity to
|
||||
* *resultCapacity. Guarantees *resultCapacity>=minCapacity.
|
||||
* May return a pointer to the caller-owned scratch buffer which must have
|
||||
* scratchCapacity>=minCapacity.
|
||||
* The returned buffer is only valid until the next operation
|
||||
* on this Appendable.
|
||||
*
|
||||
* After writing at most *resultCapacity UChars, call appendString() with the
|
||||
* pointer returned from this function and the number of UChars written.
|
||||
* Many appendString() implementations will avoid copying UChars if this function
|
||||
* returned an internal buffer.
|
||||
*
|
||||
* Partial usage example:
|
||||
* \code
|
||||
* int32_t capacity;
|
||||
* UChar* buffer = app.getAppendBuffer(..., &capacity);
|
||||
* ... Write n UChars into buffer, with n <= capacity.
|
||||
* app.appendString(buffer, n);
|
||||
* \endcode
|
||||
* In many implementations, that call to append will avoid copying UChars.
|
||||
*
|
||||
* If the Appendable allocates or reallocates an internal buffer, it should use
|
||||
* the desiredCapacityHint if appropriate.
|
||||
* If a caller cannot provide a reasonable guess at the desired capacity,
|
||||
* it should pass desiredCapacityHint=0.
|
||||
*
|
||||
* If a non-scratch buffer is returned, the caller may only pass
|
||||
* a prefix to it to appendString().
|
||||
* That is, it is not correct to pass an interior pointer to appendString().
|
||||
*
|
||||
* The default implementation always returns the scratch buffer.
|
||||
*
|
||||
* @param minCapacity required minimum capacity of the returned buffer;
|
||||
* must be non-negative
|
||||
* @param desiredCapacityHint desired capacity of the returned buffer;
|
||||
* must be non-negative
|
||||
* @param scratch default caller-owned buffer
|
||||
* @param scratchCapacity capacity of the scratch buffer
|
||||
* @param resultCapacity pointer to an integer which will be set to the
|
||||
* capacity of the returned buffer
|
||||
* @return a buffer with *resultCapacity>=minCapacity
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UChar *getAppendBuffer(int32_t minCapacity,
|
||||
int32_t desiredCapacityHint,
|
||||
UChar *scratch, int32_t scratchCapacity,
|
||||
int32_t *resultCapacity);
|
||||
};
|
||||
|
||||
/**
|
||||
* An Appendable implementation which writes to a UnicodeString.
|
||||
*
|
||||
* This class is not intended for public subclassing.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
class U_COMMON_API UnicodeStringAppendable : public Appendable {
|
||||
public:
|
||||
/**
|
||||
* Aliases the UnicodeString (keeps its reference) for writing.
|
||||
* @param s The UnicodeString to which this Appendable will write.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
explicit UnicodeStringAppendable(UnicodeString &s) : str(s) {}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
~UnicodeStringAppendable();
|
||||
|
||||
/**
|
||||
* Appends a 16-bit code unit to the string.
|
||||
* @param c code unit
|
||||
* @return TRUE if the operation succeeded
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool appendCodeUnit(UChar c);
|
||||
|
||||
/**
|
||||
* Appends a code point to the string.
|
||||
* @param c code point 0..0x10ffff
|
||||
* @return TRUE if the operation succeeded
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool appendCodePoint(UChar32 c);
|
||||
|
||||
/**
|
||||
* Appends a string to the UnicodeString.
|
||||
* @param s string, must not be NULL if length!=0
|
||||
* @param length string length, or -1 if NUL-terminated
|
||||
* @return TRUE if the operation succeeded
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool appendString(const UChar *s, int32_t length);
|
||||
|
||||
/**
|
||||
* Tells the UnicodeString that the caller is going to append roughly
|
||||
* appendCapacity UChars.
|
||||
* @param appendCapacity estimated number of UChars that will be appended
|
||||
* @return TRUE if the operation succeeded
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UBool reserveAppendCapacity(int32_t appendCapacity);
|
||||
|
||||
/**
|
||||
* Returns a writable buffer for appending and writes the buffer's capacity to
|
||||
* *resultCapacity. Guarantees *resultCapacity>=minCapacity.
|
||||
* May return a pointer to the caller-owned scratch buffer which must have
|
||||
* scratchCapacity>=minCapacity.
|
||||
* The returned buffer is only valid until the next write operation
|
||||
* on the UnicodeString.
|
||||
*
|
||||
* For details see Appendable::getAppendBuffer().
|
||||
*
|
||||
* @param minCapacity required minimum capacity of the returned buffer;
|
||||
* must be non-negative
|
||||
* @param desiredCapacityHint desired capacity of the returned buffer;
|
||||
* must be non-negative
|
||||
* @param scratch default caller-owned buffer
|
||||
* @param scratchCapacity capacity of the scratch buffer
|
||||
* @param resultCapacity pointer to an integer which will be set to the
|
||||
* capacity of the returned buffer
|
||||
* @return a buffer with *resultCapacity>=minCapacity
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual UChar *getAppendBuffer(int32_t minCapacity,
|
||||
int32_t desiredCapacityHint,
|
||||
UChar *scratch, int32_t scratchCapacity,
|
||||
int32_t *resultCapacity);
|
||||
|
||||
private:
|
||||
UnicodeString &str;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // __APPENDABLE_H__
|
||||
@ -1,214 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007-2013, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef BASICTZ_H
|
||||
#define BASICTZ_H
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: ICU TimeZone base class
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/timezone.h"
|
||||
#include "unicode/tzrule.h"
|
||||
#include "unicode/tztrans.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// forward declarations
|
||||
class UVector;
|
||||
|
||||
/**
|
||||
* <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>.
|
||||
* This class provides some additional methods to access time zone transitions and rules.
|
||||
* All ICU <code>TimeZone</code> concrete subclasses extend this class.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
class U_I18N_API BasicTimeZone: public TimeZone {
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual ~BasicTimeZone();
|
||||
|
||||
/**
|
||||
* Gets the first time zone transition after the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the first transition after the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the most recent time zone transition before the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the most recent transition before the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0;
|
||||
|
||||
/**
|
||||
* Checks if the time zone has equivalent transitions in the time range.
|
||||
* This method returns true when all of transition times, from/to standard
|
||||
* offsets and DST savings used by this time zone match the other in the
|
||||
* time range.
|
||||
* @param tz The <code>BasicTimeZone</code> object to be compared with.
|
||||
* @param start The start time of the evaluated time range (inclusive)
|
||||
* @param end The end time of the evaluated time range (inclusive)
|
||||
* @param ignoreDstAmount
|
||||
* When true, any transitions with only daylight saving amount
|
||||
* changes will be ignored, except either of them is zero.
|
||||
* For example, a transition from rawoffset 3:00/dstsavings 1:00
|
||||
* to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison,
|
||||
* but a transtion from rawoffset 2:00/dstsavings 1:00 to
|
||||
* rawoffset 3:00/dstsavings 0:00 is included.
|
||||
* @param ec Output param to filled in with a success or an error.
|
||||
* @return true if the other time zone has the equivalent transitions in the
|
||||
* time range.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual UBool hasEquivalentTransitions(const BasicTimeZone& tz, UDate start, UDate end,
|
||||
UBool ignoreDstAmount, UErrorCode& ec) const;
|
||||
|
||||
/**
|
||||
* Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
|
||||
* for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
|
||||
* <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
|
||||
* @param status Receives error status code.
|
||||
* @return The number of <code>TimeZoneRule</code>s representing time transitions.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual int32_t countTransitionRules(UErrorCode& status) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
|
||||
* which represent time transitions for this time zone. On successful return,
|
||||
* the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
|
||||
* the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
|
||||
* instances up to the size specified by trscount. The results are referencing the
|
||||
* rule instance held by this time zone instance. Therefore, after this time zone
|
||||
* is destructed, they are no longer available.
|
||||
* @param initial Receives the initial timezone rule
|
||||
* @param trsrules Receives the timezone transition rules
|
||||
* @param trscount On input, specify the size of the array 'transitions' receiving
|
||||
* the timezone transition rules. On output, actual number of
|
||||
* rules filled in the array will be set.
|
||||
* @param status Receives error status code.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
|
||||
const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the set of time zone rules valid at the specified time. Some known external time zone
|
||||
* implementations are not capable to handle historic time zone rule changes. Also some
|
||||
* implementations can only handle certain type of rule definitions.
|
||||
* If this time zone does not use any daylight saving time within about 1 year from the specified
|
||||
* time, only the <code>InitialTimeZone</code> is returned. Otherwise, the rule for standard
|
||||
* time and daylight saving time transitions are returned in addition to the
|
||||
* <code>InitialTimeZoneRule</code>. The standard and daylight saving time transition rules are
|
||||
* represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date
|
||||
* rule and <code>DateTimeRule::WALL_TIME</code> for its time rule. Because daylight saving time
|
||||
* rule is changing time to time in many time zones and also mapping a transition time rule to
|
||||
* different type is lossy transformation, the set of rules returned by this method may be valid
|
||||
* for short period of time.
|
||||
* The time zone rule objects returned by this method is owned by the caller, so the caller is
|
||||
* responsible for deleting them after use.
|
||||
* @param date The date used for extracting time zone rules.
|
||||
* @param initial Receives the <code>InitialTimeZone</code>, always not NULL.
|
||||
* @param std Receives the <code>AnnualTimeZoneRule</code> for standard time transitions.
|
||||
* When this time time zone does not observe daylight saving times around the
|
||||
* specified date, NULL is set.
|
||||
* @param dst Receives the <code>AnnualTimeZoneRule</code> for daylight saving time
|
||||
* transitions. When this time zone does not observer daylight saving times
|
||||
* around the specified date, NULL is set.
|
||||
* @param status Receives error status code.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
|
||||
AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) const;
|
||||
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* The time type option bit flags used by getOffsetFromLocal
|
||||
* @internal
|
||||
*/
|
||||
enum {
|
||||
kStandard = 0x01,
|
||||
kDaylight = 0x03,
|
||||
kFormer = 0x04,
|
||||
kLatter = 0x0C
|
||||
};
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* Get time zone offsets from local wall time.
|
||||
* @internal
|
||||
*/
|
||||
virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt,
|
||||
int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const;
|
||||
|
||||
protected:
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* The time type option bit masks used by getOffsetFromLocal
|
||||
* @internal
|
||||
*/
|
||||
enum {
|
||||
kStdDstMask = kDaylight,
|
||||
kFormerLatterMask = kLatter
|
||||
};
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
BasicTimeZone();
|
||||
|
||||
/**
|
||||
* Construct a timezone with a given ID.
|
||||
* @param id a system time zone ID
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
BasicTimeZone(const UnicodeString &id);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source the object to be copied.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
BasicTimeZone(const BasicTimeZone& source);
|
||||
|
||||
/**
|
||||
* Gets the set of TimeZoneRule instances applicable to the specified time and after.
|
||||
* @param start The start date used for extracting time zone rules
|
||||
* @param initial Receives the InitialTimeZone, always not NULL
|
||||
* @param transitionRules Receives the transition rules, could be NULL
|
||||
* @param status Receives error status code
|
||||
*/
|
||||
void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules,
|
||||
UErrorCode& status) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // BASICTZ_H
|
||||
|
||||
//eof
|
||||
@ -1,655 +0,0 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
* File brkiter.h
|
||||
*
|
||||
* Modification History:
|
||||
*
|
||||
* Date Name Description
|
||||
* 02/18/97 aliu Added typedef for TextCount. Made DONE const.
|
||||
* 05/07/97 aliu Fixed DLL declaration.
|
||||
* 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK
|
||||
* 08/11/98 helena Sync-up JDK1.2.
|
||||
* 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods.
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef BRKITER_H
|
||||
#define BRKITER_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Break Iterator.
|
||||
*/
|
||||
|
||||
#if UCONFIG_NO_BREAK_ITERATION
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/*
|
||||
* Allow the declaration of APIs with pointers to BreakIterator
|
||||
* even when break iteration is removed from the build.
|
||||
*/
|
||||
class BreakIterator;
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#else
|
||||
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/chariter.h"
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/ubrk.h"
|
||||
#include "unicode/strenum.h"
|
||||
#include "unicode/utext.h"
|
||||
#include "unicode/umisc.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* The BreakIterator class implements methods for finding the location
|
||||
* of boundaries in text. BreakIterator is an abstract base class.
|
||||
* Instances of BreakIterator maintain a current position and scan over
|
||||
* text returning the index of characters where boundaries occur.
|
||||
* <p>
|
||||
* Line boundary analysis determines where a text string can be broken
|
||||
* when line-wrapping. The mechanism correctly handles punctuation and
|
||||
* hyphenated words.
|
||||
* <p>
|
||||
* Sentence boundary analysis allows selection with correct
|
||||
* interpretation of periods within numbers and abbreviations, and
|
||||
* trailing punctuation marks such as quotation marks and parentheses.
|
||||
* <p>
|
||||
* Word boundary analysis is used by search and replace functions, as
|
||||
* well as within text editing applications that allow the user to
|
||||
* select words with a double click. Word selection provides correct
|
||||
* interpretation of punctuation marks within and following
|
||||
* words. Characters that are not part of a word, such as symbols or
|
||||
* punctuation marks, have word-breaks on both sides.
|
||||
* <p>
|
||||
* Character boundary analysis allows users to interact with
|
||||
* characters as they expect to, for example, when moving the cursor
|
||||
* through a text string. Character boundary analysis provides correct
|
||||
* navigation of through character strings, regardless of how the
|
||||
* character is stored. For example, an accented character might be
|
||||
* stored as a base character and a diacritical mark. What users
|
||||
* consider to be a character can differ between languages.
|
||||
* <p>
|
||||
* The text boundary positions are found according to the rules
|
||||
* described in Unicode Standard Annex #29, Text Boundaries, and
|
||||
* Unicode Standard Annex #14, Line Breaking Properties. These
|
||||
* are available at http://www.unicode.org/reports/tr14/ and
|
||||
* http://www.unicode.org/reports/tr29/.
|
||||
* <p>
|
||||
* In addition to the C++ API defined in this header file, a
|
||||
* plain C API with equivalent functionality is defined in the
|
||||
* file ubrk.h
|
||||
* <p>
|
||||
* Code snippets illustrating the use of the Break Iterator APIs
|
||||
* are available in the ICU User Guide,
|
||||
* http://icu-project.org/userguide/boundaryAnalysis.html
|
||||
* and in the sample program icu/source/samples/break/break.cpp
|
||||
*
|
||||
*/
|
||||
class U_COMMON_API BreakIterator : public UObject {
|
||||
public:
|
||||
/**
|
||||
* destructor
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual ~BreakIterator();
|
||||
|
||||
/**
|
||||
* Return true if another object is semantically equal to this
|
||||
* one. The other object should be an instance of the same subclass of
|
||||
* BreakIterator. Objects of different subclasses are considered
|
||||
* unequal.
|
||||
* <P>
|
||||
* Return true if this BreakIterator is at the same position in the
|
||||
* same text, and is the same class and type (word, line, etc.) of
|
||||
* BreakIterator, as the argument. Text is considered the same if
|
||||
* it contains the same characters, it need not be the same
|
||||
* object, and styles are not considered.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool operator==(const BreakIterator&) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the complement of the result of operator==
|
||||
* @param rhs The BreakIterator to be compared for inequality
|
||||
* @return the complement of the result of operator==
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
|
||||
|
||||
/**
|
||||
* Return a polymorphic copy of this object. This is an abstract
|
||||
* method which subclasses implement.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual BreakIterator* clone(void) const = 0;
|
||||
|
||||
/**
|
||||
* Return a polymorphic class ID for this object. Different subclasses
|
||||
* will return distinct unequal values.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const = 0;
|
||||
|
||||
/**
|
||||
* Return a CharacterIterator over the text being analyzed.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual CharacterIterator& getText(void) const = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get a UText for the text being analyzed.
|
||||
* The returned UText is a shallow clone of the UText used internally
|
||||
* by the break iterator implementation. It can safely be used to
|
||||
* access the text without impacting any break iterator operations,
|
||||
* but the underlying text itself must not be altered.
|
||||
*
|
||||
* @param fillIn A UText to be filled in. If NULL, a new UText will be
|
||||
* allocated to hold the result.
|
||||
* @param status receives any error codes.
|
||||
* @return The current UText for this break iterator. If an input
|
||||
* UText was provided, it will always be returned.
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
|
||||
|
||||
/**
|
||||
* Change the text over which this operates. The text boundary is
|
||||
* reset to the start.
|
||||
* @param text The UnicodeString used to change the text.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void setText(const UnicodeString &text) = 0;
|
||||
|
||||
/**
|
||||
* Reset the break iterator to operate over the text represented by
|
||||
* the UText. The iterator position is reset to the start.
|
||||
*
|
||||
* This function makes a shallow clone of the supplied UText. This means
|
||||
* that the caller is free to immediately close or otherwise reuse the
|
||||
* Utext that was passed as a parameter, but that the underlying text itself
|
||||
* must not be altered while being referenced by the break iterator.
|
||||
*
|
||||
* All index positions returned by break iterator functions are
|
||||
* native indices from the UText. For example, when breaking UTF-8
|
||||
* encoded text, the break positions returned by next(), previous(), etc.
|
||||
* will be UTF-8 string indices, not UTF-16 positions.
|
||||
*
|
||||
* @param text The UText used to change the text.
|
||||
* @param status receives any error codes.
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
virtual void setText(UText *text, UErrorCode &status) = 0;
|
||||
|
||||
/**
|
||||
* Change the text over which this operates. The text boundary is
|
||||
* reset to the start.
|
||||
* Note that setText(UText *) provides similar functionality to this function,
|
||||
* and is more efficient.
|
||||
* @param it The CharacterIterator used to change the text.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void adoptText(CharacterIterator* it) = 0;
|
||||
|
||||
enum {
|
||||
/**
|
||||
* DONE is returned by previous() and next() after all valid
|
||||
* boundaries have been returned.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DONE = (int32_t)-1
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the current iteration position to the beginning of the text, position zero.
|
||||
* @return The offset of the beginning of the text, zero.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t first(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the iterator position to the index immediately BEYOND the last character in the text being scanned.
|
||||
* @return The index immediately BEYOND the last character in the text being scanned.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t last(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the iterator position to the boundary preceding the current boundary.
|
||||
* @return The character index of the previous text boundary or DONE if all
|
||||
* boundaries have been returned.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t previous(void) = 0;
|
||||
|
||||
/**
|
||||
* Advance the iterator to the boundary following the current boundary.
|
||||
* @return The character index of the next text boundary or DONE if all
|
||||
* boundaries have been returned.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t next(void) = 0;
|
||||
|
||||
/**
|
||||
* Return character index of the current interator position within the text.
|
||||
* @return The boundary most recently returned.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t current(void) const = 0;
|
||||
|
||||
/**
|
||||
* Advance the iterator to the first boundary following the specified offset.
|
||||
* The value returned is always greater than the offset or
|
||||
* the value BreakIterator.DONE
|
||||
* @param offset the offset to begin scanning.
|
||||
* @return The first boundary after the specified offset.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t following(int32_t offset) = 0;
|
||||
|
||||
/**
|
||||
* Set the iterator position to the first boundary preceding the specified offset.
|
||||
* The value returned is always smaller than the offset or
|
||||
* the value BreakIterator.DONE
|
||||
* @param offset the offset to begin scanning.
|
||||
* @return The first boundary before the specified offset.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t preceding(int32_t offset) = 0;
|
||||
|
||||
/**
|
||||
* Return true if the specfied position is a boundary position.
|
||||
* As a side effect, the current position of the iterator is set
|
||||
* to the first boundary position at or following the specified offset.
|
||||
* @param offset the offset to check.
|
||||
* @return True if "offset" is a boundary position.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool isBoundary(int32_t offset) = 0;
|
||||
|
||||
/**
|
||||
* Set the iterator position to the nth boundary from the current boundary
|
||||
* @param n the number of boundaries to move by. A value of 0
|
||||
* does nothing. Negative values move to previous boundaries
|
||||
* and positive values move to later boundaries.
|
||||
* @return The new iterator position, or
|
||||
* DONE if there are fewer than |n| boundaries in the specfied direction.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t next(int32_t n) = 0;
|
||||
|
||||
/**
|
||||
* For RuleBasedBreakIterators, return the status tag from the
|
||||
* break rule that determined the most recently
|
||||
* returned break position.
|
||||
* <p>
|
||||
* For break iterator types that do not support a rule status,
|
||||
* a default value of 0 is returned.
|
||||
* <p>
|
||||
* @return the status from the break rule that determined the most recently
|
||||
* returned break position.
|
||||
* @see RuleBaseBreakIterator::getRuleStatus()
|
||||
* @see UWordBreak
|
||||
* @stable ICU 52
|
||||
*/
|
||||
virtual int32_t getRuleStatus() const;
|
||||
|
||||
/**
|
||||
* For RuleBasedBreakIterators, get the status (tag) values from the break rule(s)
|
||||
* that determined the most recently returned break position.
|
||||
* <p>
|
||||
* For break iterator types that do not support rule status,
|
||||
* no values are returned.
|
||||
* <p>
|
||||
* The returned status value(s) are stored into an array provided by the caller.
|
||||
* The values are stored in sorted (ascending) order.
|
||||
* If the capacity of the output array is insufficient to hold the data,
|
||||
* the output will be truncated to the available length, and a
|
||||
* U_BUFFER_OVERFLOW_ERROR will be signaled.
|
||||
* <p>
|
||||
* @see RuleBaseBreakIterator::getRuleStatusVec
|
||||
*
|
||||
* @param fillInVec an array to be filled in with the status values.
|
||||
* @param capacity the length of the supplied vector. A length of zero causes
|
||||
* the function to return the number of status values, in the
|
||||
* normal way, without attemtping to store any values.
|
||||
* @param status receives error codes.
|
||||
* @return The number of rule status values from rules that determined
|
||||
* the most recent boundary returned by the break iterator.
|
||||
* In the event of a U_BUFFER_OVERFLOW_ERROR, the return value
|
||||
* is the total number of status values that were available,
|
||||
* not the reduced number that were actually returned.
|
||||
* @see getRuleStatus
|
||||
* @stable ICU 52
|
||||
*/
|
||||
virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Create BreakIterator for word-breaks using the given locale.
|
||||
* Returns an instance of a BreakIterator implementing word breaks.
|
||||
* WordBreak is useful for word selection (ex. double click)
|
||||
* @param where the locale.
|
||||
* @param status the error code
|
||||
* @return A BreakIterator for word-breaks. The UErrorCode& status
|
||||
* parameter is used to return status information to the user.
|
||||
* To check whether the construction succeeded or not, you should check
|
||||
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
||||
* can check for informational error results which still indicate success.
|
||||
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
||||
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
||||
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
||||
* used; neither the requested locale nor any of its fall back locales
|
||||
* could be found.
|
||||
* The caller owns the returned object and is responsible for deleting it.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static BreakIterator* U_EXPORT2
|
||||
createWordInstance(const Locale& where, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Create BreakIterator for line-breaks using specified locale.
|
||||
* Returns an instance of a BreakIterator implementing line breaks. Line
|
||||
* breaks are logically possible line breaks, actual line breaks are
|
||||
* usually determined based on display width.
|
||||
* LineBreak is useful for word wrapping text.
|
||||
* @param where the locale.
|
||||
* @param status The error code.
|
||||
* @return A BreakIterator for line-breaks. The UErrorCode& status
|
||||
* parameter is used to return status information to the user.
|
||||
* To check whether the construction succeeded or not, you should check
|
||||
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
||||
* can check for informational error results which still indicate success.
|
||||
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
||||
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
||||
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
||||
* used; neither the requested locale nor any of its fall back locales
|
||||
* could be found.
|
||||
* The caller owns the returned object and is responsible for deleting it.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static BreakIterator* U_EXPORT2
|
||||
createLineInstance(const Locale& where, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Create BreakIterator for character-breaks using specified locale
|
||||
* Returns an instance of a BreakIterator implementing character breaks.
|
||||
* Character breaks are boundaries of combining character sequences.
|
||||
* @param where the locale.
|
||||
* @param status The error code.
|
||||
* @return A BreakIterator for character-breaks. The UErrorCode& status
|
||||
* parameter is used to return status information to the user.
|
||||
* To check whether the construction succeeded or not, you should check
|
||||
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
||||
* can check for informational error results which still indicate success.
|
||||
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
||||
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
||||
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
||||
* used; neither the requested locale nor any of its fall back locales
|
||||
* could be found.
|
||||
* The caller owns the returned object and is responsible for deleting it.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static BreakIterator* U_EXPORT2
|
||||
createCharacterInstance(const Locale& where, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Create BreakIterator for sentence-breaks using specified locale
|
||||
* Returns an instance of a BreakIterator implementing sentence breaks.
|
||||
* @param where the locale.
|
||||
* @param status The error code.
|
||||
* @return A BreakIterator for sentence-breaks. The UErrorCode& status
|
||||
* parameter is used to return status information to the user.
|
||||
* To check whether the construction succeeded or not, you should check
|
||||
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
||||
* can check for informational error results which still indicate success.
|
||||
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
||||
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
||||
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
||||
* used; neither the requested locale nor any of its fall back locales
|
||||
* could be found.
|
||||
* The caller owns the returned object and is responsible for deleting it.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static BreakIterator* U_EXPORT2
|
||||
createSentenceInstance(const Locale& where, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Create BreakIterator for title-casing breaks using the specified locale
|
||||
* Returns an instance of a BreakIterator implementing title breaks.
|
||||
* The iterator returned locates title boundaries as described for
|
||||
* Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
|
||||
* please use Word Boundary iterator.{@link #createWordInstance }
|
||||
*
|
||||
* @param where the locale.
|
||||
* @param status The error code.
|
||||
* @return A BreakIterator for title-breaks. The UErrorCode& status
|
||||
* parameter is used to return status information to the user.
|
||||
* To check whether the construction succeeded or not, you should check
|
||||
* the value of U_SUCCESS(err). If you wish more detailed information, you
|
||||
* can check for informational error results which still indicate success.
|
||||
* U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For
|
||||
* example, 'de_CH' was requested, but nothing was found there, so 'de' was
|
||||
* used. U_USING_DEFAULT_WARNING indicates that the default locale data was
|
||||
* used; neither the requested locale nor any of its fall back locales
|
||||
* could be found.
|
||||
* The caller owns the returned object and is responsible for deleting it.
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
static BreakIterator* U_EXPORT2
|
||||
createTitleInstance(const Locale& where, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Get the set of Locales for which TextBoundaries are installed.
|
||||
* <p><b>Note:</b> this will not return locales added through the register
|
||||
* call. To see the registered locales too, use the getAvailableLocales
|
||||
* function that returns a StringEnumeration object </p>
|
||||
* @param count the output parameter of number of elements in the locale list
|
||||
* @return available locales
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
|
||||
|
||||
/**
|
||||
* Get name of the object for the desired Locale, in the desired langauge.
|
||||
* @param objectLocale must be from getAvailableLocales.
|
||||
* @param displayLocale specifies the desired locale for output.
|
||||
* @param name the fill-in parameter of the return value
|
||||
* Uses best match.
|
||||
* @return user-displayable name
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
|
||||
const Locale& displayLocale,
|
||||
UnicodeString& name);
|
||||
|
||||
/**
|
||||
* Get name of the object for the desired Locale, in the langauge of the
|
||||
* default locale.
|
||||
* @param objectLocale must be from getMatchingLocales
|
||||
* @param name the fill-in parameter of the return value
|
||||
* @return user-displayable name
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
|
||||
UnicodeString& name);
|
||||
|
||||
/**
|
||||
* Deprecated functionality. Use clone() instead.
|
||||
*
|
||||
* Thread safe client-buffer-based cloning operation
|
||||
* Do NOT call delete on a safeclone, since 'new' is not used to create it.
|
||||
* @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated.
|
||||
* If buffer is not large enough, new memory will be allocated.
|
||||
* @param BufferSize reference to size of allocated space.
|
||||
* If BufferSize == 0, a sufficient size for use in cloning will
|
||||
* be returned ('pre-flighting')
|
||||
* If BufferSize is not enough for a stack-based safe clone,
|
||||
* new memory will be allocated.
|
||||
* @param status to indicate whether the operation went on smoothly or there were errors
|
||||
* An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were
|
||||
* necessary.
|
||||
* @return pointer to the new clone
|
||||
*
|
||||
* @deprecated ICU 52. Use clone() instead.
|
||||
*/
|
||||
virtual BreakIterator * createBufferClone(void *stackBuffer,
|
||||
int32_t &BufferSize,
|
||||
UErrorCode &status) = 0;
|
||||
|
||||
#ifndef U_HIDE_DEPRECATED_API
|
||||
|
||||
/**
|
||||
* Determine whether the BreakIterator was created in user memory by
|
||||
* createBufferClone(), and thus should not be deleted. Such objects
|
||||
* must be closed by an explicit call to the destructor (not delete).
|
||||
* @deprecated ICU 52. Always delete the BreakIterator.
|
||||
*/
|
||||
inline UBool isBufferClone(void);
|
||||
|
||||
#endif /* U_HIDE_DEPRECATED_API */
|
||||
|
||||
#if !UCONFIG_NO_SERVICE
|
||||
/**
|
||||
* Register a new break iterator of the indicated kind, to use in the given locale.
|
||||
* The break iterator will be adopted. Clones of the iterator will be returned
|
||||
* if a request for a break iterator of the given kind matches or falls back to
|
||||
* this locale.
|
||||
* Because ICU may choose to cache BreakIterators internally, this must
|
||||
* be called at application startup, prior to any calls to
|
||||
* BreakIterator::createXXXInstance to avoid undefined behavior.
|
||||
* @param toAdopt the BreakIterator instance to be adopted
|
||||
* @param locale the Locale for which this instance is to be registered
|
||||
* @param kind the type of iterator for which this instance is to be registered
|
||||
* @param status the in/out status code, no special meanings are assigned
|
||||
* @return a registry key that can be used to unregister this instance
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
|
||||
const Locale& locale,
|
||||
UBreakIteratorType kind,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Unregister a previously-registered BreakIterator using the key returned from the
|
||||
* register call. Key becomes invalid after a successful call and should not be used again.
|
||||
* The BreakIterator corresponding to the key will be deleted.
|
||||
* Because ICU may choose to cache BreakIterators internally, this should
|
||||
* be called during application shutdown, after all calls to
|
||||
* BreakIterator::createXXXInstance to avoid undefined behavior.
|
||||
* @param key the registry key returned by a previous call to registerInstance
|
||||
* @param status the in/out status code, no special meanings are assigned
|
||||
* @return TRUE if the iterator for the key was successfully unregistered
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Return a StringEnumeration over the locales available at the time of the call,
|
||||
* including registered locales.
|
||||
* @return a StringEnumeration over the locales available at the time of the call
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the locale for this break iterator. Two flavors are available: valid and
|
||||
* actual locale.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/** Get the locale for this break iterator object. You can choose between valid and actual locale.
|
||||
* @param type type of the locale we're looking for (valid or actual)
|
||||
* @param status error code for the operation
|
||||
* @return the locale
|
||||
* @internal
|
||||
*/
|
||||
const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* Set the subject text string upon which the break iterator is operating
|
||||
* without changing any other aspect of the matching state.
|
||||
* The new and previous text strings must have the same content.
|
||||
*
|
||||
* This function is intended for use in environments where ICU is operating on
|
||||
* strings that may move around in memory. It provides a mechanism for notifying
|
||||
* ICU that the string has been relocated, and providing a new UText to access the
|
||||
* string in its new position.
|
||||
*
|
||||
* Note that the break iterator implementation never copies the underlying text
|
||||
* of a string being processed, but always operates directly on the original text
|
||||
* provided by the user. Refreshing simply drops the references to the old text
|
||||
* and replaces them with references to the new.
|
||||
*
|
||||
* Caution: this function is normally used only by very specialized,
|
||||
* system-level code. One example use case is with garbage collection that moves
|
||||
* the text in memory.
|
||||
*
|
||||
* @param input The new (moved) text string.
|
||||
* @param status Receives errors detected by this function.
|
||||
* @return *this
|
||||
*
|
||||
* @stable ICU 49
|
||||
*/
|
||||
virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;
|
||||
|
||||
private:
|
||||
static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
|
||||
static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
|
||||
static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
|
||||
|
||||
friend class ICUBreakIteratorFactory;
|
||||
friend class ICUBreakIteratorService;
|
||||
|
||||
protected:
|
||||
// Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API
|
||||
// or else the compiler will create a public ones.
|
||||
/** @internal */
|
||||
BreakIterator();
|
||||
/** @internal */
|
||||
BreakIterator (const BreakIterator &other) : UObject(other) {}
|
||||
/** @internal */
|
||||
BreakIterator (const Locale& valid, const Locale& actual);
|
||||
private:
|
||||
|
||||
/** @internal */
|
||||
char actualLocale[ULOC_FULLNAME_CAPACITY];
|
||||
char validLocale[ULOC_FULLNAME_CAPACITY];
|
||||
|
||||
/**
|
||||
* The assignment operator has no real implementation.
|
||||
* It's provided to make the compiler happy. Do not call.
|
||||
*/
|
||||
BreakIterator& operator=(const BreakIterator&);
|
||||
};
|
||||
|
||||
#ifndef U_HIDE_DEPRECATED_API
|
||||
|
||||
inline UBool BreakIterator::isBufferClone()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* U_HIDE_DEPRECATED_API */
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
|
||||
|
||||
#endif // _BRKITER
|
||||
//eof
|
||||
@ -1,257 +0,0 @@
|
||||
// Copyright (C) 2009-2012, International Business Machines
|
||||
// Corporation and others. All Rights Reserved.
|
||||
//
|
||||
// Copyright 2007 Google Inc. All Rights Reserved.
|
||||
// Author: sanjay@google.com (Sanjay Ghemawat)
|
||||
//
|
||||
// Abstract interface that consumes a sequence of bytes (ByteSink).
|
||||
//
|
||||
// Used so that we can write a single piece of code that can operate
|
||||
// on a variety of output string types.
|
||||
//
|
||||
// Various implementations of this interface are provided:
|
||||
// ByteSink:
|
||||
// CheckedArrayByteSink Write to a flat array, with bounds checking
|
||||
// StringByteSink Write to an STL string
|
||||
|
||||
// This code is a contribution of Google code, and the style used here is
|
||||
// a compromise between the original Google code and the ICU coding guidelines.
|
||||
// For example, data types are ICU-ified (size_t,int->int32_t),
|
||||
// and API comments doxygen-ified, but function names and behavior are
|
||||
// as in the original, if possible.
|
||||
// Assertion-style error handling, not available in ICU, was changed to
|
||||
// parameter "pinning" similar to UnicodeString.
|
||||
//
|
||||
// In addition, this is only a partial port of the original Google code,
|
||||
// limited to what was needed so far. The (nearly) complete original code
|
||||
// is in the ICU svn repository at icuhtml/trunk/design/strings/contrib
|
||||
// (see ICU ticket 6765, r25517).
|
||||
|
||||
#ifndef __BYTESTREAM_H__
|
||||
#define __BYTESTREAM_H__
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Interface for writing bytes, and implementation classes.
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/std_string.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* A ByteSink can be filled with bytes.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
class U_COMMON_API ByteSink : public UMemory {
|
||||
public:
|
||||
/**
|
||||
* Default constructor.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
ByteSink() { }
|
||||
/**
|
||||
* Virtual destructor.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual ~ByteSink();
|
||||
|
||||
/**
|
||||
* Append "bytes[0,n-1]" to this.
|
||||
* @param bytes the pointer to the bytes
|
||||
* @param n the number of bytes; must be non-negative
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual void Append(const char* bytes, int32_t n) = 0;
|
||||
|
||||
/**
|
||||
* Returns a writable buffer for appending and writes the buffer's capacity to
|
||||
* *result_capacity. Guarantees *result_capacity>=min_capacity.
|
||||
* May return a pointer to the caller-owned scratch buffer which must have
|
||||
* scratch_capacity>=min_capacity.
|
||||
* The returned buffer is only valid until the next operation
|
||||
* on this ByteSink.
|
||||
*
|
||||
* After writing at most *result_capacity bytes, call Append() with the
|
||||
* pointer returned from this function and the number of bytes written.
|
||||
* Many Append() implementations will avoid copying bytes if this function
|
||||
* returned an internal buffer.
|
||||
*
|
||||
* Partial usage example:
|
||||
* int32_t capacity;
|
||||
* char* buffer = sink->GetAppendBuffer(..., &capacity);
|
||||
* ... Write n bytes into buffer, with n <= capacity.
|
||||
* sink->Append(buffer, n);
|
||||
* In many implementations, that call to Append will avoid copying bytes.
|
||||
*
|
||||
* If the ByteSink allocates or reallocates an internal buffer, it should use
|
||||
* the desired_capacity_hint if appropriate.
|
||||
* If a caller cannot provide a reasonable guess at the desired capacity,
|
||||
* it should pass desired_capacity_hint=0.
|
||||
*
|
||||
* If a non-scratch buffer is returned, the caller may only pass
|
||||
* a prefix to it to Append().
|
||||
* That is, it is not correct to pass an interior pointer to Append().
|
||||
*
|
||||
* The default implementation always returns the scratch buffer.
|
||||
*
|
||||
* @param min_capacity required minimum capacity of the returned buffer;
|
||||
* must be non-negative
|
||||
* @param desired_capacity_hint desired capacity of the returned buffer;
|
||||
* must be non-negative
|
||||
* @param scratch default caller-owned buffer
|
||||
* @param scratch_capacity capacity of the scratch buffer
|
||||
* @param result_capacity pointer to an integer which will be set to the
|
||||
* capacity of the returned buffer
|
||||
* @return a buffer with *result_capacity>=min_capacity
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual char* GetAppendBuffer(int32_t min_capacity,
|
||||
int32_t desired_capacity_hint,
|
||||
char* scratch, int32_t scratch_capacity,
|
||||
int32_t* result_capacity);
|
||||
|
||||
/**
|
||||
* Flush internal buffers.
|
||||
* Some byte sinks use internal buffers or provide buffering
|
||||
* and require calling Flush() at the end of the stream.
|
||||
* The ByteSink should be ready for further Append() calls after Flush().
|
||||
* The default implementation of Flush() does nothing.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual void Flush();
|
||||
|
||||
private:
|
||||
ByteSink(const ByteSink &); // copy constructor not implemented
|
||||
ByteSink &operator=(const ByteSink &); // assignment operator not implemented
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Some standard implementations
|
||||
|
||||
/**
|
||||
* Implementation of ByteSink that writes to a flat byte array,
|
||||
* with bounds-checking:
|
||||
* This sink will not write more than capacity bytes to outbuf.
|
||||
* If more than capacity bytes are Append()ed, then excess bytes are ignored,
|
||||
* and Overflowed() will return true.
|
||||
* Overflow does not cause a runtime error.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
class U_COMMON_API CheckedArrayByteSink : public ByteSink {
|
||||
public:
|
||||
/**
|
||||
* Constructs a ByteSink that will write to outbuf[0..capacity-1].
|
||||
* @param outbuf buffer to write to
|
||||
* @param capacity size of the buffer
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
CheckedArrayByteSink(char* outbuf, int32_t capacity);
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual ~CheckedArrayByteSink();
|
||||
/**
|
||||
* Returns the sink to its original state, without modifying the buffer.
|
||||
* Useful for reusing both the buffer and the sink for multiple streams.
|
||||
* Resets the state to NumberOfBytesWritten()=NumberOfBytesAppended()=0
|
||||
* and Overflowed()=FALSE.
|
||||
* @return *this
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
virtual CheckedArrayByteSink& Reset();
|
||||
/**
|
||||
* Append "bytes[0,n-1]" to this.
|
||||
* @param bytes the pointer to the bytes
|
||||
* @param n the number of bytes; must be non-negative
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual void Append(const char* bytes, int32_t n);
|
||||
/**
|
||||
* Returns a writable buffer for appending and writes the buffer's capacity to
|
||||
* *result_capacity. For details see the base class documentation.
|
||||
* @param min_capacity required minimum capacity of the returned buffer;
|
||||
* must be non-negative
|
||||
* @param desired_capacity_hint desired capacity of the returned buffer;
|
||||
* must be non-negative
|
||||
* @param scratch default caller-owned buffer
|
||||
* @param scratch_capacity capacity of the scratch buffer
|
||||
* @param result_capacity pointer to an integer which will be set to the
|
||||
* capacity of the returned buffer
|
||||
* @return a buffer with *result_capacity>=min_capacity
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual char* GetAppendBuffer(int32_t min_capacity,
|
||||
int32_t desired_capacity_hint,
|
||||
char* scratch, int32_t scratch_capacity,
|
||||
int32_t* result_capacity);
|
||||
/**
|
||||
* Returns the number of bytes actually written to the sink.
|
||||
* @return number of bytes written to the buffer
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
int32_t NumberOfBytesWritten() const { return size_; }
|
||||
/**
|
||||
* Returns true if any bytes were discarded, i.e., if there was an
|
||||
* attempt to write more than 'capacity' bytes.
|
||||
* @return TRUE if more than 'capacity' bytes were Append()ed
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
UBool Overflowed() const { return overflowed_; }
|
||||
/**
|
||||
* Returns the number of bytes appended to the sink.
|
||||
* If Overflowed() then NumberOfBytesAppended()>NumberOfBytesWritten()
|
||||
* else they return the same number.
|
||||
* @return number of bytes written to the buffer
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
int32_t NumberOfBytesAppended() const { return appended_; }
|
||||
private:
|
||||
char* outbuf_;
|
||||
const int32_t capacity_;
|
||||
int32_t size_;
|
||||
int32_t appended_;
|
||||
UBool overflowed_;
|
||||
CheckedArrayByteSink(); ///< default constructor not implemented
|
||||
CheckedArrayByteSink(const CheckedArrayByteSink &); ///< copy constructor not implemented
|
||||
CheckedArrayByteSink &operator=(const CheckedArrayByteSink &); ///< assignment operator not implemented
|
||||
};
|
||||
|
||||
#if U_HAVE_STD_STRING
|
||||
|
||||
/**
|
||||
* Implementation of ByteSink that writes to a "string".
|
||||
* The StringClass is usually instantiated with a std::string.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
template<typename StringClass>
|
||||
class StringByteSink : public ByteSink {
|
||||
public:
|
||||
/**
|
||||
* Constructs a ByteSink that will append bytes to the dest string.
|
||||
* @param dest pointer to string object to append to
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
StringByteSink(StringClass* dest) : dest_(dest) { }
|
||||
/**
|
||||
* Append "bytes[0,n-1]" to this.
|
||||
* @param data the pointer to the bytes
|
||||
* @param n the number of bytes; must be non-negative
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual void Append(const char* data, int32_t n) { dest_->append(data, n); }
|
||||
private:
|
||||
StringClass* dest_;
|
||||
StringByteSink(); ///< default constructor not implemented
|
||||
StringByteSink(const StringByteSink &); ///< copy constructor not implemented
|
||||
StringByteSink &operator=(const StringByteSink &); ///< assignment operator not implemented
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // __BYTESTREAM_H__
|
||||
@ -1,519 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2012, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: bytestrie.h
|
||||
* encoding: US-ASCII
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2010sep25
|
||||
* created by: Markus W. Scherer
|
||||
*/
|
||||
|
||||
#ifndef __BYTESTRIE_H__
|
||||
#define __BYTESTRIE_H__
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Trie for mapping byte sequences to integer values.
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/stringpiece.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/ustringtrie.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class ByteSink;
|
||||
class BytesTrieBuilder;
|
||||
class CharString;
|
||||
class UVector32;
|
||||
|
||||
/**
|
||||
* Light-weight, non-const reader class for a BytesTrie.
|
||||
* Traverses a byte-serialized data structure with minimal state,
|
||||
* for mapping byte sequences to non-negative integer values.
|
||||
*
|
||||
* This class owns the serialized trie data only if it was constructed by
|
||||
* the builder's build() method.
|
||||
* The public constructor and the copy constructor only alias the data (only copy the pointer).
|
||||
* There is no assignment operator.
|
||||
*
|
||||
* This class is not intended for public subclassing.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
class U_COMMON_API BytesTrie : public UMemory {
|
||||
public:
|
||||
/**
|
||||
* Constructs a BytesTrie reader instance.
|
||||
*
|
||||
* The trieBytes must contain a copy of a byte sequence from the BytesTrieBuilder,
|
||||
* starting with the first byte of that sequence.
|
||||
* The BytesTrie object will not read more bytes than
|
||||
* the BytesTrieBuilder generated in the corresponding build() call.
|
||||
*
|
||||
* The array is not copied/cloned and must not be modified while
|
||||
* the BytesTrie object is in use.
|
||||
*
|
||||
* @param trieBytes The byte array that contains the serialized trie.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
BytesTrie(const void *trieBytes)
|
||||
: ownedArray_(NULL), bytes_(static_cast<const uint8_t *>(trieBytes)),
|
||||
pos_(bytes_), remainingMatchLength_(-1) {}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
~BytesTrie();
|
||||
|
||||
/**
|
||||
* Copy constructor, copies the other trie reader object and its state,
|
||||
* but not the byte array which will be shared. (Shallow copy.)
|
||||
* @param other Another BytesTrie object.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
BytesTrie(const BytesTrie &other)
|
||||
: ownedArray_(NULL), bytes_(other.bytes_),
|
||||
pos_(other.pos_), remainingMatchLength_(other.remainingMatchLength_) {}
|
||||
|
||||
/**
|
||||
* Resets this trie to its initial state.
|
||||
* @return *this
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
BytesTrie &reset() {
|
||||
pos_=bytes_;
|
||||
remainingMatchLength_=-1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* BytesTrie state object, for saving a trie's current state
|
||||
* and resetting the trie back to this state later.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
class State : public UMemory {
|
||||
public:
|
||||
/**
|
||||
* Constructs an empty State.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
State() { bytes=NULL; }
|
||||
private:
|
||||
friend class BytesTrie;
|
||||
|
||||
const uint8_t *bytes;
|
||||
const uint8_t *pos;
|
||||
int32_t remainingMatchLength;
|
||||
};
|
||||
|
||||
/**
|
||||
* Saves the state of this trie.
|
||||
* @param state The State object to hold the trie's state.
|
||||
* @return *this
|
||||
* @see resetToState
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
const BytesTrie &saveState(State &state) const {
|
||||
state.bytes=bytes_;
|
||||
state.pos=pos_;
|
||||
state.remainingMatchLength=remainingMatchLength_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets this trie to the saved state.
|
||||
* If the state object contains no state, or the state of a different trie,
|
||||
* then this trie remains unchanged.
|
||||
* @param state The State object which holds a saved trie state.
|
||||
* @return *this
|
||||
* @see saveState
|
||||
* @see reset
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
BytesTrie &resetToState(const State &state) {
|
||||
if(bytes_==state.bytes && bytes_!=NULL) {
|
||||
pos_=state.pos;
|
||||
remainingMatchLength_=state.remainingMatchLength;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the byte sequence so far matches, whether it has a value,
|
||||
* and whether another input byte can continue a matching byte sequence.
|
||||
* @return The match/value Result.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
UStringTrieResult current() const;
|
||||
|
||||
/**
|
||||
* Traverses the trie from the initial state for this input byte.
|
||||
* Equivalent to reset().next(inByte).
|
||||
* @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff.
|
||||
* Values below -0x100 and above 0xff will never match.
|
||||
* @return The match/value Result.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
inline UStringTrieResult first(int32_t inByte) {
|
||||
remainingMatchLength_=-1;
|
||||
if(inByte<0) {
|
||||
inByte+=0x100;
|
||||
}
|
||||
return nextImpl(bytes_, inByte);
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverses the trie from the current state for this input byte.
|
||||
* @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff.
|
||||
* Values below -0x100 and above 0xff will never match.
|
||||
* @return The match/value Result.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
UStringTrieResult next(int32_t inByte);
|
||||
|
||||
/**
|
||||
* Traverses the trie from the current state for this byte sequence.
|
||||
* Equivalent to
|
||||
* \code
|
||||
* Result result=current();
|
||||
* for(each c in s)
|
||||
* if(!USTRINGTRIE_HAS_NEXT(result)) return USTRINGTRIE_NO_MATCH;
|
||||
* result=next(c);
|
||||
* return result;
|
||||
* \endcode
|
||||
* @param s A string or byte sequence. Can be NULL if length is 0.
|
||||
* @param length The length of the byte sequence. Can be -1 if NUL-terminated.
|
||||
* @return The match/value Result.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
UStringTrieResult next(const char *s, int32_t length);
|
||||
|
||||
/**
|
||||
* Returns a matching byte sequence's value if called immediately after
|
||||
* current()/first()/next() returned USTRINGTRIE_INTERMEDIATE_VALUE or USTRINGTRIE_FINAL_VALUE.
|
||||
* getValue() can be called multiple times.
|
||||
*
|
||||
* Do not call getValue() after USTRINGTRIE_NO_MATCH or USTRINGTRIE_NO_VALUE!
|
||||
* @return The value for the byte sequence so far.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
inline int32_t getValue() const {
|
||||
const uint8_t *pos=pos_;
|
||||
int32_t leadByte=*pos++;
|
||||
// U_ASSERT(leadByte>=kMinValueLead);
|
||||
return readValue(pos, leadByte>>1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether all byte sequences reachable from the current state
|
||||
* map to the same value.
|
||||
* @param uniqueValue Receives the unique value, if this function returns TRUE.
|
||||
* (output-only)
|
||||
* @return TRUE if all byte sequences reachable from the current state
|
||||
* map to the same value.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
inline UBool hasUniqueValue(int32_t &uniqueValue) const {
|
||||
const uint8_t *pos=pos_;
|
||||
// Skip the rest of a pending linear-match node.
|
||||
return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds each byte which continues the byte sequence from the current state.
|
||||
* That is, each byte b for which it would be next(b)!=USTRINGTRIE_NO_MATCH now.
|
||||
* @param out Each next byte is appended to this object.
|
||||
* (Only uses the out.Append(s, length) method.)
|
||||
* @return the number of bytes which continue the byte sequence from here
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
int32_t getNextBytes(ByteSink &out) const;
|
||||
|
||||
/**
|
||||
* Iterator for all of the (byte sequence, value) pairs in a BytesTrie.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
class U_COMMON_API Iterator : public UMemory {
|
||||
public:
|
||||
/**
|
||||
* Iterates from the root of a byte-serialized BytesTrie.
|
||||
* @param trieBytes The trie bytes.
|
||||
* @param maxStringLength If 0, the iterator returns full strings/byte sequences.
|
||||
* Otherwise, the iterator returns strings with this maximum length.
|
||||
* @param errorCode Standard ICU error code. Its input value must
|
||||
* pass the U_SUCCESS() test, or else the function returns
|
||||
* immediately. Check for U_FAILURE() on output or use with
|
||||
* function chaining. (See User Guide for details.)
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
Iterator(const void *trieBytes, int32_t maxStringLength, UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Iterates from the current state of the specified BytesTrie.
|
||||
* @param trie The trie whose state will be copied for iteration.
|
||||
* @param maxStringLength If 0, the iterator returns full strings/byte sequences.
|
||||
* Otherwise, the iterator returns strings with this maximum length.
|
||||
* @param errorCode Standard ICU error code. Its input value must
|
||||
* pass the U_SUCCESS() test, or else the function returns
|
||||
* immediately. Check for U_FAILURE() on output or use with
|
||||
* function chaining. (See User Guide for details.)
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
Iterator(const BytesTrie &trie, int32_t maxStringLength, UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
~Iterator();
|
||||
|
||||
/**
|
||||
* Resets this iterator to its initial state.
|
||||
* @return *this
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
Iterator &reset();
|
||||
|
||||
/**
|
||||
* @return TRUE if there are more elements.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
UBool hasNext() const;
|
||||
|
||||
/**
|
||||
* Finds the next (byte sequence, value) pair if there is one.
|
||||
*
|
||||
* If the byte sequence is truncated to the maximum length and does not
|
||||
* have a real value, then the value is set to -1.
|
||||
* In this case, this "not a real value" is indistinguishable from
|
||||
* a real value of -1.
|
||||
* @param errorCode Standard ICU error code. Its input value must
|
||||
* pass the U_SUCCESS() test, or else the function returns
|
||||
* immediately. Check for U_FAILURE() on output or use with
|
||||
* function chaining. (See User Guide for details.)
|
||||
* @return TRUE if there is another element.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
UBool next(UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* @return The NUL-terminated byte sequence for the last successful next().
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
const StringPiece &getString() const { return sp_; }
|
||||
/**
|
||||
* @return The value for the last successful next().
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
int32_t getValue() const { return value_; }
|
||||
|
||||
private:
|
||||
UBool truncateAndStop();
|
||||
|
||||
const uint8_t *branchNext(const uint8_t *pos, int32_t length, UErrorCode &errorCode);
|
||||
|
||||
const uint8_t *bytes_;
|
||||
const uint8_t *pos_;
|
||||
const uint8_t *initialPos_;
|
||||
int32_t remainingMatchLength_;
|
||||
int32_t initialRemainingMatchLength_;
|
||||
|
||||
CharString *str_;
|
||||
StringPiece sp_;
|
||||
int32_t maxLength_;
|
||||
int32_t value_;
|
||||
|
||||
// The stack stores pairs of integers for backtracking to another
|
||||
// outbound edge of a branch node.
|
||||
// The first integer is an offset from bytes_.
|
||||
// The second integer has the str_->length() from before the node in bits 15..0,
|
||||
// and the remaining branch length in bits 24..16. (Bits 31..25 are unused.)
|
||||
// (We could store the remaining branch length minus 1 in bits 23..16 and not use bits 31..24,
|
||||
// but the code looks more confusing that way.)
|
||||
UVector32 *stack_;
|
||||
};
|
||||
|
||||
private:
|
||||
friend class BytesTrieBuilder;
|
||||
|
||||
/**
|
||||
* Constructs a BytesTrie reader instance.
|
||||
* Unlike the public constructor which just aliases an array,
|
||||
* this constructor adopts the builder's array.
|
||||
* This constructor is only called by the builder.
|
||||
*/
|
||||
BytesTrie(void *adoptBytes, const void *trieBytes)
|
||||
: ownedArray_(static_cast<uint8_t *>(adoptBytes)),
|
||||
bytes_(static_cast<const uint8_t *>(trieBytes)),
|
||||
pos_(bytes_), remainingMatchLength_(-1) {}
|
||||
|
||||
// No assignment operator.
|
||||
BytesTrie &operator=(const BytesTrie &other);
|
||||
|
||||
inline void stop() {
|
||||
pos_=NULL;
|
||||
}
|
||||
|
||||
// Reads a compact 32-bit integer.
|
||||
// pos is already after the leadByte, and the lead byte is already shifted right by 1.
|
||||
static int32_t readValue(const uint8_t *pos, int32_t leadByte);
|
||||
static inline const uint8_t *skipValue(const uint8_t *pos, int32_t leadByte) {
|
||||
// U_ASSERT(leadByte>=kMinValueLead);
|
||||
if(leadByte>=(kMinTwoByteValueLead<<1)) {
|
||||
if(leadByte<(kMinThreeByteValueLead<<1)) {
|
||||
++pos;
|
||||
} else if(leadByte<(kFourByteValueLead<<1)) {
|
||||
pos+=2;
|
||||
} else {
|
||||
pos+=3+((leadByte>>1)&1);
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
static inline const uint8_t *skipValue(const uint8_t *pos) {
|
||||
int32_t leadByte=*pos++;
|
||||
return skipValue(pos, leadByte);
|
||||
}
|
||||
|
||||
// Reads a jump delta and jumps.
|
||||
static const uint8_t *jumpByDelta(const uint8_t *pos);
|
||||
|
||||
static inline const uint8_t *skipDelta(const uint8_t *pos) {
|
||||
int32_t delta=*pos++;
|
||||
if(delta>=kMinTwoByteDeltaLead) {
|
||||
if(delta<kMinThreeByteDeltaLead) {
|
||||
++pos;
|
||||
} else if(delta<kFourByteDeltaLead) {
|
||||
pos+=2;
|
||||
} else {
|
||||
pos+=3+(delta&1);
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
static inline UStringTrieResult valueResult(int32_t node) {
|
||||
return (UStringTrieResult)(USTRINGTRIE_INTERMEDIATE_VALUE-(node&kValueIsFinal));
|
||||
}
|
||||
|
||||
// Handles a branch node for both next(byte) and next(string).
|
||||
UStringTrieResult branchNext(const uint8_t *pos, int32_t length, int32_t inByte);
|
||||
|
||||
// Requires remainingLength_<0.
|
||||
UStringTrieResult nextImpl(const uint8_t *pos, int32_t inByte);
|
||||
|
||||
// Helper functions for hasUniqueValue().
|
||||
// Recursively finds a unique value (or whether there is not a unique one)
|
||||
// from a branch.
|
||||
static const uint8_t *findUniqueValueFromBranch(const uint8_t *pos, int32_t length,
|
||||
UBool haveUniqueValue, int32_t &uniqueValue);
|
||||
// Recursively finds a unique value (or whether there is not a unique one)
|
||||
// starting from a position on a node lead byte.
|
||||
static UBool findUniqueValue(const uint8_t *pos, UBool haveUniqueValue, int32_t &uniqueValue);
|
||||
|
||||
// Helper functions for getNextBytes().
|
||||
// getNextBytes() when pos is on a branch node.
|
||||
static void getNextBranchBytes(const uint8_t *pos, int32_t length, ByteSink &out);
|
||||
static void append(ByteSink &out, int c);
|
||||
|
||||
// BytesTrie data structure
|
||||
//
|
||||
// The trie consists of a series of byte-serialized nodes for incremental
|
||||
// string/byte sequence matching. The root node is at the beginning of the trie data.
|
||||
//
|
||||
// Types of nodes are distinguished by their node lead byte ranges.
|
||||
// After each node, except a final-value node, another node follows to
|
||||
// encode match values or continue matching further bytes.
|
||||
//
|
||||
// Node types:
|
||||
// - Value node: Stores a 32-bit integer in a compact, variable-length format.
|
||||
// The value is for the string/byte sequence so far.
|
||||
// One node bit indicates whether the value is final or whether
|
||||
// matching continues with the next node.
|
||||
// - Linear-match node: Matches a number of bytes.
|
||||
// - Branch node: Branches to other nodes according to the current input byte.
|
||||
// The node byte is the length of the branch (number of bytes to select from)
|
||||
// minus 1. It is followed by a sub-node:
|
||||
// - If the length is at most kMaxBranchLinearSubNodeLength, then
|
||||
// there are length-1 (key, value) pairs and then one more comparison byte.
|
||||
// If one of the key bytes matches, then the value is either a final value for
|
||||
// the string/byte sequence so far, or a "jump" delta to the next node.
|
||||
// If the last byte matches, then matching continues with the next node.
|
||||
// (Values have the same encoding as value nodes.)
|
||||
// - If the length is greater than kMaxBranchLinearSubNodeLength, then
|
||||
// there is one byte and one "jump" delta.
|
||||
// If the input byte is less than the sub-node byte, then "jump" by delta to
|
||||
// the next sub-node which will have a length of length/2.
|
||||
// (The delta has its own compact encoding.)
|
||||
// Otherwise, skip the "jump" delta to the next sub-node
|
||||
// which will have a length of length-length/2.
|
||||
|
||||
// Node lead byte values.
|
||||
|
||||
// 00..0f: Branch node. If node!=0 then the length is node+1, otherwise
|
||||
// the length is one more than the next byte.
|
||||
|
||||
// For a branch sub-node with at most this many entries, we drop down
|
||||
// to a linear search.
|
||||
static const int32_t kMaxBranchLinearSubNodeLength=5;
|
||||
|
||||
// 10..1f: Linear-match node, match 1..16 bytes and continue reading the next node.
|
||||
static const int32_t kMinLinearMatch=0x10;
|
||||
static const int32_t kMaxLinearMatchLength=0x10;
|
||||
|
||||
// 20..ff: Variable-length value node.
|
||||
// If odd, the value is final. (Otherwise, intermediate value or jump delta.)
|
||||
// Then shift-right by 1 bit.
|
||||
// The remaining lead byte value indicates the number of following bytes (0..4)
|
||||
// and contains the value's top bits.
|
||||
static const int32_t kMinValueLead=kMinLinearMatch+kMaxLinearMatchLength; // 0x20
|
||||
// It is a final value if bit 0 is set.
|
||||
static const int32_t kValueIsFinal=1;
|
||||
|
||||
// Compact value: After testing bit 0, shift right by 1 and then use the following thresholds.
|
||||
static const int32_t kMinOneByteValueLead=kMinValueLead/2; // 0x10
|
||||
static const int32_t kMaxOneByteValue=0x40; // At least 6 bits in the first byte.
|
||||
|
||||
static const int32_t kMinTwoByteValueLead=kMinOneByteValueLead+kMaxOneByteValue+1; // 0x51
|
||||
static const int32_t kMaxTwoByteValue=0x1aff;
|
||||
|
||||
static const int32_t kMinThreeByteValueLead=kMinTwoByteValueLead+(kMaxTwoByteValue>>8)+1; // 0x6c
|
||||
static const int32_t kFourByteValueLead=0x7e;
|
||||
|
||||
// A little more than Unicode code points. (0x11ffff)
|
||||
static const int32_t kMaxThreeByteValue=((kFourByteValueLead-kMinThreeByteValueLead)<<16)-1;
|
||||
|
||||
static const int32_t kFiveByteValueLead=0x7f;
|
||||
|
||||
// Compact delta integers.
|
||||
static const int32_t kMaxOneByteDelta=0xbf;
|
||||
static const int32_t kMinTwoByteDeltaLead=kMaxOneByteDelta+1; // 0xc0
|
||||
static const int32_t kMinThreeByteDeltaLead=0xf0;
|
||||
static const int32_t kFourByteDeltaLead=0xfe;
|
||||
static const int32_t kFiveByteDeltaLead=0xff;
|
||||
|
||||
static const int32_t kMaxTwoByteDelta=((kMinThreeByteDeltaLead-kMinTwoByteDeltaLead)<<8)-1; // 0x2fff
|
||||
static const int32_t kMaxThreeByteDelta=((kFourByteDeltaLead-kMinThreeByteDeltaLead)<<16)-1; // 0xdffff
|
||||
|
||||
uint8_t *ownedArray_;
|
||||
|
||||
// Fixed value referencing the BytesTrie bytes.
|
||||
const uint8_t *bytes_;
|
||||
|
||||
// Iterator variables.
|
||||
|
||||
// Pointer to next trie byte to read. NULL if no more matches.
|
||||
const uint8_t *pos_;
|
||||
// Remaining length of a linear-match node, minus 1. Negative if not in such a node.
|
||||
int32_t remainingMatchLength_;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // __BYTESTRIE_H__
|
||||
@ -1,181 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2010-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* file name: bytestriebuilder.h
|
||||
* encoding: US-ASCII
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2010sep25
|
||||
* created by: Markus W. Scherer
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Builder for icu::BytesTrie
|
||||
*/
|
||||
|
||||
#ifndef __BYTESTRIEBUILDER_H__
|
||||
#define __BYTESTRIEBUILDER_H__
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/bytestrie.h"
|
||||
#include "unicode/stringpiece.h"
|
||||
#include "unicode/stringtriebuilder.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class BytesTrieElement;
|
||||
class CharString;
|
||||
|
||||
/**
|
||||
* Builder class for BytesTrie.
|
||||
*
|
||||
* This class is not intended for public subclassing.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
class U_COMMON_API BytesTrieBuilder : public StringTrieBuilder {
|
||||
public:
|
||||
/**
|
||||
* Constructs an empty builder.
|
||||
* @param errorCode Standard ICU error code.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
BytesTrieBuilder(UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual ~BytesTrieBuilder();
|
||||
|
||||
/**
|
||||
* Adds a (byte sequence, value) pair.
|
||||
* The byte sequence must be unique.
|
||||
* The bytes will be copied; the builder does not keep
|
||||
* a reference to the input StringPiece or its data().
|
||||
* @param s The input byte sequence.
|
||||
* @param value The value associated with this byte sequence.
|
||||
* @param errorCode Standard ICU error code. Its input value must
|
||||
* pass the U_SUCCESS() test, or else the function returns
|
||||
* immediately. Check for U_FAILURE() on output or use with
|
||||
* function chaining. (See User Guide for details.)
|
||||
* @return *this
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
BytesTrieBuilder &add(const StringPiece &s, int32_t value, UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Builds a BytesTrie for the add()ed data.
|
||||
* Once built, no further data can be add()ed until clear() is called.
|
||||
*
|
||||
* A BytesTrie cannot be empty. At least one (byte sequence, value) pair
|
||||
* must have been add()ed.
|
||||
*
|
||||
* This method passes ownership of the builder's internal result array to the new trie object.
|
||||
* Another call to any build() variant will re-serialize the trie.
|
||||
* After clear() has been called, a new array will be used as well.
|
||||
* @param buildOption Build option, see UStringTrieBuildOption.
|
||||
* @param errorCode Standard ICU error code. Its input value must
|
||||
* pass the U_SUCCESS() test, or else the function returns
|
||||
* immediately. Check for U_FAILURE() on output or use with
|
||||
* function chaining. (See User Guide for details.)
|
||||
* @return A new BytesTrie for the add()ed data.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
BytesTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Builds a BytesTrie for the add()ed data and byte-serializes it.
|
||||
* Once built, no further data can be add()ed until clear() is called.
|
||||
*
|
||||
* A BytesTrie cannot be empty. At least one (byte sequence, value) pair
|
||||
* must have been add()ed.
|
||||
*
|
||||
* Multiple calls to buildStringPiece() return StringPieces referring to the
|
||||
* builder's same byte array, without rebuilding.
|
||||
* If buildStringPiece() is called after build(), the trie will be
|
||||
* re-serialized into a new array.
|
||||
* If build() is called after buildStringPiece(), the trie object will become
|
||||
* the owner of the previously returned array.
|
||||
* After clear() has been called, a new array will be used as well.
|
||||
* @param buildOption Build option, see UStringTrieBuildOption.
|
||||
* @param errorCode Standard ICU error code. Its input value must
|
||||
* pass the U_SUCCESS() test, or else the function returns
|
||||
* immediately. Check for U_FAILURE() on output or use with
|
||||
* function chaining. (See User Guide for details.)
|
||||
* @return A StringPiece which refers to the byte-serialized BytesTrie for the add()ed data.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
StringPiece buildStringPiece(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Removes all (byte sequence, value) pairs.
|
||||
* New data can then be add()ed and a new trie can be built.
|
||||
* @return *this
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
BytesTrieBuilder &clear();
|
||||
|
||||
private:
|
||||
BytesTrieBuilder(const BytesTrieBuilder &other); // no copy constructor
|
||||
BytesTrieBuilder &operator=(const BytesTrieBuilder &other); // no assignment operator
|
||||
|
||||
void buildBytes(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
|
||||
|
||||
virtual int32_t getElementStringLength(int32_t i) const;
|
||||
virtual UChar getElementUnit(int32_t i, int32_t byteIndex) const;
|
||||
virtual int32_t getElementValue(int32_t i) const;
|
||||
|
||||
virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t byteIndex) const;
|
||||
|
||||
virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t byteIndex) const;
|
||||
virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const;
|
||||
virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, UChar byte) const;
|
||||
|
||||
virtual UBool matchNodesCanHaveValues() const { return FALSE; }
|
||||
|
||||
virtual int32_t getMaxBranchLinearSubNodeLength() const { return BytesTrie::kMaxBranchLinearSubNodeLength; }
|
||||
virtual int32_t getMinLinearMatch() const { return BytesTrie::kMinLinearMatch; }
|
||||
virtual int32_t getMaxLinearMatchLength() const { return BytesTrie::kMaxLinearMatchLength; }
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class BTLinearMatchNode : public LinearMatchNode {
|
||||
public:
|
||||
BTLinearMatchNode(const char *units, int32_t len, Node *nextNode);
|
||||
virtual UBool operator==(const Node &other) const;
|
||||
virtual void write(StringTrieBuilder &builder);
|
||||
private:
|
||||
const char *s;
|
||||
};
|
||||
|
||||
virtual Node *createLinearMatchNode(int32_t i, int32_t byteIndex, int32_t length,
|
||||
Node *nextNode) const;
|
||||
|
||||
UBool ensureCapacity(int32_t length);
|
||||
virtual int32_t write(int32_t byte);
|
||||
int32_t write(const char *b, int32_t length);
|
||||
virtual int32_t writeElementUnits(int32_t i, int32_t byteIndex, int32_t length);
|
||||
virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);
|
||||
virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);
|
||||
virtual int32_t writeDeltaTo(int32_t jumpTarget);
|
||||
|
||||
CharString *strings; // Pointer not object so we need not #include internal charstr.h.
|
||||
BytesTrieElement *elements;
|
||||
int32_t elementsCapacity;
|
||||
int32_t elementsLength;
|
||||
|
||||
// Byte serialization of the trie.
|
||||
// Grows from the back: bytesLength measures from the end of the buffer!
|
||||
char *bytes;
|
||||
int32_t bytesCapacity;
|
||||
int32_t bytesLength;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // __BYTESTRIEBUILDER_H__
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,208 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2014, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef CANITER_H
|
||||
#define CANITER_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_NORMALIZATION
|
||||
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/unistr.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Canonical Iterator
|
||||
*/
|
||||
|
||||
/** Should permutation skip characters with combining class zero
|
||||
* Should be either TRUE or FALSE. This is a compile time option
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
#ifndef CANITER_SKIP_ZEROES
|
||||
#define CANITER_SKIP_ZEROES TRUE
|
||||
#endif
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class Hashtable;
|
||||
class Normalizer2;
|
||||
class Normalizer2Impl;
|
||||
|
||||
/**
|
||||
* This class allows one to iterate through all the strings that are canonically equivalent to a given
|
||||
* string. For example, here are some sample results:
|
||||
Results for: {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
|
||||
1: \\u0041\\u030A\\u0064\\u0307\\u0327
|
||||
= {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
|
||||
2: \\u0041\\u030A\\u0064\\u0327\\u0307
|
||||
= {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
|
||||
3: \\u0041\\u030A\\u1E0B\\u0327
|
||||
= {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
|
||||
4: \\u0041\\u030A\\u1E11\\u0307
|
||||
= {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
|
||||
5: \\u00C5\\u0064\\u0307\\u0327
|
||||
= {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
|
||||
6: \\u00C5\\u0064\\u0327\\u0307
|
||||
= {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
|
||||
7: \\u00C5\\u1E0B\\u0327
|
||||
= {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
|
||||
8: \\u00C5\\u1E11\\u0307
|
||||
= {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
|
||||
9: \\u212B\\u0064\\u0307\\u0327
|
||||
= {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
|
||||
10: \\u212B\\u0064\\u0327\\u0307
|
||||
= {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
|
||||
11: \\u212B\\u1E0B\\u0327
|
||||
= {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
|
||||
12: \\u212B\\u1E11\\u0307
|
||||
= {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
|
||||
*<br>Note: the code is intended for use with small strings, and is not suitable for larger ones,
|
||||
* since it has not been optimized for that situation.
|
||||
* Note, CanonicalIterator is not intended to be subclassed.
|
||||
* @author M. Davis
|
||||
* @author C++ port by V. Weinstein
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
class U_COMMON_API CanonicalIterator U_FINAL : public UObject {
|
||||
public:
|
||||
/**
|
||||
* Construct a CanonicalIterator object
|
||||
* @param source string to get results for
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
CanonicalIterator(const UnicodeString &source, UErrorCode &status);
|
||||
|
||||
/** Destructor
|
||||
* Cleans pieces
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
virtual ~CanonicalIterator();
|
||||
|
||||
/**
|
||||
* Gets the NFD form of the current source we are iterating over.
|
||||
* @return gets the source: NOTE: it is the NFD form of source
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
UnicodeString getSource();
|
||||
|
||||
/**
|
||||
* Resets the iterator so that one can start again from the beginning.
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Get the next canonically equivalent string.
|
||||
* <br><b>Warning: The strings are not guaranteed to be in any particular order.</b>
|
||||
* @return the next string that is canonically equivalent. A bogus string is returned when
|
||||
* the iteration is done.
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
UnicodeString next();
|
||||
|
||||
/**
|
||||
* Set a new source for this iterator. Allows object reuse.
|
||||
* @param newSource the source string to iterate against. This allows the same iterator to be used
|
||||
* while changing the source string, saving object creation.
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
void setSource(const UnicodeString &newSource, UErrorCode &status);
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* Dumb recursive implementation of permutation.
|
||||
* TODO: optimize
|
||||
* @param source the string to find permutations for
|
||||
* @param skipZeros determine if skip zeros
|
||||
* @param result the results in a set.
|
||||
* @param status Fill-in parameter which receives the status of this operation.
|
||||
* @internal
|
||||
*/
|
||||
static void U_EXPORT2 permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status);
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID();
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
private:
|
||||
// ===================== PRIVATES ==============================
|
||||
// private default constructor
|
||||
CanonicalIterator();
|
||||
|
||||
|
||||
/**
|
||||
* Copy constructor. Private for now.
|
||||
* @internal
|
||||
*/
|
||||
CanonicalIterator(const CanonicalIterator& other);
|
||||
|
||||
/**
|
||||
* Assignment operator. Private for now.
|
||||
* @internal
|
||||
*/
|
||||
CanonicalIterator& operator=(const CanonicalIterator& other);
|
||||
|
||||
// fields
|
||||
UnicodeString source;
|
||||
UBool done;
|
||||
|
||||
// 2 dimensional array holds the pieces of the string with
|
||||
// their different canonically equivalent representations
|
||||
UnicodeString **pieces;
|
||||
int32_t pieces_length;
|
||||
int32_t *pieces_lengths;
|
||||
|
||||
// current is used in iterating to combine pieces
|
||||
int32_t *current;
|
||||
int32_t current_length;
|
||||
|
||||
// transient fields
|
||||
UnicodeString buffer;
|
||||
|
||||
const Normalizer2 &nfd;
|
||||
const Normalizer2Impl &nfcImpl;
|
||||
|
||||
// we have a segment, in NFD. Find all the strings that are canonically equivalent to it.
|
||||
UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
|
||||
|
||||
//Set getEquivalents2(String segment);
|
||||
Hashtable *getEquivalents2(Hashtable *fillinResult, const UChar *segment, int32_t segLen, UErrorCode &status);
|
||||
//Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
|
||||
|
||||
/**
|
||||
* See if the decomposition of cp2 is at segment starting at segmentPos
|
||||
* (with canonical rearrangment!)
|
||||
* If so, take the remainder, and return the equivalents
|
||||
*/
|
||||
//Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
|
||||
Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
|
||||
//Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
|
||||
|
||||
void cleanPieces();
|
||||
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_NORMALIZATION */
|
||||
|
||||
#endif
|
||||
@ -1,722 +0,0 @@
|
||||
/*
|
||||
********************************************************************
|
||||
*
|
||||
* Copyright (C) 1997-2011, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef CHARITER_H
|
||||
#define CHARITER_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/unistr.h"
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Character Iterator
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
/**
|
||||
* Abstract class that defines an API for forward-only iteration
|
||||
* on text objects.
|
||||
* This is a minimal interface for iteration without random access
|
||||
* or backwards iteration. It is especially useful for wrapping
|
||||
* streams with converters into an object for collation or
|
||||
* normalization.
|
||||
*
|
||||
* <p>Characters can be accessed in two ways: as code units or as
|
||||
* code points.
|
||||
* Unicode code points are 21-bit integers and are the scalar values
|
||||
* of Unicode characters. ICU uses the type UChar32 for them.
|
||||
* Unicode code units are the storage units of a given
|
||||
* Unicode/UCS Transformation Format (a character encoding scheme).
|
||||
* With UTF-16, all code points can be represented with either one
|
||||
* or two code units ("surrogates").
|
||||
* String storage is typically based on code units, while properties
|
||||
* of characters are typically determined using code point values.
|
||||
* Some processes may be designed to work with sequences of code units,
|
||||
* or it may be known that all characters that are important to an
|
||||
* algorithm can be represented with single code units.
|
||||
* Other processes will need to use the code point access functions.</p>
|
||||
*
|
||||
* <p>ForwardCharacterIterator provides nextPostInc() to access
|
||||
* a code unit and advance an internal position into the text object,
|
||||
* similar to a <code>return text[position++]</code>.<br>
|
||||
* It provides next32PostInc() to access a code point and advance an internal
|
||||
* position.</p>
|
||||
*
|
||||
* <p>next32PostInc() assumes that the current position is that of
|
||||
* the beginning of a code point, i.e., of its first code unit.
|
||||
* After next32PostInc(), this will be true again.
|
||||
* In general, access to code units and code points in the same
|
||||
* iteration loop should not be mixed. In UTF-16, if the current position
|
||||
* is on a second code unit (Low Surrogate), then only that code unit
|
||||
* is returned even by next32PostInc().</p>
|
||||
*
|
||||
* <p>For iteration with either function, there are two ways to
|
||||
* check for the end of the iteration. When there are no more
|
||||
* characters in the text object:
|
||||
* <ul>
|
||||
* <li>The hasNext() function returns FALSE.</li>
|
||||
* <li>nextPostInc() and next32PostInc() return DONE
|
||||
* when one attempts to read beyond the end of the text object.</li>
|
||||
* </ul>
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
* void function1(ForwardCharacterIterator &it) {
|
||||
* UChar32 c;
|
||||
* while(it.hasNext()) {
|
||||
* c=it.next32PostInc();
|
||||
* // use c
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void function1(ForwardCharacterIterator &it) {
|
||||
* UChar c;
|
||||
* while((c=it.nextPostInc())!=ForwardCharacterIterator::DONE) {
|
||||
* // use c
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
* </p>
|
||||
*
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
class U_COMMON_API ForwardCharacterIterator : public UObject {
|
||||
public:
|
||||
/**
|
||||
* Value returned by most of ForwardCharacterIterator's functions
|
||||
* when the iterator has reached the limits of its iteration.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
enum { DONE = 0xffff };
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual ~ForwardCharacterIterator();
|
||||
|
||||
/**
|
||||
* Returns true when both iterators refer to the same
|
||||
* character in the same character-storage object.
|
||||
* @param that The ForwardCharacterIterator to be compared for equality
|
||||
* @return true when both iterators refer to the same
|
||||
* character in the same character-storage object
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool operator==(const ForwardCharacterIterator& that) const = 0;
|
||||
|
||||
/**
|
||||
* Returns true when the iterators refer to different
|
||||
* text-storage objects, or to different characters in the
|
||||
* same text-storage object.
|
||||
* @param that The ForwardCharacterIterator to be compared for inequality
|
||||
* @return true when the iterators refer to different
|
||||
* text-storage objects, or to different characters in the
|
||||
* same text-storage object
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
inline UBool operator!=(const ForwardCharacterIterator& that) const;
|
||||
|
||||
/**
|
||||
* Generates a hash code for this iterator.
|
||||
* @return the hash code.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t hashCode(void) const = 0;
|
||||
|
||||
/**
|
||||
* Returns a UClassID for this ForwardCharacterIterator ("poor man's
|
||||
* RTTI").<P> Despite the fact that this function is public,
|
||||
* DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API!
|
||||
* @return a UClassID for this ForwardCharacterIterator
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the current code unit for returning and advances to the next code unit
|
||||
* in the iteration range
|
||||
* (toward endIndex()). If there are
|
||||
* no more code units to return, returns DONE.
|
||||
* @return the current code unit.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar nextPostInc(void) = 0;
|
||||
|
||||
/**
|
||||
* Gets the current code point for returning and advances to the next code point
|
||||
* in the iteration range
|
||||
* (toward endIndex()). If there are
|
||||
* no more code points to return, returns DONE.
|
||||
* @return the current code point.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar32 next32PostInc(void) = 0;
|
||||
|
||||
/**
|
||||
* Returns FALSE if there are no more code units or code points
|
||||
* at or after the current position in the iteration range.
|
||||
* This is used with nextPostInc() or next32PostInc() in forward
|
||||
* iteration.
|
||||
* @returns FALSE if there are no more code units or code points
|
||||
* at or after the current position in the iteration range.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool hasNext() = 0;
|
||||
|
||||
protected:
|
||||
/** Default constructor to be overridden in the implementing class. @stable ICU 2.0*/
|
||||
ForwardCharacterIterator();
|
||||
|
||||
/** Copy constructor to be overridden in the implementing class. @stable ICU 2.0*/
|
||||
ForwardCharacterIterator(const ForwardCharacterIterator &other);
|
||||
|
||||
/**
|
||||
* Assignment operator to be overridden in the implementing class.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstract class that defines an API for iteration
|
||||
* on text objects.
|
||||
* This is an interface for forward and backward iteration
|
||||
* and random access into a text object.
|
||||
*
|
||||
* <p>The API provides backward compatibility to the Java and older ICU
|
||||
* CharacterIterator classes but extends them significantly:
|
||||
* <ol>
|
||||
* <li>CharacterIterator is now a subclass of ForwardCharacterIterator.</li>
|
||||
* <li>While the old API functions provided forward iteration with
|
||||
* "pre-increment" semantics, the new one also provides functions
|
||||
* with "post-increment" semantics. They are more efficient and should
|
||||
* be the preferred iterator functions for new implementations.
|
||||
* The backward iteration always had "pre-decrement" semantics, which
|
||||
* are efficient.</li>
|
||||
* <li>Just like ForwardCharacterIterator, it provides access to
|
||||
* both code units and code points. Code point access versions are available
|
||||
* for the old and the new iteration semantics.</li>
|
||||
* <li>There are new functions for setting and moving the current position
|
||||
* without returning a character, for efficiency.</li>
|
||||
* </ol>
|
||||
*
|
||||
* See ForwardCharacterIterator for examples for using the new forward iteration
|
||||
* functions. For backward iteration, there is also a hasPrevious() function
|
||||
* that can be used analogously to hasNext().
|
||||
* The old functions work as before and are shown below.</p>
|
||||
*
|
||||
* <p>Examples for some of the new functions:</p>
|
||||
*
|
||||
* Forward iteration with hasNext():
|
||||
* \code
|
||||
* void forward1(CharacterIterator &it) {
|
||||
* UChar32 c;
|
||||
* for(it.setToStart(); it.hasNext();) {
|
||||
* c=it.next32PostInc();
|
||||
* // use c
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
* Forward iteration more similar to loops with the old forward iteration,
|
||||
* showing a way to convert simple for() loops:
|
||||
* \code
|
||||
* void forward2(CharacterIterator &it) {
|
||||
* UChar c;
|
||||
* for(c=it.firstPostInc(); c!=CharacterIterator::DONE; c=it.nextPostInc()) {
|
||||
* // use c
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
* Backward iteration with setToEnd() and hasPrevious():
|
||||
* \code
|
||||
* void backward1(CharacterIterator &it) {
|
||||
* UChar32 c;
|
||||
* for(it.setToEnd(); it.hasPrevious();) {
|
||||
* c=it.previous32();
|
||||
* // use c
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
* Backward iteration with a more traditional for() loop:
|
||||
* \code
|
||||
* void backward2(CharacterIterator &it) {
|
||||
* UChar c;
|
||||
* for(c=it.last(); c!=CharacterIterator::DONE; c=it.previous()) {
|
||||
* // use c
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* Example for random access:
|
||||
* \code
|
||||
* void random(CharacterIterator &it) {
|
||||
* // set to the third code point from the beginning
|
||||
* it.move32(3, CharacterIterator::kStart);
|
||||
* // get a code point from here without moving the position
|
||||
* UChar32 c=it.current32();
|
||||
* // get the position
|
||||
* int32_t pos=it.getIndex();
|
||||
* // get the previous code unit
|
||||
* UChar u=it.previous();
|
||||
* // move back one more code unit
|
||||
* it.move(-1, CharacterIterator::kCurrent);
|
||||
* // set the position back to where it was
|
||||
* // and read the same code point c and move beyond it
|
||||
* it.setIndex(pos);
|
||||
* if(c!=it.next32PostInc()) {
|
||||
* exit(1); // CharacterIterator inconsistent
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* <p>Examples, especially for the old API:</p>
|
||||
*
|
||||
* Function processing characters, in this example simple output
|
||||
* <pre>
|
||||
* \code
|
||||
* void processChar( UChar c )
|
||||
* {
|
||||
* cout << " " << c;
|
||||
* }
|
||||
* \endcode
|
||||
* </pre>
|
||||
* Traverse the text from start to finish
|
||||
* <pre>
|
||||
* \code
|
||||
* void traverseForward(CharacterIterator& iter)
|
||||
* {
|
||||
* for(UChar c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
|
||||
* processChar(c);
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
* </pre>
|
||||
* Traverse the text backwards, from end to start
|
||||
* <pre>
|
||||
* \code
|
||||
* void traverseBackward(CharacterIterator& iter)
|
||||
* {
|
||||
* for(UChar c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {
|
||||
* processChar(c);
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
* </pre>
|
||||
* Traverse both forward and backward from a given position in the text.
|
||||
* Calls to notBoundary() in this example represents some additional stopping criteria.
|
||||
* <pre>
|
||||
* \code
|
||||
* void traverseOut(CharacterIterator& iter, int32_t pos)
|
||||
* {
|
||||
* UChar c;
|
||||
* for (c = iter.setIndex(pos);
|
||||
* c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
|
||||
* c = iter.next()) {}
|
||||
* int32_t end = iter.getIndex();
|
||||
* for (c = iter.setIndex(pos);
|
||||
* c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
|
||||
* c = iter.previous()) {}
|
||||
* int32_t start = iter.getIndex() + 1;
|
||||
*
|
||||
* cout << "start: " << start << " end: " << end << endl;
|
||||
* for (c = iter.setIndex(start); iter.getIndex() < end; c = iter.next() ) {
|
||||
* processChar(c);
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
* </pre>
|
||||
* Creating a StringCharacterIterator and calling the test functions
|
||||
* <pre>
|
||||
* \code
|
||||
* void CharacterIterator_Example( void )
|
||||
* {
|
||||
* cout << endl << "===== CharacterIterator_Example: =====" << endl;
|
||||
* UnicodeString text("Ein kleiner Satz.");
|
||||
* StringCharacterIterator iterator(text);
|
||||
* cout << "----- traverseForward: -----------" << endl;
|
||||
* traverseForward( iterator );
|
||||
* cout << endl << endl << "----- traverseBackward: ----------" << endl;
|
||||
* traverseBackward( iterator );
|
||||
* cout << endl << endl << "----- traverseOut: ---------------" << endl;
|
||||
* traverseOut( iterator, 7 );
|
||||
* cout << endl << endl << "-----" << endl;
|
||||
* }
|
||||
* \endcode
|
||||
* </pre>
|
||||
*
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
|
||||
public:
|
||||
/**
|
||||
* Origin enumeration for the move() and move32() functions.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
enum EOrigin { kStart, kCurrent, kEnd };
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual ~CharacterIterator();
|
||||
|
||||
/**
|
||||
* Returns a pointer to a new CharacterIterator of the same
|
||||
* concrete class as this one, and referring to the same
|
||||
* character in the same text-storage object as this one. The
|
||||
* caller is responsible for deleting the new clone.
|
||||
* @return a pointer to a new CharacterIterator
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual CharacterIterator* clone(void) const = 0;
|
||||
|
||||
/**
|
||||
* Sets the iterator to refer to the first code unit in its
|
||||
* iteration range, and returns that code unit.
|
||||
* This can be used to begin an iteration with next().
|
||||
* @return the first code unit in its iteration range.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar first(void) = 0;
|
||||
|
||||
/**
|
||||
* Sets the iterator to refer to the first code unit in its
|
||||
* iteration range, returns that code unit, and moves the position
|
||||
* to the second code unit. This is an alternative to setToStart()
|
||||
* for forward iteration with nextPostInc().
|
||||
* @return the first code unit in its iteration range.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar firstPostInc(void);
|
||||
|
||||
/**
|
||||
* Sets the iterator to refer to the first code point in its
|
||||
* iteration range, and returns that code unit,
|
||||
* This can be used to begin an iteration with next32().
|
||||
* Note that an iteration with next32PostInc(), beginning with,
|
||||
* e.g., setToStart() or firstPostInc(), is more efficient.
|
||||
* @return the first code point in its iteration range.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar32 first32(void) = 0;
|
||||
|
||||
/**
|
||||
* Sets the iterator to refer to the first code point in its
|
||||
* iteration range, returns that code point, and moves the position
|
||||
* to the second code point. This is an alternative to setToStart()
|
||||
* for forward iteration with next32PostInc().
|
||||
* @return the first code point in its iteration range.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar32 first32PostInc(void);
|
||||
|
||||
/**
|
||||
* Sets the iterator to refer to the first code unit or code point in its
|
||||
* iteration range. This can be used to begin a forward
|
||||
* iteration with nextPostInc() or next32PostInc().
|
||||
* @return the start position of the iteration range
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
inline int32_t setToStart();
|
||||
|
||||
/**
|
||||
* Sets the iterator to refer to the last code unit in its
|
||||
* iteration range, and returns that code unit.
|
||||
* This can be used to begin an iteration with previous().
|
||||
* @return the last code unit.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar last(void) = 0;
|
||||
|
||||
/**
|
||||
* Sets the iterator to refer to the last code point in its
|
||||
* iteration range, and returns that code unit.
|
||||
* This can be used to begin an iteration with previous32().
|
||||
* @return the last code point.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar32 last32(void) = 0;
|
||||
|
||||
/**
|
||||
* Sets the iterator to the end of its iteration range, just behind
|
||||
* the last code unit or code point. This can be used to begin a backward
|
||||
* iteration with previous() or previous32().
|
||||
* @return the end position of the iteration range
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
inline int32_t setToEnd();
|
||||
|
||||
/**
|
||||
* Sets the iterator to refer to the "position"-th code unit
|
||||
* in the text-storage object the iterator refers to, and
|
||||
* returns that code unit.
|
||||
* @param position the "position"-th code unit in the text-storage object
|
||||
* @return the "position"-th code unit.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar setIndex(int32_t position) = 0;
|
||||
|
||||
/**
|
||||
* Sets the iterator to refer to the beginning of the code point
|
||||
* that contains the "position"-th code unit
|
||||
* in the text-storage object the iterator refers to, and
|
||||
* returns that code point.
|
||||
* The current position is adjusted to the beginning of the code point
|
||||
* (its first code unit).
|
||||
* @param position the "position"-th code unit in the text-storage object
|
||||
* @return the "position"-th code point.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar32 setIndex32(int32_t position) = 0;
|
||||
|
||||
/**
|
||||
* Returns the code unit the iterator currently refers to.
|
||||
* @return the current code unit.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar current(void) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the code point the iterator currently refers to.
|
||||
* @return the current code point.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar32 current32(void) const = 0;
|
||||
|
||||
/**
|
||||
* Advances to the next code unit in the iteration range
|
||||
* (toward endIndex()), and returns that code unit. If there are
|
||||
* no more code units to return, returns DONE.
|
||||
* @return the next code unit.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar next(void) = 0;
|
||||
|
||||
/**
|
||||
* Advances to the next code point in the iteration range
|
||||
* (toward endIndex()), and returns that code point. If there are
|
||||
* no more code points to return, returns DONE.
|
||||
* Note that iteration with "pre-increment" semantics is less
|
||||
* efficient than iteration with "post-increment" semantics
|
||||
* that is provided by next32PostInc().
|
||||
* @return the next code point.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar32 next32(void) = 0;
|
||||
|
||||
/**
|
||||
* Advances to the previous code unit in the iteration range
|
||||
* (toward startIndex()), and returns that code unit. If there are
|
||||
* no more code units to return, returns DONE.
|
||||
* @return the previous code unit.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar previous(void) = 0;
|
||||
|
||||
/**
|
||||
* Advances to the previous code point in the iteration range
|
||||
* (toward startIndex()), and returns that code point. If there are
|
||||
* no more code points to return, returns DONE.
|
||||
* @return the previous code point.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UChar32 previous32(void) = 0;
|
||||
|
||||
/**
|
||||
* Returns FALSE if there are no more code units or code points
|
||||
* before the current position in the iteration range.
|
||||
* This is used with previous() or previous32() in backward
|
||||
* iteration.
|
||||
* @return FALSE if there are no more code units or code points
|
||||
* before the current position in the iteration range, return TRUE otherwise.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool hasPrevious() = 0;
|
||||
|
||||
/**
|
||||
* Returns the numeric index in the underlying text-storage
|
||||
* object of the character returned by first(). Since it's
|
||||
* possible to create an iterator that iterates across only
|
||||
* part of a text-storage object, this number isn't
|
||||
* necessarily 0.
|
||||
* @returns the numeric index in the underlying text-storage
|
||||
* object of the character returned by first().
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
inline int32_t startIndex(void) const;
|
||||
|
||||
/**
|
||||
* Returns the numeric index in the underlying text-storage
|
||||
* object of the position immediately BEYOND the character
|
||||
* returned by last().
|
||||
* @return the numeric index in the underlying text-storage
|
||||
* object of the position immediately BEYOND the character
|
||||
* returned by last().
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
inline int32_t endIndex(void) const;
|
||||
|
||||
/**
|
||||
* Returns the numeric index in the underlying text-storage
|
||||
* object of the character the iterator currently refers to
|
||||
* (i.e., the character returned by current()).
|
||||
* @return the numberic index in the text-storage object of
|
||||
* the character the iterator currently refers to
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
inline int32_t getIndex(void) const;
|
||||
|
||||
/**
|
||||
* Returns the length of the entire text in the underlying
|
||||
* text-storage object.
|
||||
* @return the length of the entire text in the text-storage object
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
inline int32_t getLength() const;
|
||||
|
||||
/**
|
||||
* Moves the current position relative to the start or end of the
|
||||
* iteration range, or relative to the current position itself.
|
||||
* The movement is expressed in numbers of code units forward
|
||||
* or backward by specifying a positive or negative delta.
|
||||
* @param delta the position relative to origin. A positive delta means forward;
|
||||
* a negative delta means backward.
|
||||
* @param origin Origin enumeration {kStart, kCurrent, kEnd}
|
||||
* @return the new position
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t move(int32_t delta, EOrigin origin) = 0;
|
||||
|
||||
/**
|
||||
* Moves the current position relative to the start or end of the
|
||||
* iteration range, or relative to the current position itself.
|
||||
* The movement is expressed in numbers of code points forward
|
||||
* or backward by specifying a positive or negative delta.
|
||||
* @param delta the position relative to origin. A positive delta means forward;
|
||||
* a negative delta means backward.
|
||||
* @param origin Origin enumeration {kStart, kCurrent, kEnd}
|
||||
* @return the new position
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual int32_t move32(int32_t delta, EOrigin origin) = 0;
|
||||
|
||||
/**
|
||||
* Copies the text under iteration into the UnicodeString
|
||||
* referred to by "result".
|
||||
* @param result Receives a copy of the text under iteration.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void getText(UnicodeString& result) = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Empty constructor.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
CharacterIterator();
|
||||
|
||||
/**
|
||||
* Constructor, just setting the length field in this base class.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
CharacterIterator(int32_t length);
|
||||
|
||||
/**
|
||||
* Constructor, just setting the length and position fields in this base class.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
CharacterIterator(int32_t length, int32_t position);
|
||||
|
||||
/**
|
||||
* Constructor, just setting the length, start, end, and position fields in this base class.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* @param that The CharacterIterator to be copied
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
CharacterIterator(const CharacterIterator &that);
|
||||
|
||||
/**
|
||||
* Assignment operator. Sets this CharacterIterator to have the same behavior,
|
||||
* as the one passed in.
|
||||
* @param that The CharacterIterator passed in.
|
||||
* @return the newly set CharacterIterator.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
CharacterIterator &operator=(const CharacterIterator &that);
|
||||
|
||||
/**
|
||||
* Base class text length field.
|
||||
* Necessary this for correct getText() and hashCode().
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t textLength;
|
||||
|
||||
/**
|
||||
* Base class field for the current position.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t pos;
|
||||
|
||||
/**
|
||||
* Base class field for the start of the iteration range.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t begin;
|
||||
|
||||
/**
|
||||
* Base class field for the end of the iteration range.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t end;
|
||||
};
|
||||
|
||||
inline UBool
|
||||
ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
inline int32_t
|
||||
CharacterIterator::setToStart() {
|
||||
return move(0, kStart);
|
||||
}
|
||||
|
||||
inline int32_t
|
||||
CharacterIterator::setToEnd() {
|
||||
return move(0, kEnd);
|
||||
}
|
||||
|
||||
inline int32_t
|
||||
CharacterIterator::startIndex(void) const {
|
||||
return begin;
|
||||
}
|
||||
|
||||
inline int32_t
|
||||
CharacterIterator::endIndex(void) const {
|
||||
return end;
|
||||
}
|
||||
|
||||
inline int32_t
|
||||
CharacterIterator::getIndex(void) const {
|
||||
return pos;
|
||||
}
|
||||
|
||||
inline int32_t
|
||||
CharacterIterator::getLength(void) const {
|
||||
return textLength;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif
|
||||
@ -1,594 +0,0 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 1997-2013, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
* File CHOICFMT.H
|
||||
*
|
||||
* Modification History:
|
||||
*
|
||||
* Date Name Description
|
||||
* 02/19/97 aliu Converted from java.
|
||||
* 03/20/97 helena Finished first cut of implementation and got rid
|
||||
* of nextDouble/previousDouble and replaced with
|
||||
* boolean array.
|
||||
* 4/10/97 aliu Clean up. Modified to work on AIX.
|
||||
* 8/6/97 nos Removed overloaded constructor, member var 'buffer'.
|
||||
* 07/22/98 stephen Removed operator!= (implemented in Format)
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef CHOICFMT_H
|
||||
#define CHOICFMT_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Choice Format.
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
#ifndef U_HIDE_DEPRECATED_API
|
||||
|
||||
#include "unicode/fieldpos.h"
|
||||
#include "unicode/format.h"
|
||||
#include "unicode/messagepattern.h"
|
||||
#include "unicode/numfmt.h"
|
||||
#include "unicode/unistr.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class MessageFormat;
|
||||
|
||||
/**
|
||||
* ChoiceFormat converts between ranges of numeric values and strings for those ranges.
|
||||
* The strings must conform to the MessageFormat pattern syntax.
|
||||
*
|
||||
* <p><em><code>ChoiceFormat</code> is probably not what you need.
|
||||
* Please use <code>MessageFormat</code>
|
||||
* with <code>plural</code> arguments for proper plural selection,
|
||||
* and <code>select</code> arguments for simple selection among a fixed set of choices!</em></p>
|
||||
*
|
||||
* <p>A <code>ChoiceFormat</code> splits
|
||||
* the real number line \htmlonly<code>-∞</code> to
|
||||
* <code>+∞</code>\endhtmlonly into two
|
||||
* or more contiguous ranges. Each range is mapped to a
|
||||
* string.</p>
|
||||
*
|
||||
* <p><code>ChoiceFormat</code> was originally intended
|
||||
* for displaying grammatically correct
|
||||
* plurals such as "There is one file." vs. "There are 2 files."
|
||||
* <em>However,</em> plural rules for many languages
|
||||
* are too complex for the capabilities of ChoiceFormat,
|
||||
* and its requirement of specifying the precise rules for each message
|
||||
* is unmanageable for translators.</p>
|
||||
*
|
||||
* <p>There are two methods of defining a <code>ChoiceFormat</code>; both
|
||||
* are equivalent. The first is by using a string pattern. This is the
|
||||
* preferred method in most cases. The second method is through direct
|
||||
* specification of the arrays that logically make up the
|
||||
* <code>ChoiceFormat</code>.</p>
|
||||
*
|
||||
* <p>Note: Typically, choice formatting is done (if done at all) via <code>MessageFormat</code>
|
||||
* with a <code>choice</code> argument type,
|
||||
* rather than using a stand-alone <code>ChoiceFormat</code>.</p>
|
||||
*
|
||||
* <h5>Patterns and Their Interpretation</h5>
|
||||
*
|
||||
* <p>The pattern string defines the range boundaries and the strings for each number range.
|
||||
* Syntax:
|
||||
* <pre>
|
||||
* choiceStyle = number separator message ('|' number separator message)*
|
||||
* number = normal_number | ['-'] \htmlonly∞\endhtmlonly (U+221E, infinity)
|
||||
* normal_number = double value (unlocalized ASCII string)
|
||||
* separator = less_than | less_than_or_equal
|
||||
* less_than = '<'
|
||||
* less_than_or_equal = '#' | \htmlonly≤\endhtmlonly (U+2264)
|
||||
* message: see {@link MessageFormat}
|
||||
* </pre>
|
||||
* Pattern_White_Space between syntax elements is ignored, except
|
||||
* around each range's sub-message.</p>
|
||||
*
|
||||
* <p>Each numeric sub-range extends from the current range's number
|
||||
* to the next range's number.
|
||||
* The number itself is included in its range if a <code>less_than_or_equal</code> sign is used,
|
||||
* and excluded from its range (and instead included in the previous range)
|
||||
* if a <code>less_than</code> sign is used.</p>
|
||||
*
|
||||
* <p>When a <code>ChoiceFormat</code> is constructed from
|
||||
* arrays of numbers, closure flags and strings,
|
||||
* they are interpreted just like
|
||||
* the sequence of <code>(number separator string)</code> in an equivalent pattern string.
|
||||
* <code>closure[i]==TRUE</code> corresponds to a <code>less_than</code> separator sign.
|
||||
* The equivalent pattern string will be constructed automatically.</p>
|
||||
*
|
||||
* <p>During formatting, a number is mapped to the first range
|
||||
* where the number is not greater than the range's upper limit.
|
||||
* That range's message string is returned. A NaN maps to the very first range.</p>
|
||||
*
|
||||
* <p>During parsing, a range is selected for the longest match of
|
||||
* any range's message. That range's number is returned, ignoring the separator/closure.
|
||||
* Only a simple string match is performed, without parsing of arguments that
|
||||
* might be specified in the message strings.</p>
|
||||
*
|
||||
* <p>Note that the first range's number is ignored in formatting
|
||||
* but may be returned from parsing.</p>
|
||||
*
|
||||
* <h5>Examples</h5>
|
||||
*
|
||||
* <p>Here is an example of two arrays that map the number
|
||||
* <code>1..7</code> to the English day of the week abbreviations
|
||||
* <code>Sun..Sat</code>. No closures array is given; this is the same as
|
||||
* specifying all closures to be <code>FALSE</code>.</p>
|
||||
*
|
||||
* <pre> {1,2,3,4,5,6,7},
|
||||
* {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}</pre>
|
||||
*
|
||||
* <p>Here is an example that maps the ranges [-Inf, 1), [1, 1], and (1,
|
||||
* +Inf] to three strings. That is, the number line is split into three
|
||||
* ranges: x < 1.0, x = 1.0, and x > 1.0.
|
||||
* (The round parentheses in the notation above indicate an exclusive boundary,
|
||||
* like the turned bracket in European notation: [-Inf, 1) == [-Inf, 1[ )</p>
|
||||
*
|
||||
* <pre> {0, 1, 1},
|
||||
* {FALSE, FALSE, TRUE},
|
||||
* {"no files", "one file", "many files"}</pre>
|
||||
*
|
||||
* <p>Here is an example that shows formatting and parsing: </p>
|
||||
*
|
||||
* \code
|
||||
* #include <unicode/choicfmt.h>
|
||||
* #include <unicode/unistr.h>
|
||||
* #include <iostream.h>
|
||||
*
|
||||
* int main(int argc, char *argv[]) {
|
||||
* double limits[] = {1,2,3,4,5,6,7};
|
||||
* UnicodeString monthNames[] = {
|
||||
* "Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
|
||||
* ChoiceFormat fmt(limits, monthNames, 7);
|
||||
* UnicodeString str;
|
||||
* char buf[256];
|
||||
* for (double x = 1.0; x <= 8.0; x += 1.0) {
|
||||
* fmt.format(x, str);
|
||||
* str.extract(0, str.length(), buf, 256, "");
|
||||
* str.truncate(0);
|
||||
* cout << x << " -> "
|
||||
* << buf << endl;
|
||||
* }
|
||||
* cout << endl;
|
||||
* return 0;
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* <p><em>User subclasses are not supported.</em> While clients may write
|
||||
* subclasses, such code will not necessarily work and will not be
|
||||
* guaranteed to work stably from release to release.
|
||||
*
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
class U_I18N_API ChoiceFormat: public NumberFormat {
|
||||
public:
|
||||
/**
|
||||
* Constructs a new ChoiceFormat from the pattern string.
|
||||
*
|
||||
* @param pattern Pattern used to construct object.
|
||||
* @param status Output param to receive success code. If the
|
||||
* pattern cannot be parsed, set to failure code.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
ChoiceFormat(const UnicodeString& pattern,
|
||||
UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new ChoiceFormat with the given limits and message strings.
|
||||
* All closure flags default to <code>FALSE</code>,
|
||||
* equivalent to <code>less_than_or_equal</code> separators.
|
||||
*
|
||||
* Copies the limits and formats instead of adopting them.
|
||||
*
|
||||
* @param limits Array of limit values.
|
||||
* @param formats Array of formats.
|
||||
* @param count Size of 'limits' and 'formats' arrays.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
ChoiceFormat(const double* limits,
|
||||
const UnicodeString* formats,
|
||||
int32_t count );
|
||||
|
||||
/**
|
||||
* Constructs a new ChoiceFormat with the given limits, closure flags and message strings.
|
||||
*
|
||||
* Copies the limits and formats instead of adopting them.
|
||||
*
|
||||
* @param limits Array of limit values
|
||||
* @param closures Array of booleans specifying whether each
|
||||
* element of 'limits' is open or closed. If FALSE, then the
|
||||
* corresponding limit number is a member of its range.
|
||||
* If TRUE, then the limit number belongs to the previous range it.
|
||||
* @param formats Array of formats
|
||||
* @param count Size of 'limits', 'closures', and 'formats' arrays
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
ChoiceFormat(const double* limits,
|
||||
const UBool* closures,
|
||||
const UnicodeString* formats,
|
||||
int32_t count);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* @param that ChoiceFormat object to be copied from
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
ChoiceFormat(const ChoiceFormat& that);
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
*
|
||||
* @param that ChoiceFormat object to be copied
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
const ChoiceFormat& operator=(const ChoiceFormat& that);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual ~ChoiceFormat();
|
||||
|
||||
/**
|
||||
* Clones this Format object. The caller owns the
|
||||
* result and must delete it when done.
|
||||
*
|
||||
* @return a copy of this object
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual Format* clone(void) const;
|
||||
|
||||
/**
|
||||
* Returns true if the given Format objects are semantically equal.
|
||||
* Objects of different subclasses are considered unequal.
|
||||
*
|
||||
* @param other ChoiceFormat object to be compared
|
||||
* @return true if other is the same as this.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
/**
|
||||
* Sets the pattern.
|
||||
* @param pattern The pattern to be applied.
|
||||
* @param status Output param set to success/failure code on
|
||||
* exit. If the pattern is invalid, this will be
|
||||
* set to a failure result.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual void applyPattern(const UnicodeString& pattern,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Sets the pattern.
|
||||
* @param pattern The pattern to be applied.
|
||||
* @param parseError Struct to receive information on position
|
||||
* of error if an error is encountered
|
||||
* @param status Output param set to success/failure code on
|
||||
* exit. If the pattern is invalid, this will be
|
||||
* set to a failure result.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual void applyPattern(const UnicodeString& pattern,
|
||||
UParseError& parseError,
|
||||
UErrorCode& status);
|
||||
/**
|
||||
* Gets the pattern.
|
||||
*
|
||||
* @param pattern Output param which will receive the pattern
|
||||
* Previous contents are deleted.
|
||||
* @return A reference to 'pattern'
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual UnicodeString& toPattern(UnicodeString &pattern) const;
|
||||
|
||||
/**
|
||||
* Sets the choices to be used in formatting.
|
||||
* For details see the constructor with the same parameter list.
|
||||
*
|
||||
* @param limitsToCopy Contains the top value that you want
|
||||
* parsed with that format,and should be in
|
||||
* ascending sorted order. When formatting X,
|
||||
* the choice will be the i, where limit[i]
|
||||
* <= X < limit[i+1].
|
||||
* @param formatsToCopy The format strings you want to use for each limit.
|
||||
* @param count The size of the above arrays.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual void setChoices(const double* limitsToCopy,
|
||||
const UnicodeString* formatsToCopy,
|
||||
int32_t count );
|
||||
|
||||
/**
|
||||
* Sets the choices to be used in formatting.
|
||||
* For details see the constructor with the same parameter list.
|
||||
*
|
||||
* @param limits Array of limits
|
||||
* @param closures Array of limit booleans
|
||||
* @param formats Array of format string
|
||||
* @param count The size of the above arrays
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual void setChoices(const double* limits,
|
||||
const UBool* closures,
|
||||
const UnicodeString* formats,
|
||||
int32_t count);
|
||||
|
||||
/**
|
||||
* Returns NULL and 0.
|
||||
* Before ICU 4.8, this used to return the choice limits array.
|
||||
*
|
||||
* @param count Will be set to 0.
|
||||
* @return NULL
|
||||
* @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.
|
||||
*/
|
||||
virtual const double* getLimits(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Returns NULL and 0.
|
||||
* Before ICU 4.8, this used to return the limit booleans array.
|
||||
*
|
||||
* @param count Will be set to 0.
|
||||
* @return NULL
|
||||
* @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.
|
||||
*/
|
||||
virtual const UBool* getClosures(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Returns NULL and 0.
|
||||
* Before ICU 4.8, this used to return the array of choice strings.
|
||||
*
|
||||
* @param count Will be set to 0.
|
||||
* @return NULL
|
||||
* @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.
|
||||
*/
|
||||
virtual const UnicodeString* getFormats(int32_t& count) const;
|
||||
|
||||
|
||||
using NumberFormat::format;
|
||||
|
||||
/**
|
||||
* Formats a double number using this object's choices.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual UnicodeString& format(double number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
/**
|
||||
* Formats an int32_t number using this object's choices.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual UnicodeString& format(int32_t number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
|
||||
/**
|
||||
* Formats an int64_t number using this object's choices.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual UnicodeString& format(int64_t number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
|
||||
/**
|
||||
* Formats an array of objects using this object's choices.
|
||||
*
|
||||
* @param objs The array of objects to be formatted.
|
||||
* @param cnt The size of objs.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param success Output param set to success/failure code on
|
||||
* exit.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable* objs,
|
||||
int32_t cnt,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& success) const;
|
||||
|
||||
using NumberFormat::parse;
|
||||
|
||||
/**
|
||||
* Looks for the longest match of any message string on the input text and,
|
||||
* if there is a match, sets the result object to the corresponding range's number.
|
||||
*
|
||||
* If no string matches, then the parsePosition is unchanged.
|
||||
*
|
||||
* @param text The text to be parsed.
|
||||
* @param result Formattable to be set to the parse result.
|
||||
* If parse fails, return contents are undefined.
|
||||
* @param parsePosition The position to start parsing at on input.
|
||||
* On output, moved to after the last successfully
|
||||
* parse character. On parse failure, does not change.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual void parse(const UnicodeString& text,
|
||||
Formattable& result,
|
||||
ParsePosition& parsePosition) const;
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Part of ICU's "poor man's RTTI".
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
|
||||
/**
|
||||
* Returns the class ID for this class. This is useful only for
|
||||
* comparing to a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . Derived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Converts a double value to a string.
|
||||
* @param value the double number to be converted.
|
||||
* @param string the result string.
|
||||
* @return the converted string.
|
||||
*/
|
||||
static UnicodeString& dtos(double value, UnicodeString& string);
|
||||
|
||||
ChoiceFormat(); // default constructor not implemented
|
||||
|
||||
/**
|
||||
* Construct a new ChoiceFormat with the limits and the corresponding formats
|
||||
* based on the pattern.
|
||||
*
|
||||
* @param newPattern Pattern used to construct object.
|
||||
* @param parseError Struct to receive information on position
|
||||
* of error if an error is encountered.
|
||||
* @param status Output param to receive success code. If the
|
||||
* pattern cannot be parsed, set to failure code.
|
||||
*/
|
||||
ChoiceFormat(const UnicodeString& newPattern,
|
||||
UParseError& parseError,
|
||||
UErrorCode& status);
|
||||
|
||||
friend class MessageFormat;
|
||||
|
||||
virtual void setChoices(const double* limits,
|
||||
const UBool* closures,
|
||||
const UnicodeString* formats,
|
||||
int32_t count,
|
||||
UErrorCode &errorCode);
|
||||
|
||||
/**
|
||||
* Finds the ChoiceFormat sub-message for the given number.
|
||||
* @param pattern A MessagePattern.
|
||||
* @param partIndex the index of the first ChoiceFormat argument style part.
|
||||
* @param number a number to be mapped to one of the ChoiceFormat argument's intervals
|
||||
* @return the sub-message start part index.
|
||||
*/
|
||||
static int32_t findSubMessage(const MessagePattern &pattern, int32_t partIndex, double number);
|
||||
|
||||
static double parseArgument(
|
||||
const MessagePattern &pattern, int32_t partIndex,
|
||||
const UnicodeString &source, ParsePosition &pos);
|
||||
|
||||
/**
|
||||
* Matches the pattern string from the end of the partIndex to
|
||||
* the beginning of the limitPartIndex,
|
||||
* including all syntax except SKIP_SYNTAX,
|
||||
* against the source string starting at sourceOffset.
|
||||
* If they match, returns the length of the source string match.
|
||||
* Otherwise returns -1.
|
||||
*/
|
||||
static int32_t matchStringUntilLimitPart(
|
||||
const MessagePattern &pattern, int32_t partIndex, int32_t limitPartIndex,
|
||||
const UnicodeString &source, int32_t sourceOffset);
|
||||
|
||||
/**
|
||||
* Some of the ChoiceFormat constructors do not have a UErrorCode paramater.
|
||||
* We need _some_ way to provide one for the MessagePattern constructor.
|
||||
* Alternatively, the MessagePattern could be a pointer field, but that is
|
||||
* not nice either.
|
||||
*/
|
||||
UErrorCode constructorErrorCode;
|
||||
|
||||
/**
|
||||
* The MessagePattern which contains the parsed structure of the pattern string.
|
||||
*
|
||||
* Starting with ICU 4.8, the MessagePattern contains a sequence of
|
||||
* numeric/selector/message parts corresponding to the parsed pattern.
|
||||
* For details see the MessagePattern class API docs.
|
||||
*/
|
||||
MessagePattern msgPattern;
|
||||
|
||||
/**
|
||||
* Docs & fields from before ICU 4.8, before MessagePattern was used.
|
||||
* Commented out, and left only for explanation of semantics.
|
||||
* --------
|
||||
* Each ChoiceFormat divides the range -Inf..+Inf into fCount
|
||||
* intervals. The intervals are:
|
||||
*
|
||||
* 0: fChoiceLimits[0]..fChoiceLimits[1]
|
||||
* 1: fChoiceLimits[1]..fChoiceLimits[2]
|
||||
* ...
|
||||
* fCount-2: fChoiceLimits[fCount-2]..fChoiceLimits[fCount-1]
|
||||
* fCount-1: fChoiceLimits[fCount-1]..+Inf
|
||||
*
|
||||
* Interval 0 is special; during formatting (mapping numbers to
|
||||
* strings), it also contains all numbers less than
|
||||
* fChoiceLimits[0], as well as NaN values.
|
||||
*
|
||||
* Interval i maps to and from string fChoiceFormats[i]. When
|
||||
* parsing (mapping strings to numbers), then intervals map to
|
||||
* their lower limit, that is, interval i maps to fChoiceLimit[i].
|
||||
*
|
||||
* The intervals may be closed, half open, or open. This affects
|
||||
* formatting but does not affect parsing. Interval i is affected
|
||||
* by fClosures[i] and fClosures[i+1]. If fClosures[i]
|
||||
* is FALSE, then the value fChoiceLimits[i] is in interval i.
|
||||
* That is, intervals i and i are:
|
||||
*
|
||||
* i-1: ... x < fChoiceLimits[i]
|
||||
* i: fChoiceLimits[i] <= x ...
|
||||
*
|
||||
* If fClosures[i] is TRUE, then the value fChoiceLimits[i] is
|
||||
* in interval i-1. That is, intervals i-1 and i are:
|
||||
*
|
||||
* i-1: ... x <= fChoiceLimits[i]
|
||||
* i: fChoiceLimits[i] < x ...
|
||||
*
|
||||
* Because of the nature of interval 0, fClosures[0] has no
|
||||
* effect.
|
||||
*/
|
||||
// double* fChoiceLimits;
|
||||
// UBool* fClosures;
|
||||
// UnicodeString* fChoiceFormats;
|
||||
// int32_t fCount;
|
||||
};
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // U_HIDE_DEPRECATED_API
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // CHOICFMT_H
|
||||
//eof
|
||||
@ -1,404 +0,0 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1997-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Collation Element Iterator.
|
||||
*/
|
||||
|
||||
/**
|
||||
* File coleitr.h
|
||||
*
|
||||
* Created by: Helena Shih
|
||||
*
|
||||
* Modification History:
|
||||
*
|
||||
* Date Name Description
|
||||
*
|
||||
* 8/18/97 helena Added internal API documentation.
|
||||
* 08/03/98 erm Synched with 1.2 version CollationElementIterator.java
|
||||
* 12/10/99 aliu Ported Thai collation support from Java.
|
||||
* 01/25/01 swquek Modified into a C++ wrapper calling C APIs (ucoliter.h)
|
||||
* 02/19/01 swquek Removed CollationElementsIterator() since it is
|
||||
* private constructor and no calls are made to it
|
||||
* 2012-2014 markus Rewritten in C++ again.
|
||||
*/
|
||||
|
||||
#ifndef COLEITR_H
|
||||
#define COLEITR_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_COLLATION
|
||||
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/uobject.h"
|
||||
|
||||
struct UCollationElements;
|
||||
struct UHashtable;
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
struct CollationData;
|
||||
|
||||
class CollationIterator;
|
||||
class RuleBasedCollator;
|
||||
class UCollationPCE;
|
||||
class UVector32;
|
||||
|
||||
/**
|
||||
* The CollationElementIterator class is used as an iterator to walk through
|
||||
* each character of an international string. Use the iterator to return the
|
||||
* ordering priority of the positioned character. The ordering priority of a
|
||||
* character, which we refer to as a key, defines how a character is collated in
|
||||
* the given collation object.
|
||||
* For example, consider the following in Slovak and in traditional Spanish collation:
|
||||
* <pre>
|
||||
* "ca" -> the first key is key('c') and second key is key('a').
|
||||
* "cha" -> the first key is key('ch') and second key is key('a').</pre>
|
||||
* And in German phonebook collation,
|
||||
* <pre> \htmlonly "æb"-> the first key is key('a'), the second key is key('e'), and
|
||||
* the third key is key('b'). \endhtmlonly </pre>
|
||||
* The key of a character, is an integer composed of primary order(short),
|
||||
* secondary order(char), and tertiary order(char). Java strictly defines the
|
||||
* size and signedness of its primitive data types. Therefore, the static
|
||||
* functions primaryOrder(), secondaryOrder(), and tertiaryOrder() return
|
||||
* int32_t to ensure the correctness of the key value.
|
||||
* <p>Example of the iterator usage: (without error checking)
|
||||
* <pre>
|
||||
* \code
|
||||
* void CollationElementIterator_Example()
|
||||
* {
|
||||
* UnicodeString str = "This is a test";
|
||||
* UErrorCode success = U_ZERO_ERROR;
|
||||
* RuleBasedCollator* rbc =
|
||||
* (RuleBasedCollator*) RuleBasedCollator::createInstance(success);
|
||||
* CollationElementIterator* c =
|
||||
* rbc->createCollationElementIterator( str );
|
||||
* int32_t order = c->next(success);
|
||||
* c->reset();
|
||||
* order = c->previous(success);
|
||||
* delete c;
|
||||
* delete rbc;
|
||||
* }
|
||||
* \endcode
|
||||
* </pre>
|
||||
* <p>
|
||||
* The method next() returns the collation order of the next character based on
|
||||
* the comparison level of the collator. The method previous() returns the
|
||||
* collation order of the previous character based on the comparison level of
|
||||
* the collator. The Collation Element Iterator moves only in one direction
|
||||
* between calls to reset(), setOffset(), or setText(). That is, next()
|
||||
* and previous() can not be inter-used. Whenever previous() is to be called after
|
||||
* next() or vice versa, reset(), setOffset() or setText() has to be called first
|
||||
* to reset the status, shifting pointers to either the end or the start of
|
||||
* the string (reset() or setText()), or the specified position (setOffset()).
|
||||
* Hence at the next call of next() or previous(), the first or last collation order,
|
||||
* or collation order at the spefcifieid position will be returned. If a change of
|
||||
* direction is done without one of these calls, the result is undefined.
|
||||
* <p>
|
||||
* The result of a forward iterate (next()) and reversed result of the backward
|
||||
* iterate (previous()) on the same string are equivalent, if collation orders
|
||||
* with the value 0 are ignored.
|
||||
* Character based on the comparison level of the collator. A collation order
|
||||
* consists of primary order, secondary order and tertiary order. The data
|
||||
* type of the collation order is <strong>int32_t</strong>.
|
||||
*
|
||||
* Note, CollationElementIterator should not be subclassed.
|
||||
* @see Collator
|
||||
* @see RuleBasedCollator
|
||||
* @version 1.8 Jan 16 2001
|
||||
*/
|
||||
class U_I18N_API CollationElementIterator U_FINAL : public UObject {
|
||||
public:
|
||||
|
||||
// CollationElementIterator public data member ------------------------------
|
||||
|
||||
enum {
|
||||
/**
|
||||
* NULLORDER indicates that an error has occured while processing
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
NULLORDER = (int32_t)0xffffffff
|
||||
};
|
||||
|
||||
// CollationElementIterator public constructor/destructor -------------------
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* @param other the object to be copied from
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
CollationElementIterator(const CollationElementIterator& other);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual ~CollationElementIterator();
|
||||
|
||||
// CollationElementIterator public methods ----------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if "other" is the same as "this"
|
||||
*
|
||||
* @param other the object to be compared
|
||||
* @return true if "other" is the same as "this"
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UBool operator==(const CollationElementIterator& other) const;
|
||||
|
||||
/**
|
||||
* Returns true if "other" is not the same as "this".
|
||||
*
|
||||
* @param other the object to be compared
|
||||
* @return true if "other" is not the same as "this"
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UBool operator!=(const CollationElementIterator& other) const;
|
||||
|
||||
/**
|
||||
* Resets the cursor to the beginning of the string.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void reset(void);
|
||||
|
||||
/**
|
||||
* Gets the ordering priority of the next character in the string.
|
||||
* @param status the error code status.
|
||||
* @return the next character's ordering. otherwise returns NULLORDER if an
|
||||
* error has occured or if the end of string has been reached
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t next(UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Get the ordering priority of the previous collation element in the string.
|
||||
* @param status the error code status.
|
||||
* @return the previous element's ordering. otherwise returns NULLORDER if an
|
||||
* error has occured or if the start of string has been reached
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t previous(UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Gets the primary order of a collation order.
|
||||
* @param order the collation order
|
||||
* @return the primary order of a collation order.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static inline int32_t primaryOrder(int32_t order);
|
||||
|
||||
/**
|
||||
* Gets the secondary order of a collation order.
|
||||
* @param order the collation order
|
||||
* @return the secondary order of a collation order.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static inline int32_t secondaryOrder(int32_t order);
|
||||
|
||||
/**
|
||||
* Gets the tertiary order of a collation order.
|
||||
* @param order the collation order
|
||||
* @return the tertiary order of a collation order.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static inline int32_t tertiaryOrder(int32_t order);
|
||||
|
||||
/**
|
||||
* Return the maximum length of any expansion sequences that end with the
|
||||
* specified comparison order.
|
||||
* @param order a collation order returned by previous or next.
|
||||
* @return maximum size of the expansion sequences ending with the collation
|
||||
* element or 1 if collation element does not occur at the end of any
|
||||
* expansion sequence
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t getMaxExpansion(int32_t order) const;
|
||||
|
||||
/**
|
||||
* Gets the comparison order in the desired strength. Ignore the other
|
||||
* differences.
|
||||
* @param order The order value
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t strengthOrder(int32_t order) const;
|
||||
|
||||
/**
|
||||
* Sets the source string.
|
||||
* @param str the source string.
|
||||
* @param status the error code status.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setText(const UnicodeString& str, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Sets the source string.
|
||||
* @param str the source character iterator.
|
||||
* @param status the error code status.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setText(CharacterIterator& str, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Checks if a comparison order is ignorable.
|
||||
* @param order the collation order.
|
||||
* @return TRUE if a character is ignorable, FALSE otherwise.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static inline UBool isIgnorable(int32_t order);
|
||||
|
||||
/**
|
||||
* Gets the offset of the currently processed character in the source string.
|
||||
* @return the offset of the character.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
int32_t getOffset(void) const;
|
||||
|
||||
/**
|
||||
* Sets the offset of the currently processed character in the source string.
|
||||
* @param newOffset the new offset.
|
||||
* @param status the error code status.
|
||||
* @return the offset of the character.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setOffset(int32_t newOffset, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID();
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/** @internal */
|
||||
static inline CollationElementIterator *fromUCollationElements(UCollationElements *uc) {
|
||||
return reinterpret_cast<CollationElementIterator *>(uc);
|
||||
}
|
||||
/** @internal */
|
||||
static inline const CollationElementIterator *fromUCollationElements(const UCollationElements *uc) {
|
||||
return reinterpret_cast<const CollationElementIterator *>(uc);
|
||||
}
|
||||
/** @internal */
|
||||
inline UCollationElements *toUCollationElements() {
|
||||
return reinterpret_cast<UCollationElements *>(this);
|
||||
}
|
||||
/** @internal */
|
||||
inline const UCollationElements *toUCollationElements() const {
|
||||
return reinterpret_cast<const UCollationElements *>(this);
|
||||
}
|
||||
#endif // U_HIDE_INTERNAL_API
|
||||
|
||||
private:
|
||||
friend class RuleBasedCollator;
|
||||
friend class UCollationPCE;
|
||||
|
||||
/**
|
||||
* CollationElementIterator constructor. This takes the source string and the
|
||||
* collation object. The cursor will walk thru the source string based on the
|
||||
* predefined collation rules. If the source string is empty, NULLORDER will
|
||||
* be returned on the calls to next().
|
||||
* @param sourceText the source string.
|
||||
* @param order the collation object.
|
||||
* @param status the error code status.
|
||||
*/
|
||||
CollationElementIterator(const UnicodeString& sourceText,
|
||||
const RuleBasedCollator* order, UErrorCode& status);
|
||||
// Note: The constructors should take settings & tailoring, not a collator,
|
||||
// to avoid circular dependencies.
|
||||
// However, for operator==() we would need to be able to compare tailoring data for equality
|
||||
// without making CollationData or CollationTailoring depend on TailoredSet.
|
||||
// (See the implementation of RuleBasedCollator::operator==().)
|
||||
// That might require creating an intermediate class that would be used
|
||||
// by both CollationElementIterator and RuleBasedCollator
|
||||
// but only contain the part of RBC== related to data and rules.
|
||||
|
||||
/**
|
||||
* CollationElementIterator constructor. This takes the source string and the
|
||||
* collation object. The cursor will walk thru the source string based on the
|
||||
* predefined collation rules. If the source string is empty, NULLORDER will
|
||||
* be returned on the calls to next().
|
||||
* @param sourceText the source string.
|
||||
* @param order the collation object.
|
||||
* @param status the error code status.
|
||||
*/
|
||||
CollationElementIterator(const CharacterIterator& sourceText,
|
||||
const RuleBasedCollator* order, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
*
|
||||
* @param other the object to be copied
|
||||
*/
|
||||
const CollationElementIterator&
|
||||
operator=(const CollationElementIterator& other);
|
||||
|
||||
CollationElementIterator(); // default constructor not implemented
|
||||
|
||||
/** Normalizes dir_=1 (just after setOffset()) to dir_=0 (just after reset()). */
|
||||
inline int8_t normalizeDir() const { return dir_ == 1 ? 0 : dir_; }
|
||||
|
||||
static UHashtable *computeMaxExpansions(const CollationData *data, UErrorCode &errorCode);
|
||||
|
||||
static int32_t getMaxExpansion(const UHashtable *maxExpansions, int32_t order);
|
||||
|
||||
// CollationElementIterator private data members ----------------------------
|
||||
|
||||
CollationIterator *iter_; // owned
|
||||
const RuleBasedCollator *rbc_; // aliased
|
||||
uint32_t otherHalf_;
|
||||
/**
|
||||
* <0: backwards; 0: just after reset() (previous() begins from end);
|
||||
* 1: just after setOffset(); >1: forward
|
||||
*/
|
||||
int8_t dir_;
|
||||
/**
|
||||
* Stores offsets from expansions and from unsafe-backwards iteration,
|
||||
* so that getOffset() returns intermediate offsets for the CEs
|
||||
* that are consistent with forward iteration.
|
||||
*/
|
||||
UVector32 *offsets_;
|
||||
|
||||
UnicodeString string_;
|
||||
};
|
||||
|
||||
// CollationElementIterator inline method definitions --------------------------
|
||||
|
||||
inline int32_t CollationElementIterator::primaryOrder(int32_t order)
|
||||
{
|
||||
return (order >> 16) & 0xffff;
|
||||
}
|
||||
|
||||
inline int32_t CollationElementIterator::secondaryOrder(int32_t order)
|
||||
{
|
||||
return (order >> 8) & 0xff;
|
||||
}
|
||||
|
||||
inline int32_t CollationElementIterator::tertiaryOrder(int32_t order)
|
||||
{
|
||||
return order & 0xff;
|
||||
}
|
||||
|
||||
inline UBool CollationElementIterator::isIgnorable(int32_t order)
|
||||
{
|
||||
return (order & 0xffff0000) == 0;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_COLLATION */
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,330 +0,0 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 2012-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
* File COMPACTDECIMALFORMAT.H
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __COMPACT_DECIMAL_FORMAT_H__
|
||||
#define __COMPACT_DECIMAL_FORMAT_H__
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Formats decimal numbers in compact form.
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/decimfmt.h"
|
||||
|
||||
struct UHashtable;
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class PluralRules;
|
||||
|
||||
/**
|
||||
* The CompactDecimalFormat produces abbreviated numbers, suitable for display in
|
||||
* environments will limited real estate. For example, 'Hits: 1.2B' instead of
|
||||
* 'Hits: 1,200,000,000'. The format will be appropriate for the given language,
|
||||
* such as "1,2 Mrd." for German.
|
||||
* <p>
|
||||
* For numbers under 1000 trillion (under 10^15, such as 123,456,789,012,345),
|
||||
* the result will be short for supported languages. However, the result may
|
||||
* sometimes exceed 7 characters, such as when there are combining marks or thin
|
||||
* characters. In such cases, the visual width in fonts should still be short.
|
||||
* <p>
|
||||
* By default, there are 3 significant digits. After creation, if more than
|
||||
* three significant digits are set (with setMaximumSignificantDigits), or if a
|
||||
* fixed number of digits are set (with setMaximumIntegerDigits or
|
||||
* setMaximumFractionDigits), then result may be wider.
|
||||
* <p>
|
||||
* At this time, parsing is not supported, and will produce a U_UNSUPPORTED_ERROR.
|
||||
* Resetting the pattern prefixes or suffixes is not supported; the method calls
|
||||
* are ignored.
|
||||
* <p>
|
||||
* @stable ICU 51
|
||||
*/
|
||||
class U_I18N_API CompactDecimalFormat : public DecimalFormat {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Returns a compact decimal instance for specified locale.
|
||||
* @param inLocale the given locale.
|
||||
* @param style whether to use short or long style.
|
||||
* @param status error code returned here.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
static CompactDecimalFormat* U_EXPORT2 createInstance(
|
||||
const Locale& inLocale, UNumberCompactStyle style, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* @param source the DecimalFormat object to be copied from.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
CompactDecimalFormat(const CompactDecimalFormat& source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual ~CompactDecimalFormat();
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
*
|
||||
* @param rhs the DecimalFormat object to be copied.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
CompactDecimalFormat& operator=(const CompactDecimalFormat& rhs);
|
||||
|
||||
/**
|
||||
* Clone this Format object polymorphically. The caller owns the
|
||||
* result and should delete it when done.
|
||||
*
|
||||
* @return a polymorphic copy of this CompactDecimalFormat.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual Format* clone() const;
|
||||
|
||||
/**
|
||||
* Return TRUE if the given Format objects are semantically equal.
|
||||
* Objects of different subclasses are considered unequal.
|
||||
*
|
||||
* @param other the object to be compared with.
|
||||
* @return TRUE if the given Format objects are semantically equal.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
|
||||
using DecimalFormat::format;
|
||||
|
||||
/**
|
||||
* Format a double or long number using base-10 representation.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual UnicodeString& format(double number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
|
||||
/**
|
||||
* Format a double or long number using base-10 representation.
|
||||
* Currently sets status to U_UNSUPPORTED_ERROR.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param posIter On return, can be used to iterate over positions
|
||||
* of fields generated by this format call.
|
||||
* Can be NULL.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @internal
|
||||
*/
|
||||
virtual UnicodeString& format(double number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPositionIterator* posIter,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Format an int64 number using base-10 representation.
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual UnicodeString& format(int64_t number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos) const;
|
||||
|
||||
/**
|
||||
* Format an int64 number using base-10 representation.
|
||||
* Currently sets status to U_UNSUPPORTED_ERROR
|
||||
*
|
||||
* @param number The value to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param posIter On return, can be used to iterate over positions
|
||||
* of fields generated by this format call.
|
||||
* Can be NULL.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @internal
|
||||
*/
|
||||
virtual UnicodeString& format(int64_t number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPositionIterator* posIter,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Format a decimal number. Currently sets status to U_UNSUPPORTED_ERROR
|
||||
* The syntax of the unformatted number is a "numeric string"
|
||||
* as defined in the Decimal Arithmetic Specification, available at
|
||||
* http://speleotrove.com/decimal
|
||||
*
|
||||
* @param number The unformatted number, as a string.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param posIter On return, can be used to iterate over positions
|
||||
* of fields generated by this format call.
|
||||
* Can be NULL.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @internal
|
||||
*/
|
||||
virtual UnicodeString& format(const StringPiece &number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPositionIterator* posIter,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Format a decimal number. Currently sets status to U_UNSUPPORTED_ERROR
|
||||
* The number is a DigitList wrapper onto a floating point decimal number.
|
||||
* The default implementation in NumberFormat converts the decimal number
|
||||
* to a double and formats that.
|
||||
*
|
||||
* @param number The number, a DigitList format Decimal Floating Point.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param posIter On return, can be used to iterate over positions
|
||||
* of fields generated by this format call.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @internal
|
||||
*/
|
||||
virtual UnicodeString& format(const DigitList &number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPositionIterator* posIter,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Format a decimal number. Currently sets status to U_UNSUPPORTED_ERROR.
|
||||
* The number is a DigitList wrapper onto a floating point decimal number.
|
||||
* The default implementation in NumberFormat converts the decimal number
|
||||
* to a double and formats that.
|
||||
*
|
||||
* @param number The number, a DigitList format Decimal Floating Point.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @internal
|
||||
*/
|
||||
virtual UnicodeString& format(const DigitList &number,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* CompactDecimalFormat does not support parsing. This implementation
|
||||
* does nothing.
|
||||
* @param text Unused.
|
||||
* @param result Does not change.
|
||||
* @param parsePosition Does not change.
|
||||
* @see Formattable
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual void parse(const UnicodeString& text,
|
||||
Formattable& result,
|
||||
ParsePosition& parsePosition) const;
|
||||
|
||||
/**
|
||||
* CompactDecimalFormat does not support parsing. This implementation
|
||||
* sets status to U_UNSUPPORTED_ERROR
|
||||
*
|
||||
* @param text Unused.
|
||||
* @param result Does not change.
|
||||
* @param status Always set to U_UNSUPPORTED_ERROR.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual void parse(const UnicodeString& text,
|
||||
Formattable& result,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Parses text from the given string as a currency amount. Unlike
|
||||
* the parse() method, this method will attempt to parse a generic
|
||||
* currency name, searching for a match of this object's locale's
|
||||
* currency display names, or for a 3-letter ISO currency code.
|
||||
* This method will fail if this format is not a currency format,
|
||||
* that is, if it does not contain the currency pattern symbol
|
||||
* (U+00A4) in its prefix or suffix. This implementation always returns
|
||||
* NULL.
|
||||
*
|
||||
* @param text the string to parse
|
||||
* @param pos input-output position; on input, the position within text
|
||||
* to match; must have 0 <= pos.getIndex() < text.length();
|
||||
* on output, the position after the last matched character.
|
||||
* If the parse fails, the position in unchanged upon output.
|
||||
* @return if parse succeeds, a pointer to a newly-created CurrencyAmount
|
||||
* object (owned by the caller) containing information about
|
||||
* the parsed currency; if parse fails, this is NULL.
|
||||
* @internal
|
||||
*/
|
||||
virtual CurrencyAmount* parseCurrency(const UnicodeString& text,
|
||||
ParsePosition& pos) const;
|
||||
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for
|
||||
* comparing to a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . Derived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID();
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override.
|
||||
* This method is to implement a simple version of RTTI, since not all
|
||||
* C++ compilers support genuine RTTI. Polymorphic operator==() and
|
||||
* clone() methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
private:
|
||||
|
||||
const UHashtable* _unitsByVariant;
|
||||
const double* _divisors;
|
||||
PluralRules* _pluralRules;
|
||||
|
||||
// Default constructor not implemented.
|
||||
CompactDecimalFormat(const DecimalFormat &, const UHashtable* unitsByVariant, const double* divisors, PluralRules* pluralRules);
|
||||
|
||||
UBool eqHelper(const CompactDecimalFormat& that) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // __COMPACT_DECIMAL_FORMAT_H__
|
||||
//eof
|
||||
@ -1,130 +0,0 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2004-2006, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Alan Liu
|
||||
* Created: April 26, 2004
|
||||
* Since: ICU 3.0
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifndef __CURRENCYAMOUNT_H__
|
||||
#define __CURRENCYAMOUNT_H__
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/measure.h"
|
||||
#include "unicode/currunit.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Currency Amount Object.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
*
|
||||
* A currency together with a numeric amount, such as 200 USD.
|
||||
*
|
||||
* @author Alan Liu
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
class U_I18N_API CurrencyAmount: public Measure {
|
||||
public:
|
||||
/**
|
||||
* Construct an object with the given numeric amount and the given
|
||||
* ISO currency code.
|
||||
* @param amount a numeric object; amount.isNumeric() must be TRUE
|
||||
* @param isoCode the 3-letter ISO 4217 currency code; must not be
|
||||
* NULL and must have length 3
|
||||
* @param ec input-output error code. If the amount or the isoCode
|
||||
* is invalid, then this will be set to a failing value.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
CurrencyAmount(const Formattable& amount, const UChar* isoCode,
|
||||
UErrorCode &ec);
|
||||
|
||||
/**
|
||||
* Construct an object with the given numeric amount and the given
|
||||
* ISO currency code.
|
||||
* @param amount the amount of the given currency
|
||||
* @param isoCode the 3-letter ISO 4217 currency code; must not be
|
||||
* NULL and must have length 3
|
||||
* @param ec input-output error code. If the isoCode is invalid,
|
||||
* then this will be set to a failing value.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
CurrencyAmount(double amount, const UChar* isoCode,
|
||||
UErrorCode &ec);
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
CurrencyAmount(const CurrencyAmount& other);
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
CurrencyAmount& operator=(const CurrencyAmount& other);
|
||||
|
||||
/**
|
||||
* Return a polymorphic clone of this object. The result will
|
||||
* have the same class as returned by getDynamicClassID().
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
virtual UObject* clone() const;
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
virtual ~CurrencyAmount();
|
||||
|
||||
/**
|
||||
* Returns a unique class ID for this object POLYMORPHICALLY.
|
||||
* This method implements a simple form of RTTI used by ICU.
|
||||
* @return The class ID for this object. All objects of a given
|
||||
* class have the same class ID. Objects of other classes have
|
||||
* different class IDs.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* Returns the class ID for this class. This is used to compare to
|
||||
* the return value of getDynamicClassID().
|
||||
* @return The class ID for all objects of this class.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID();
|
||||
|
||||
/**
|
||||
* Return the currency unit object of this object.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
inline const CurrencyUnit& getCurrency() const;
|
||||
|
||||
/**
|
||||
* Return the ISO currency code of this object.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
inline const UChar* getISOCurrency() const;
|
||||
};
|
||||
|
||||
inline const CurrencyUnit& CurrencyAmount::getCurrency() const {
|
||||
return (const CurrencyUnit&) getUnit();
|
||||
}
|
||||
|
||||
inline const UChar* CurrencyAmount::getISOCurrency() const {
|
||||
return getCurrency().getISOCurrency();
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // !UCONFIG_NO_FORMATTING
|
||||
#endif // __CURRENCYAMOUNT_H__
|
||||
@ -1,258 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2009-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef CURRPINF_H
|
||||
#define CURRPINF_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Currency Plural Information used by Decimal Format
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/unistr.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class Locale;
|
||||
class PluralRules;
|
||||
class Hashtable;
|
||||
|
||||
/**
|
||||
* This class represents the information needed by
|
||||
* DecimalFormat to format currency plural,
|
||||
* such as "3.00 US dollars" or "1.00 US dollar".
|
||||
* DecimalFormat creates for itself an instance of
|
||||
* CurrencyPluralInfo from its locale data.
|
||||
* If you need to change any of these symbols, you can get the
|
||||
* CurrencyPluralInfo object from your
|
||||
* DecimalFormat and modify it.
|
||||
*
|
||||
* Following are the information needed for currency plural format and parse:
|
||||
* locale information,
|
||||
* plural rule of the locale,
|
||||
* currency plural pattern of the locale.
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
class U_I18N_API CurrencyPluralInfo : public UObject {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Create a CurrencyPluralInfo object for the default locale.
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
CurrencyPluralInfo(UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Create a CurrencyPluralInfo object for the given locale.
|
||||
* @param locale the locale
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
CurrencyPluralInfo(const Locale& locale, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
CurrencyPluralInfo(const CurrencyPluralInfo& info);
|
||||
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info);
|
||||
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual ~CurrencyPluralInfo();
|
||||
|
||||
|
||||
/**
|
||||
* Equal operator.
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
UBool operator==(const CurrencyPluralInfo& info) const;
|
||||
|
||||
|
||||
/**
|
||||
* Not equal operator
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
UBool operator!=(const CurrencyPluralInfo& info) const;
|
||||
|
||||
|
||||
/**
|
||||
* Clone
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
CurrencyPluralInfo* clone() const;
|
||||
|
||||
|
||||
/**
|
||||
* Gets plural rules of this locale, used for currency plural format
|
||||
*
|
||||
* @return plural rule
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
const PluralRules* getPluralRules() const;
|
||||
|
||||
/**
|
||||
* Given a plural count, gets currency plural pattern of this locale,
|
||||
* used for currency plural format
|
||||
*
|
||||
* @param pluralCount currency plural count
|
||||
* @param result output param to receive the pattern
|
||||
* @return a currency plural pattern based on plural count
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount,
|
||||
UnicodeString& result) const;
|
||||
|
||||
/**
|
||||
* Get locale
|
||||
*
|
||||
* @return locale
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
const Locale& getLocale() const;
|
||||
|
||||
/**
|
||||
* Set plural rules.
|
||||
* The plural rule is set when CurrencyPluralInfo
|
||||
* instance is created.
|
||||
* You can call this method to reset plural rules only if you want
|
||||
* to modify the default plural rule of the locale.
|
||||
*
|
||||
* @param ruleDescription new plural rule description
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
void setPluralRules(const UnicodeString& ruleDescription,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Set currency plural pattern.
|
||||
* The currency plural pattern is set when CurrencyPluralInfo
|
||||
* instance is created.
|
||||
* You can call this method to reset currency plural pattern only if
|
||||
* you want to modify the default currency plural pattern of the locale.
|
||||
*
|
||||
* @param pluralCount the plural count for which the currency pattern will
|
||||
* be overridden.
|
||||
* @param pattern the new currency plural pattern
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
void setCurrencyPluralPattern(const UnicodeString& pluralCount,
|
||||
const UnicodeString& pattern,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Set locale
|
||||
*
|
||||
* @param loc the new locale to set
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
void setLocale(const Locale& loc, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID();
|
||||
|
||||
private:
|
||||
friend class DecimalFormat;
|
||||
|
||||
void initialize(const Locale& loc, UErrorCode& status);
|
||||
|
||||
void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);
|
||||
|
||||
/*
|
||||
* delete hash table
|
||||
*
|
||||
* @param hTable hash table to be deleted
|
||||
*/
|
||||
void deleteHash(Hashtable* hTable);
|
||||
|
||||
|
||||
/*
|
||||
* initialize hash table
|
||||
*
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @return hash table initialized
|
||||
*/
|
||||
Hashtable* initHash(UErrorCode& status);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* copy hash table
|
||||
*
|
||||
* @param source the source to copy from
|
||||
* @param target the target to copy to
|
||||
* @param status error code
|
||||
*/
|
||||
void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);
|
||||
|
||||
//-------------------- private data member ---------------------
|
||||
// map from plural count to currency plural pattern, for example
|
||||
// a plural pattern defined in "CurrencyUnitPatterns" is
|
||||
// "one{{0} {1}}", in which "one" is a plural count
|
||||
// and "{0} {1}" is a currency plural pattern".
|
||||
// The currency plural pattern saved in this mapping is the pattern
|
||||
// defined in "CurrencyUnitPattern" by replacing
|
||||
// {0} with the number format pattern,
|
||||
// and {1} with 3 currency sign.
|
||||
Hashtable* fPluralCountToCurrencyUnitPattern;
|
||||
|
||||
/*
|
||||
* The plural rule is used to format currency plural name,
|
||||
* for example: "3.00 US Dollars".
|
||||
* If there are 3 currency signs in the currency patttern,
|
||||
* the 3 currency signs will be replaced by currency plural name.
|
||||
*/
|
||||
PluralRules* fPluralRules;
|
||||
|
||||
// locale
|
||||
Locale* fLocale;
|
||||
};
|
||||
|
||||
|
||||
inline UBool
|
||||
CurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const { return !operator==(info); }
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // _CURRPINFO
|
||||
//eof
|
||||
@ -1,110 +0,0 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2004-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Alan Liu
|
||||
* Created: April 26, 2004
|
||||
* Since: ICU 3.0
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifndef __CURRENCYUNIT_H__
|
||||
#define __CURRENCYUNIT_H__
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/measunit.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Currency Unit Information.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* A unit of currency, such as USD (U.S. dollars) or JPY (Japanese
|
||||
* yen). This class is a thin wrapper over a UChar string that
|
||||
* subclasses MeasureUnit, for use with Measure and MeasureFormat.
|
||||
*
|
||||
* @author Alan Liu
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
class U_I18N_API CurrencyUnit: public MeasureUnit {
|
||||
public:
|
||||
/**
|
||||
* Construct an object with the given ISO currency code.
|
||||
* @param isoCode the 3-letter ISO 4217 currency code; must not be
|
||||
* NULL and must have length 3
|
||||
* @param ec input-output error code. If the isoCode is invalid,
|
||||
* then this will be set to a failing value.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
CurrencyUnit(const UChar* isoCode, UErrorCode &ec);
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
CurrencyUnit(const CurrencyUnit& other);
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
CurrencyUnit& operator=(const CurrencyUnit& other);
|
||||
|
||||
/**
|
||||
* Return a polymorphic clone of this object. The result will
|
||||
* have the same class as returned by getDynamicClassID().
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
virtual UObject* clone() const;
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
virtual ~CurrencyUnit();
|
||||
|
||||
/**
|
||||
* Returns a unique class ID for this object POLYMORPHICALLY.
|
||||
* This method implements a simple form of RTTI used by ICU.
|
||||
* @return The class ID for this object. All objects of a given
|
||||
* class have the same class ID. Objects of other classes have
|
||||
* different class IDs.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* Returns the class ID for this class. This is used to compare to
|
||||
* the return value of getDynamicClassID().
|
||||
* @return The class ID for all objects of this class.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID();
|
||||
|
||||
/**
|
||||
* Return the ISO currency code of this object.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
inline const UChar* getISOCurrency() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* The ISO 4217 code of this object.
|
||||
*/
|
||||
UChar isoCode[4];
|
||||
};
|
||||
|
||||
inline const UChar* CurrencyUnit::getISOCurrency() const {
|
||||
return isoCode;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif // !UCONFIG_NO_FORMATTING
|
||||
#endif // __CURRENCYUNIT_H__
|
||||
@ -1,972 +0,0 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 1997-2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
* File DATEFMT.H
|
||||
*
|
||||
* Modification History:
|
||||
*
|
||||
* Date Name Description
|
||||
* 02/19/97 aliu Converted from java.
|
||||
* 04/01/97 aliu Added support for centuries.
|
||||
* 07/23/98 stephen JDK 1.2 sync
|
||||
* 11/15/99 weiv Added support for week of year/day of week formatting
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef DATEFMT_H
|
||||
#define DATEFMT_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/udat.h"
|
||||
#include "unicode/calendar.h"
|
||||
#include "unicode/numfmt.h"
|
||||
#include "unicode/format.h"
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/enumset.h"
|
||||
#include "unicode/udisplaycontext.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Abstract class for converting dates.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class TimeZone;
|
||||
class DateTimePatternGenerator;
|
||||
|
||||
// explicit template instantiation. see digitlst.h
|
||||
#if defined (_MSC_VER)
|
||||
template class U_I18N_API EnumSet<UDateFormatBooleanAttribute,
|
||||
0,
|
||||
UDAT_BOOLEAN_ATTRIBUTE_COUNT>;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* DateFormat is an abstract class for a family of classes that convert dates and
|
||||
* times from their internal representations to textual form and back again in a
|
||||
* language-independent manner. Converting from the internal representation (milliseconds
|
||||
* since midnight, January 1, 1970) to text is known as "formatting," and converting
|
||||
* from text to millis is known as "parsing." We currently define only one concrete
|
||||
* subclass of DateFormat: SimpleDateFormat, which can handle pretty much all normal
|
||||
* date formatting and parsing actions.
|
||||
* <P>
|
||||
* DateFormat helps you to format and parse dates for any locale. Your code can
|
||||
* be completely independent of the locale conventions for months, days of the
|
||||
* week, or even the calendar format: lunar vs. solar.
|
||||
* <P>
|
||||
* To format a date for the current Locale, use one of the static factory
|
||||
* methods:
|
||||
* <pre>
|
||||
* \code
|
||||
* DateFormat* dfmt = DateFormat::createDateInstance();
|
||||
* UDate myDate = Calendar::getNow();
|
||||
* UnicodeString myString;
|
||||
* myString = dfmt->format( myDate, myString );
|
||||
* \endcode
|
||||
* </pre>
|
||||
* If you are formatting multiple numbers, it is more efficient to get the
|
||||
* format and use it multiple times so that the system doesn't have to fetch the
|
||||
* information about the local language and country conventions multiple times.
|
||||
* <pre>
|
||||
* \code
|
||||
* DateFormat* df = DateFormat::createDateInstance();
|
||||
* UnicodeString myString;
|
||||
* UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
|
||||
* for (int32_t i = 0; i < 3; ++i) {
|
||||
* myString.remove();
|
||||
* cout << df->format( myDateArr[i], myString ) << endl;
|
||||
* }
|
||||
* \endcode
|
||||
* </pre>
|
||||
* To get specific fields of a date, you can use UFieldPosition to
|
||||
* get specific fields.
|
||||
* <pre>
|
||||
* \code
|
||||
* DateFormat* dfmt = DateFormat::createDateInstance();
|
||||
* FieldPosition pos(DateFormat::YEAR_FIELD);
|
||||
* UnicodeString myString;
|
||||
* myString = dfmt->format( myDate, myString );
|
||||
* cout << myString << endl;
|
||||
* cout << pos.getBeginIndex() << "," << pos. getEndIndex() << endl;
|
||||
* \endcode
|
||||
* </pre>
|
||||
* To format a date for a different Locale, specify it in the call to
|
||||
* createDateInstance().
|
||||
* <pre>
|
||||
* \code
|
||||
* DateFormat* df =
|
||||
* DateFormat::createDateInstance( DateFormat::SHORT, Locale::getFrance());
|
||||
* \endcode
|
||||
* </pre>
|
||||
* You can use a DateFormat to parse also.
|
||||
* <pre>
|
||||
* \code
|
||||
* UErrorCode status = U_ZERO_ERROR;
|
||||
* UDate myDate = df->parse(myString, status);
|
||||
* \endcode
|
||||
* </pre>
|
||||
* Use createDateInstance() to produce the normal date format for that country.
|
||||
* There are other static factory methods available. Use createTimeInstance()
|
||||
* to produce the normal time format for that country. Use createDateTimeInstance()
|
||||
* to produce a DateFormat that formats both date and time. You can pass in
|
||||
* different options to these factory methods to control the length of the
|
||||
* result; from SHORT to MEDIUM to LONG to FULL. The exact result depends on the
|
||||
* locale, but generally:
|
||||
* <ul type=round>
|
||||
* <li> SHORT is completely numeric, such as 12/13/52 or 3:30pm
|
||||
* <li> MEDIUM is longer, such as Jan 12, 1952
|
||||
* <li> LONG is longer, such as January 12, 1952 or 3:30:32pm
|
||||
* <li> FULL is pretty completely specified, such as
|
||||
* Tuesday, April 12, 1952 AD or 3:30:42pm PST.
|
||||
* </ul>
|
||||
* You can also set the time zone on the format if you wish. If you want even
|
||||
* more control over the format or parsing, (or want to give your users more
|
||||
* control), you can try casting the DateFormat you get from the factory methods
|
||||
* to a SimpleDateFormat. This will work for the majority of countries; just
|
||||
* remember to chck getDynamicClassID() before carrying out the cast.
|
||||
* <P>
|
||||
* You can also use forms of the parse and format methods with ParsePosition and
|
||||
* FieldPosition to allow you to
|
||||
* <ul type=round>
|
||||
* <li> Progressively parse through pieces of a string.
|
||||
* <li> Align any particular field, or find out where it is for selection
|
||||
* on the screen.
|
||||
* </ul>
|
||||
*
|
||||
* <p><em>User subclasses are not supported.</em> While clients may write
|
||||
* subclasses, such code will not necessarily work and will not be
|
||||
* guaranteed to work stably from release to release.
|
||||
*/
|
||||
class U_I18N_API DateFormat : public Format {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constants for various style patterns. These reflect the order of items in
|
||||
* the DateTimePatterns resource. There are 4 time patterns, 4 date patterns,
|
||||
* the default date-time pattern, and 4 date-time patterns. Each block of 4 values
|
||||
* in the resource occurs in the order full, long, medium, short.
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
enum EStyle
|
||||
{
|
||||
kNone = -1,
|
||||
|
||||
kFull = 0,
|
||||
kLong = 1,
|
||||
kMedium = 2,
|
||||
kShort = 3,
|
||||
|
||||
kDateOffset = kShort + 1,
|
||||
// kFull + kDateOffset = 4
|
||||
// kLong + kDateOffset = 5
|
||||
// kMedium + kDateOffset = 6
|
||||
// kShort + kDateOffset = 7
|
||||
|
||||
kDateTime = 8,
|
||||
// Default DateTime
|
||||
|
||||
kDateTimeOffset = kDateTime + 1,
|
||||
// kFull + kDateTimeOffset = 9
|
||||
// kLong + kDateTimeOffset = 10
|
||||
// kMedium + kDateTimeOffset = 11
|
||||
// kShort + kDateTimeOffset = 12
|
||||
|
||||
// relative dates
|
||||
kRelative = (1 << 7),
|
||||
|
||||
kFullRelative = (kFull | kRelative),
|
||||
|
||||
kLongRelative = kLong | kRelative,
|
||||
|
||||
kMediumRelative = kMedium | kRelative,
|
||||
|
||||
kShortRelative = kShort | kRelative,
|
||||
|
||||
|
||||
kDefault = kMedium,
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* These constants are provided for backwards compatibility only.
|
||||
* Please use the C++ style constants defined above.
|
||||
*/
|
||||
FULL = kFull,
|
||||
LONG = kLong,
|
||||
MEDIUM = kMedium,
|
||||
SHORT = kShort,
|
||||
DEFAULT = kDefault,
|
||||
DATE_OFFSET = kDateOffset,
|
||||
NONE = kNone,
|
||||
DATE_TIME = kDateTime
|
||||
};
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual ~DateFormat();
|
||||
|
||||
/**
|
||||
* Equality operator. Returns true if the two formats have the same behavior.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool operator==(const Format&) const;
|
||||
|
||||
|
||||
using Format::format;
|
||||
|
||||
/**
|
||||
* Format an object to produce a string. This method handles Formattable
|
||||
* objects with a UDate type. If a the Formattable object type is not a Date,
|
||||
* then it returns a failing UErrorCode.
|
||||
*
|
||||
* @param obj The object to format. Must be a Date.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Format an object to produce a string. This method handles Formattable
|
||||
* objects with a UDate type. If a the Formattable object type is not a Date,
|
||||
* then it returns a failing UErrorCode.
|
||||
*
|
||||
* @param obj The object to format. Must be a Date.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param posIter On return, can be used to iterate over positions
|
||||
* of fields generated by this format call. Field values
|
||||
* are defined in UDateFormatField. Can be NULL.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 4.4
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& appendTo,
|
||||
FieldPositionIterator* posIter,
|
||||
UErrorCode& status) const;
|
||||
/**
|
||||
* Formats a date into a date/time string. This is an abstract method which
|
||||
* concrete subclasses must implement.
|
||||
* <P>
|
||||
* On input, the FieldPosition parameter may have its "field" member filled with
|
||||
* an enum value specifying a field. On output, the FieldPosition will be filled
|
||||
* in with the text offsets for that field.
|
||||
* <P> For example, given a time text
|
||||
* "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is
|
||||
* UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and
|
||||
* statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.
|
||||
* <P> Notice
|
||||
* that if the same time field appears more than once in a pattern, the status will
|
||||
* be set for the first occurence of that time field. For instance,
|
||||
* formatting a UDate to the time string "1 PM PDT (Pacific Daylight Time)"
|
||||
* using the pattern "h a z (zzzz)" and the alignment field
|
||||
* DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and
|
||||
* fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first
|
||||
* occurence of the timezone pattern character 'z'.
|
||||
*
|
||||
* @param cal Calendar set to the date and time to be formatted
|
||||
* into a date/time string. When the calendar type is
|
||||
* different from the internal calendar held by this
|
||||
* DateFormat instance, the date and the time zone will
|
||||
* be inherited from the input calendar, but other calendar
|
||||
* field values will be calculated by the internal calendar.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param fieldPosition On input: an alignment field, if desired (see examples above)
|
||||
* On output: the offsets of the alignment field (see examples above)
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
virtual UnicodeString& format( Calendar& cal,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition) const = 0;
|
||||
|
||||
/**
|
||||
* Formats a date into a date/time string. Subclasses should implement this method.
|
||||
*
|
||||
* @param cal Calendar set to the date and time to be formatted
|
||||
* into a date/time string. When the calendar type is
|
||||
* different from the internal calendar held by this
|
||||
* DateFormat instance, the date and the time zone will
|
||||
* be inherited from the input calendar, but other calendar
|
||||
* field values will be calculated by the internal calendar.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param posIter On return, can be used to iterate over positions
|
||||
* of fields generated by this format call. Field values
|
||||
* are defined in UDateFormatField. Can be NULL.
|
||||
* @param status error status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 4.4
|
||||
*/
|
||||
virtual UnicodeString& format(Calendar& cal,
|
||||
UnicodeString& appendTo,
|
||||
FieldPositionIterator* posIter,
|
||||
UErrorCode& status) const;
|
||||
/**
|
||||
* Formats a UDate into a date/time string.
|
||||
* <P>
|
||||
* On input, the FieldPosition parameter may have its "field" member filled with
|
||||
* an enum value specifying a field. On output, the FieldPosition will be filled
|
||||
* in with the text offsets for that field.
|
||||
* <P> For example, given a time text
|
||||
* "1996.07.10 AD at 15:08:56 PDT", if the given fieldPosition.field is
|
||||
* UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and
|
||||
* statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.
|
||||
* <P> Notice
|
||||
* that if the same time field appears more than once in a pattern, the status will
|
||||
* be set for the first occurence of that time field. For instance,
|
||||
* formatting a UDate to the time string "1 PM PDT (Pacific Daylight Time)"
|
||||
* using the pattern "h a z (zzzz)" and the alignment field
|
||||
* DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and
|
||||
* fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first
|
||||
* occurence of the timezone pattern character 'z'.
|
||||
*
|
||||
* @param date UDate to be formatted into a date/time string.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param fieldPosition On input: an alignment field, if desired (see examples above)
|
||||
* On output: the offsets of the alignment field (see examples above)
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UnicodeString& format( UDate date,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition) const;
|
||||
|
||||
/**
|
||||
* Formats a UDate into a date/time string.
|
||||
*
|
||||
* @param date UDate to be formatted into a date/time string.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param posIter On return, can be used to iterate over positions
|
||||
* of fields generated by this format call. Field values
|
||||
* are defined in UDateFormatField. Can be NULL.
|
||||
* @param status error status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 4.4
|
||||
*/
|
||||
UnicodeString& format(UDate date,
|
||||
UnicodeString& appendTo,
|
||||
FieldPositionIterator* posIter,
|
||||
UErrorCode& status) const;
|
||||
/**
|
||||
* Formats a UDate into a date/time string. If there is a problem, you won't
|
||||
* know, using this method. Use the overloaded format() method which takes a
|
||||
* FieldPosition& to detect formatting problems.
|
||||
*
|
||||
* @param date The UDate value to be formatted into a string.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UnicodeString& format(UDate date, UnicodeString& appendTo) const;
|
||||
|
||||
/**
|
||||
* Parse a date/time string. For example, a time text "07/10/96 4:5 PM, PDT"
|
||||
* will be parsed into a UDate that is equivalent to Date(837039928046).
|
||||
* Parsing begins at the beginning of the string and proceeds as far as
|
||||
* possible. Assuming no parse errors were encountered, this function
|
||||
* doesn't return any information about how much of the string was consumed
|
||||
* by the parsing. If you need that information, use the version of
|
||||
* parse() that takes a ParsePosition.
|
||||
* <P>
|
||||
* By default, parsing is lenient: If the input is not in the form used by
|
||||
* this object's format method but can still be parsed as a date, then the
|
||||
* parse succeeds. Clients may insist on strict adherence to the format by
|
||||
* calling setLenient(false).
|
||||
* @see DateFormat::setLenient(boolean)
|
||||
* <P>
|
||||
* Note that the normal date formats associated with some calendars - such
|
||||
* as the Chinese lunar calendar - do not specify enough fields to enable
|
||||
* dates to be parsed unambiguously. In the case of the Chinese lunar
|
||||
* calendar, while the year within the current 60-year cycle is specified,
|
||||
* the number of such cycles since the start date of the calendar (in the
|
||||
* ERA field of the Calendar object) is not normally part of the format,
|
||||
* and parsing may assume the wrong era. For cases such as this it is
|
||||
* recommended that clients parse using the method
|
||||
* parse(const UnicodeString&, Calendar& cal, ParsePosition&)
|
||||
* with the Calendar passed in set to the current date, or to a date
|
||||
* within the era/cycle that should be assumed if absent in the format.
|
||||
*
|
||||
* @param text The date/time string to be parsed into a UDate value.
|
||||
* @param status Output param to be set to success/failure code. If
|
||||
* 'text' cannot be parsed, it will be set to a failure
|
||||
* code.
|
||||
* @return The parsed UDate value, if successful.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UDate parse( const UnicodeString& text,
|
||||
UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Parse a date/time string beginning at the given parse position. For
|
||||
* example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
|
||||
* that is equivalent to Date(837039928046).
|
||||
* <P>
|
||||
* By default, parsing is lenient: If the input is not in the form used by
|
||||
* this object's format method but can still be parsed as a date, then the
|
||||
* parse succeeds. Clients may insist on strict adherence to the format by
|
||||
* calling setLenient(false).
|
||||
* @see DateFormat::setLenient(boolean)
|
||||
*
|
||||
* @param text The date/time string to be parsed.
|
||||
* @param cal A Calendar set on input to the date and time to be used for
|
||||
* missing values in the date/time string being parsed, and set
|
||||
* on output to the parsed date/time. When the calendar type is
|
||||
* different from the internal calendar held by this DateFormat
|
||||
* instance, the internal calendar will be cloned to a work
|
||||
* calendar set to the same milliseconds and time zone as the
|
||||
* cal parameter, field values will be parsed based on the work
|
||||
* calendar, then the result (milliseconds and time zone) will
|
||||
* be set in this calendar.
|
||||
* @param pos On input, the position at which to start parsing; on
|
||||
* output, the position at which parsing terminated, or the
|
||||
* start position if the parse failed.
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
virtual void parse( const UnicodeString& text,
|
||||
Calendar& cal,
|
||||
ParsePosition& pos) const = 0;
|
||||
|
||||
/**
|
||||
* Parse a date/time string beginning at the given parse position. For
|
||||
* example, a time text "07/10/96 4:5 PM, PDT" will be parsed into a Date
|
||||
* that is equivalent to Date(837039928046).
|
||||
* <P>
|
||||
* By default, parsing is lenient: If the input is not in the form used by
|
||||
* this object's format method but can still be parsed as a date, then the
|
||||
* parse succeeds. Clients may insist on strict adherence to the format by
|
||||
* calling setLenient(false).
|
||||
* @see DateFormat::setLenient(boolean)
|
||||
* <P>
|
||||
* Note that the normal date formats associated with some calendars - such
|
||||
* as the Chinese lunar calendar - do not specify enough fields to enable
|
||||
* dates to be parsed unambiguously. In the case of the Chinese lunar
|
||||
* calendar, while the year within the current 60-year cycle is specified,
|
||||
* the number of such cycles since the start date of the calendar (in the
|
||||
* ERA field of the Calendar object) is not normally part of the format,
|
||||
* and parsing may assume the wrong era. For cases such as this it is
|
||||
* recommended that clients parse using the method
|
||||
* parse(const UnicodeString&, Calendar& cal, ParsePosition&)
|
||||
* with the Calendar passed in set to the current date, or to a date
|
||||
* within the era/cycle that should be assumed if absent in the format.
|
||||
*
|
||||
* @param text The date/time string to be parsed into a UDate value.
|
||||
* @param pos On input, the position at which to start parsing; on
|
||||
* output, the position at which parsing terminated, or the
|
||||
* start position if the parse failed.
|
||||
* @return A valid UDate if the input could be parsed.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UDate parse( const UnicodeString& text,
|
||||
ParsePosition& pos) const;
|
||||
|
||||
/**
|
||||
* Parse a string to produce an object. This methods handles parsing of
|
||||
* date/time strings into Formattable objects with UDate types.
|
||||
* <P>
|
||||
* Before calling, set parse_pos.index to the offset you want to start
|
||||
* parsing at in the source. After calling, parse_pos.index is the end of
|
||||
* the text you parsed. If error occurs, index is unchanged.
|
||||
* <P>
|
||||
* When parsing, leading whitespace is discarded (with a successful parse),
|
||||
* while trailing whitespace is left as is.
|
||||
* <P>
|
||||
* See Format::parseObject() for more.
|
||||
*
|
||||
* @param source The string to be parsed into an object.
|
||||
* @param result Formattable to be set to the parse result.
|
||||
* If parse fails, return contents are undefined.
|
||||
* @param parse_pos The position to start parsing at. Upon return
|
||||
* this param is set to the position after the
|
||||
* last character successfully parsed. If the
|
||||
* source is not parsed successfully, this param
|
||||
* will remain unchanged.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void parseObject(const UnicodeString& source,
|
||||
Formattable& result,
|
||||
ParsePosition& parse_pos) const;
|
||||
|
||||
/**
|
||||
* Create a default date/time formatter that uses the SHORT style for both
|
||||
* the date and the time.
|
||||
*
|
||||
* @return A date/time formatter which the caller owns.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 createInstance(void);
|
||||
|
||||
/**
|
||||
* Creates a time formatter with the given formatting style for the given
|
||||
* locale.
|
||||
*
|
||||
* @param style The given formatting style. For example,
|
||||
* SHORT for "h:mm a" in the US locale. Relative
|
||||
* time styles are not currently supported.
|
||||
* @param aLocale The given locale.
|
||||
* @return A time formatter which the caller owns.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 createTimeInstance(EStyle style = kDefault,
|
||||
const Locale& aLocale = Locale::getDefault());
|
||||
|
||||
/**
|
||||
* Creates a date formatter with the given formatting style for the given
|
||||
* const locale.
|
||||
*
|
||||
* @param style The given formatting style. For example, SHORT for "M/d/yy" in the
|
||||
* US locale. As currently implemented, relative date formatting only
|
||||
* affects a limited range of calendar days before or after the
|
||||
* current date, based on the CLDR <field type="day">/<relative> data:
|
||||
* For example, in English, "Yesterday", "Today", and "Tomorrow".
|
||||
* Outside of this range, dates are formatted using the corresponding
|
||||
* non-relative style.
|
||||
* @param aLocale The given locale.
|
||||
* @return A date formatter which the caller owns.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 createDateInstance(EStyle style = kDefault,
|
||||
const Locale& aLocale = Locale::getDefault());
|
||||
|
||||
/**
|
||||
* Creates a date/time formatter with the given formatting styles for the
|
||||
* given locale.
|
||||
*
|
||||
* @param dateStyle The given formatting style for the date portion of the result.
|
||||
* For example, SHORT for "M/d/yy" in the US locale. As currently
|
||||
* implemented, relative date formatting only affects a limited range
|
||||
* of calendar days before or after the current date, based on the
|
||||
* CLDR <field type="day">/<relative> data: For example, in English,
|
||||
* "Yesterday", "Today", and "Tomorrow". Outside of this range, dates
|
||||
* are formatted using the corresponding non-relative style.
|
||||
* @param timeStyle The given formatting style for the time portion of the result.
|
||||
* For example, SHORT for "h:mm a" in the US locale. Relative
|
||||
* time styles are not currently supported.
|
||||
* @param aLocale The given locale.
|
||||
* @return A date/time formatter which the caller owns.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 createDateTimeInstance(EStyle dateStyle = kDefault,
|
||||
EStyle timeStyle = kDefault,
|
||||
const Locale& aLocale = Locale::getDefault());
|
||||
|
||||
#ifndef U_HIDE_DRAFT_API
|
||||
|
||||
/**
|
||||
* Creates a date/time formatter for the given skeleton and
|
||||
* default locale.
|
||||
*
|
||||
* @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
|
||||
* be in any order, and this method uses the locale to
|
||||
* map the skeleton to a pattern that includes locale
|
||||
* specific separators with the fields in the appropriate
|
||||
* order for that locale.
|
||||
* @param status Any error returned here.
|
||||
* @return A date/time formatter which the caller owns.
|
||||
* @draft ICU 55
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 createInstanceForSkeleton(
|
||||
const UnicodeString& skeleton,
|
||||
UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Creates a date/time formatter for the given skeleton and locale.
|
||||
*
|
||||
* @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
|
||||
* be in any order, and this method uses the locale to
|
||||
* map the skeleton to a pattern that includes locale
|
||||
* specific separators with the fields in the appropriate
|
||||
* order for that locale.
|
||||
* @param locale The given locale.
|
||||
* @param status Any error returned here.
|
||||
* @return A date/time formatter which the caller owns.
|
||||
* @draft ICU 55
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 createInstanceForSkeleton(
|
||||
const UnicodeString& skeleton,
|
||||
const Locale &locale,
|
||||
UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Creates a date/time formatter for the given skeleton and locale.
|
||||
*
|
||||
* @param calendarToAdopt the calendar returned DateFormat is to use.
|
||||
* @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
|
||||
* be in any order, and this method uses the locale to
|
||||
* map the skeleton to a pattern that includes locale
|
||||
* specific separators with the fields in the appropriate
|
||||
* order for that locale.
|
||||
* @param locale The given locale.
|
||||
* @param status Any error returned here.
|
||||
* @return A date/time formatter which the caller owns.
|
||||
* @draft ICU 55
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 createInstanceForSkeleton(
|
||||
Calendar *calendarToAdopt,
|
||||
const UnicodeString& skeleton,
|
||||
const Locale &locale,
|
||||
UErrorCode &status);
|
||||
|
||||
#endif /* U_HIDE_DRAFT_API */
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
|
||||
/**
|
||||
* Creates a date/time formatter for the given skeleton and locale and
|
||||
* uses the given DateTimePatternGenerator to convert the skeleton to
|
||||
* a format pattern. As creating a DateTimePatternGenerator is
|
||||
* expensive, callers can supply it here (if they already have it) to save
|
||||
* this method from creating its own.
|
||||
*
|
||||
* @param skeleton The skeleton e.g "yMMMMd." Fields in the skeleton can
|
||||
* be in any order, and this method uses the provided
|
||||
* DateTimePatternGenerator to map the skeleton to a
|
||||
* pattern that includes appropriate separators with
|
||||
* the fields in the appropriate order.
|
||||
* @param locale The given locale.
|
||||
* @param dpng The user supplied DateTimePatternGenerator. dpng
|
||||
* must be created for the same locale as locale.
|
||||
* Moreover, the caller must not modify dpng between
|
||||
* creating it by locale and calling this method.
|
||||
* Although dpng is a non-const reference, the caller
|
||||
* must not regard it as an out or in-out parameter.
|
||||
* The only reason dpng is a non-const reference is
|
||||
* because its method, getBestPattern, which converts
|
||||
* a skeleton to a date format pattern is non-const.
|
||||
* @return A date/time formatter which the caller owns.
|
||||
* @internal For ICU use only
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 internalCreateInstanceForSkeleton(
|
||||
const UnicodeString& skeleton,
|
||||
const Locale &locale,
|
||||
DateTimePatternGenerator &dpng,
|
||||
UErrorCode &status);
|
||||
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* Gets the set of locales for which DateFormats are installed.
|
||||
* @param count Filled in with the number of locales in the list that is returned.
|
||||
* @return the set of locales for which DateFormats are installed. The caller
|
||||
* does NOT own this list and must not delete it.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
|
||||
|
||||
/**
|
||||
* Returns whether both date/time parsing in the encapsulated Calendar object and DateFormat whitespace &
|
||||
* numeric processing is lenient.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual UBool isLenient(void) const;
|
||||
|
||||
/**
|
||||
* Specifies whether date/time parsing is to be lenient. With
|
||||
* lenient parsing, the parser may use heuristics to interpret inputs that
|
||||
* do not precisely match this object's format. Without lenient parsing,
|
||||
* inputs must match this object's format more closely.
|
||||
*
|
||||
* Note: ICU 53 introduced finer grained control of leniency (and added
|
||||
* new control points) making the preferred method a combination of
|
||||
* setCalendarLenient() & setBooleanAttribute() calls.
|
||||
* This method supports prior functionality but may not support all
|
||||
* future leniency control & behavior of DateFormat. For control of pre 53 leniency,
|
||||
* Calendar and DateFormat whitespace & numeric tolerance, this method is safe to
|
||||
* use. However, mixing leniency control via this method and modification of the
|
||||
* newer attributes via setBooleanAttribute() may produce undesirable
|
||||
* results.
|
||||
*
|
||||
* @param lenient True specifies date/time interpretation to be lenient.
|
||||
* @see Calendar::setLenient
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void setLenient(UBool lenient);
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether date/time parsing in the encapsulated Calendar object processing is lenient.
|
||||
* @stable ICU 53
|
||||
*/
|
||||
virtual UBool isCalendarLenient(void) const;
|
||||
|
||||
|
||||
/**
|
||||
* Specifies whether encapsulated Calendar date/time parsing is to be lenient. With
|
||||
* lenient parsing, the parser may use heuristics to interpret inputs that
|
||||
* do not precisely match this object's format. Without lenient parsing,
|
||||
* inputs must match this object's format more closely.
|
||||
* @param lenient when true, parsing is lenient
|
||||
* @see com.ibm.icu.util.Calendar#setLenient
|
||||
* @stable ICU 53
|
||||
*/
|
||||
virtual void setCalendarLenient(UBool lenient);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the calendar associated with this date/time formatter.
|
||||
* The calendar is owned by the formatter and must not be modified.
|
||||
* Also, the calendar does not reflect the results of a parse operation.
|
||||
* To parse to a calendar, use {@link #parse(const UnicodeString&, Calendar& cal, ParsePosition&) const parse(const UnicodeString&, Calendar& cal, ParsePosition&)}
|
||||
* @return the calendar associated with this date/time formatter.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual const Calendar* getCalendar(void) const;
|
||||
|
||||
/**
|
||||
* Set the calendar to be used by this date format. Initially, the default
|
||||
* calendar for the specified or default locale is used. The caller should
|
||||
* not delete the Calendar object after it is adopted by this call.
|
||||
* Adopting a new calendar will change to the default symbols.
|
||||
*
|
||||
* @param calendarToAdopt Calendar object to be adopted.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void adoptCalendar(Calendar* calendarToAdopt);
|
||||
|
||||
/**
|
||||
* Set the calendar to be used by this date format. Initially, the default
|
||||
* calendar for the specified or default locale is used.
|
||||
*
|
||||
* @param newCalendar Calendar object to be set.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void setCalendar(const Calendar& newCalendar);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the number formatter which this date/time formatter uses to format
|
||||
* and parse the numeric portions of the pattern.
|
||||
* @return the number formatter which this date/time formatter uses.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual const NumberFormat* getNumberFormat(void) const;
|
||||
|
||||
/**
|
||||
* Allows you to set the number formatter. The caller should
|
||||
* not delete the NumberFormat object after it is adopted by this call.
|
||||
* @param formatToAdopt NumberFormat object to be adopted.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void adoptNumberFormat(NumberFormat* formatToAdopt);
|
||||
|
||||
/**
|
||||
* Allows you to set the number formatter.
|
||||
* @param newNumberFormat NumberFormat object to be set.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void setNumberFormat(const NumberFormat& newNumberFormat);
|
||||
|
||||
/**
|
||||
* Returns a reference to the TimeZone used by this DateFormat's calendar.
|
||||
* @return the time zone associated with the calendar of DateFormat.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual const TimeZone& getTimeZone(void) const;
|
||||
|
||||
/**
|
||||
* Sets the time zone for the calendar of this DateFormat object. The caller
|
||||
* no longer owns the TimeZone object and should not delete it after this call.
|
||||
* @param zoneToAdopt the TimeZone to be adopted.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void adoptTimeZone(TimeZone* zoneToAdopt);
|
||||
|
||||
/**
|
||||
* Sets the time zone for the calendar of this DateFormat object.
|
||||
* @param zone the new time zone.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual void setTimeZone(const TimeZone& zone);
|
||||
|
||||
/**
|
||||
* Set a particular UDisplayContext value in the formatter, such as
|
||||
* UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
|
||||
* @param value The UDisplayContext value to set.
|
||||
* @param status Input/output status. If at entry this indicates a failure
|
||||
* status, the function will do nothing; otherwise this will be
|
||||
* updated with any new status from the function.
|
||||
* @stable ICU 53
|
||||
*/
|
||||
virtual void setContext(UDisplayContext value, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Get the formatter's UDisplayContext value for the specified UDisplayContextType,
|
||||
* such as UDISPCTX_TYPE_CAPITALIZATION.
|
||||
* @param type The UDisplayContextType whose value to return
|
||||
* @param status Input/output status. If at entry this indicates a failure
|
||||
* status, the function will do nothing; otherwise this will be
|
||||
* updated with any new status from the function.
|
||||
* @return The UDisplayContextValue for the specified type.
|
||||
* @stable ICU 53
|
||||
*/
|
||||
virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Sets an boolean attribute on this DateFormat.
|
||||
* May return U_UNSUPPORTED_ERROR if this instance does not support
|
||||
* the specified attribute.
|
||||
* @param attr the attribute to set
|
||||
* @param newvalue new value
|
||||
* @param status the error type
|
||||
* @return *this - for chaining (example: format.setAttribute(...).setAttribute(...) )
|
||||
* @stable ICU 53
|
||||
*/
|
||||
|
||||
virtual DateFormat& U_EXPORT2 setBooleanAttribute(UDateFormatBooleanAttribute attr,
|
||||
UBool newvalue,
|
||||
UErrorCode &status);
|
||||
|
||||
/**
|
||||
* Returns a boolean from this DateFormat
|
||||
* May return U_UNSUPPORTED_ERROR if this instance does not support
|
||||
* the specified attribute.
|
||||
* @param attr the attribute to set
|
||||
* @param status the error type
|
||||
* @return the attribute value. Undefined if there is an error.
|
||||
* @stable ICU 53
|
||||
*/
|
||||
virtual UBool U_EXPORT2 getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &status) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Default constructor. Creates a DateFormat with no Calendar or NumberFormat
|
||||
* associated with it. This constructor depends on the subclasses to fill in
|
||||
* the calendar and numberFormat fields.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DateFormat();
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DateFormat(const DateFormat&);
|
||||
|
||||
/**
|
||||
* Default assignment operator.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DateFormat& operator=(const DateFormat&);
|
||||
|
||||
/**
|
||||
* The calendar that DateFormat uses to produce the time field values needed
|
||||
* to implement date/time formatting. Subclasses should generally initialize
|
||||
* this to the default calendar for the locale associated with this DateFormat.
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
Calendar* fCalendar;
|
||||
|
||||
/**
|
||||
* The number formatter that DateFormat uses to format numbers in dates and
|
||||
* times. Subclasses should generally initialize this to the default number
|
||||
* format for the locale associated with this DateFormat.
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
NumberFormat* fNumberFormat;
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Gets the date/time formatter with the given formatting styles for the
|
||||
* given locale.
|
||||
* @param dateStyle the given date formatting style.
|
||||
* @param timeStyle the given time formatting style.
|
||||
* @param inLocale the given locale.
|
||||
* @return a date/time formatter, or 0 on failure.
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 create(EStyle timeStyle, EStyle dateStyle, const Locale& inLocale);
|
||||
|
||||
|
||||
/**
|
||||
* enum set of active boolean attributes for this instance
|
||||
*/
|
||||
EnumSet<UDateFormatBooleanAttribute, 0, UDAT_BOOLEAN_ATTRIBUTE_COUNT> fBoolFlags;
|
||||
|
||||
|
||||
UDisplayContext fCapitalizationContext;
|
||||
friend class DateFmtKeyByStyle;
|
||||
|
||||
public:
|
||||
#ifndef U_HIDE_OBSOLETE_API
|
||||
/**
|
||||
* Field selector for FieldPosition for DateFormat fields.
|
||||
* @obsolete ICU 3.4 use UDateFormatField instead, since this API will be
|
||||
* removed in that release
|
||||
*/
|
||||
enum EField
|
||||
{
|
||||
// Obsolete; use UDateFormatField instead
|
||||
kEraField = UDAT_ERA_FIELD,
|
||||
kYearField = UDAT_YEAR_FIELD,
|
||||
kMonthField = UDAT_MONTH_FIELD,
|
||||
kDateField = UDAT_DATE_FIELD,
|
||||
kHourOfDay1Field = UDAT_HOUR_OF_DAY1_FIELD,
|
||||
kHourOfDay0Field = UDAT_HOUR_OF_DAY0_FIELD,
|
||||
kMinuteField = UDAT_MINUTE_FIELD,
|
||||
kSecondField = UDAT_SECOND_FIELD,
|
||||
kMillisecondField = UDAT_FRACTIONAL_SECOND_FIELD,
|
||||
kDayOfWeekField = UDAT_DAY_OF_WEEK_FIELD,
|
||||
kDayOfYearField = UDAT_DAY_OF_YEAR_FIELD,
|
||||
kDayOfWeekInMonthField = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,
|
||||
kWeekOfYearField = UDAT_WEEK_OF_YEAR_FIELD,
|
||||
kWeekOfMonthField = UDAT_WEEK_OF_MONTH_FIELD,
|
||||
kAmPmField = UDAT_AM_PM_FIELD,
|
||||
kHour1Field = UDAT_HOUR1_FIELD,
|
||||
kHour0Field = UDAT_HOUR0_FIELD,
|
||||
kTimezoneField = UDAT_TIMEZONE_FIELD,
|
||||
kYearWOYField = UDAT_YEAR_WOY_FIELD,
|
||||
kDOWLocalField = UDAT_DOW_LOCAL_FIELD,
|
||||
kExtendedYearField = UDAT_EXTENDED_YEAR_FIELD,
|
||||
kJulianDayField = UDAT_JULIAN_DAY_FIELD,
|
||||
kMillisecondsInDayField = UDAT_MILLISECONDS_IN_DAY_FIELD,
|
||||
|
||||
// Obsolete; use UDateFormatField instead
|
||||
ERA_FIELD = UDAT_ERA_FIELD,
|
||||
YEAR_FIELD = UDAT_YEAR_FIELD,
|
||||
MONTH_FIELD = UDAT_MONTH_FIELD,
|
||||
DATE_FIELD = UDAT_DATE_FIELD,
|
||||
HOUR_OF_DAY1_FIELD = UDAT_HOUR_OF_DAY1_FIELD,
|
||||
HOUR_OF_DAY0_FIELD = UDAT_HOUR_OF_DAY0_FIELD,
|
||||
MINUTE_FIELD = UDAT_MINUTE_FIELD,
|
||||
SECOND_FIELD = UDAT_SECOND_FIELD,
|
||||
MILLISECOND_FIELD = UDAT_FRACTIONAL_SECOND_FIELD,
|
||||
DAY_OF_WEEK_FIELD = UDAT_DAY_OF_WEEK_FIELD,
|
||||
DAY_OF_YEAR_FIELD = UDAT_DAY_OF_YEAR_FIELD,
|
||||
DAY_OF_WEEK_IN_MONTH_FIELD = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,
|
||||
WEEK_OF_YEAR_FIELD = UDAT_WEEK_OF_YEAR_FIELD,
|
||||
WEEK_OF_MONTH_FIELD = UDAT_WEEK_OF_MONTH_FIELD,
|
||||
AM_PM_FIELD = UDAT_AM_PM_FIELD,
|
||||
HOUR1_FIELD = UDAT_HOUR1_FIELD,
|
||||
HOUR0_FIELD = UDAT_HOUR0_FIELD,
|
||||
TIMEZONE_FIELD = UDAT_TIMEZONE_FIELD
|
||||
};
|
||||
#endif /* U_HIDE_OBSOLETE_API */
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // _DATEFMT
|
||||
//eof
|
||||
@ -1,40 +0,0 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1999-2006,2013 IBM Corp. All rights reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
* 12/1/99 rgillam Complete port from Java.
|
||||
* 01/13/2000 helena Added UErrorCode to ctors.
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef DBBI_H
|
||||
#define DBBI_H
|
||||
|
||||
#include "unicode/rbbi.h"
|
||||
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Dictionary Based Break Iterator
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
#ifndef U_HIDE_DEPRECATED_API
|
||||
/**
|
||||
* An obsolete subclass of RuleBasedBreakIterator. Handling of dictionary-
|
||||
* based break iteration has been folded into the base class. This class
|
||||
* is deprecated as of ICU 3.6.
|
||||
* @deprecated ICU 3.6
|
||||
*/
|
||||
typedef RuleBasedBreakIterator DictionaryBasedBreakIterator;
|
||||
|
||||
#endif /* U_HIDE_DEPRECATED_API */
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
|
||||
|
||||
#endif
|
||||
@ -1,484 +0,0 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 1997-2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
* File DCFMTSYM.H
|
||||
*
|
||||
* Modification History:
|
||||
*
|
||||
* Date Name Description
|
||||
* 02/19/97 aliu Converted from java.
|
||||
* 03/18/97 clhuang Updated per C++ implementation.
|
||||
* 03/27/97 helena Updated to pass the simple test after code review.
|
||||
* 08/26/97 aliu Added currency/intl currency symbol support.
|
||||
* 07/22/98 stephen Changed to match C++ style
|
||||
* currencySymbol -> fCurrencySymbol
|
||||
* Constants changed from CAPS to kCaps
|
||||
* 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes
|
||||
* 09/22/00 grhoten Marked deprecation tags with a pointer to replacement
|
||||
* functions.
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef DCFMTSYM_H
|
||||
#define DCFMTSYM_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uchar.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/unum.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Symbols for formatting numbers.
|
||||
*/
|
||||
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* This class represents the set of symbols needed by DecimalFormat
|
||||
* to format numbers. DecimalFormat creates for itself an instance of
|
||||
* DecimalFormatSymbols from its locale data. If you need to change any
|
||||
* of these symbols, you can get the DecimalFormatSymbols object from
|
||||
* your DecimalFormat and modify it.
|
||||
* <P>
|
||||
* Here are the special characters used in the parts of the
|
||||
* subpattern, with notes on their usage.
|
||||
* <pre>
|
||||
* \code
|
||||
* Symbol Meaning
|
||||
* 0 a digit
|
||||
* # a digit, zero shows as absent
|
||||
* . placeholder for decimal separator
|
||||
* , placeholder for grouping separator.
|
||||
* ; separates formats.
|
||||
* - default negative prefix.
|
||||
* % divide by 100 and show as percentage
|
||||
* X any other characters can be used in the prefix or suffix
|
||||
* ' used to quote special characters in a prefix or suffix.
|
||||
* \endcode
|
||||
* </pre>
|
||||
* [Notes]
|
||||
* <P>
|
||||
* If there is no explicit negative subpattern, - is prefixed to the
|
||||
* positive form. That is, "0.00" alone is equivalent to "0.00;-0.00".
|
||||
* <P>
|
||||
* The grouping separator is commonly used for thousands, but in some
|
||||
* countries for ten-thousands. The interval is a constant number of
|
||||
* digits between the grouping characters, such as 100,000,000 or 1,0000,0000.
|
||||
* If you supply a pattern with multiple grouping characters, the interval
|
||||
* between the last one and the end of the integer is the one that is
|
||||
* used. So "#,##,###,####" == "######,####" == "##,####,####".
|
||||
* <P>
|
||||
* This class only handles localized digits where the 10 digits are
|
||||
* contiguous in Unicode, from 0 to 9. Other digits sets (such as
|
||||
* superscripts) would need a different subclass.
|
||||
*/
|
||||
class U_I18N_API DecimalFormatSymbols : public UObject {
|
||||
public:
|
||||
/**
|
||||
* Constants for specifying a number format symbol.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
enum ENumberFormatSymbol {
|
||||
/** The decimal separator */
|
||||
kDecimalSeparatorSymbol,
|
||||
/** The grouping separator */
|
||||
kGroupingSeparatorSymbol,
|
||||
/** The pattern separator */
|
||||
kPatternSeparatorSymbol,
|
||||
/** The percent sign */
|
||||
kPercentSymbol,
|
||||
/** Zero*/
|
||||
kZeroDigitSymbol,
|
||||
/** Character representing a digit in the pattern */
|
||||
kDigitSymbol,
|
||||
/** The minus sign */
|
||||
kMinusSignSymbol,
|
||||
/** The plus sign */
|
||||
kPlusSignSymbol,
|
||||
/** The currency symbol */
|
||||
kCurrencySymbol,
|
||||
/** The international currency symbol */
|
||||
kIntlCurrencySymbol,
|
||||
/** The monetary separator */
|
||||
kMonetarySeparatorSymbol,
|
||||
/** The exponential symbol */
|
||||
kExponentialSymbol,
|
||||
/** Per mill symbol - replaces kPermillSymbol */
|
||||
kPerMillSymbol,
|
||||
/** Escape padding character */
|
||||
kPadEscapeSymbol,
|
||||
/** Infinity symbol */
|
||||
kInfinitySymbol,
|
||||
/** Nan symbol */
|
||||
kNaNSymbol,
|
||||
/** Significant digit symbol
|
||||
* @stable ICU 3.0 */
|
||||
kSignificantDigitSymbol,
|
||||
/** The monetary grouping separator
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
kMonetaryGroupingSeparatorSymbol,
|
||||
/** One
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
kOneDigitSymbol,
|
||||
/** Two
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
kTwoDigitSymbol,
|
||||
/** Three
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
kThreeDigitSymbol,
|
||||
/** Four
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
kFourDigitSymbol,
|
||||
/** Five
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
kFiveDigitSymbol,
|
||||
/** Six
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
kSixDigitSymbol,
|
||||
/** Seven
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
kSevenDigitSymbol,
|
||||
/** Eight
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
kEightDigitSymbol,
|
||||
/** Nine
|
||||
* @stable ICU 4.6
|
||||
*/
|
||||
kNineDigitSymbol,
|
||||
#ifndef U_HIDE_DRAFT_API
|
||||
/** Multiplication sign.
|
||||
* @draft ICU 54
|
||||
*/
|
||||
kExponentMultiplicationSymbol,
|
||||
#endif /* U_HIDE_DRAFT_API */
|
||||
/** count symbol constants */
|
||||
kFormatSymbolCount = kNineDigitSymbol + 2
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a DecimalFormatSymbols object for the given locale.
|
||||
*
|
||||
* @param locale The locale to get symbols for.
|
||||
* @param status Input/output parameter, set to success or
|
||||
* failure code upon return.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DecimalFormatSymbols(const Locale& locale, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Create a DecimalFormatSymbols object for the default locale.
|
||||
* This constructor will not fail. If the resource file data is
|
||||
* not available, it will use hard-coded last-resort data and
|
||||
* set status to U_USING_FALLBACK_ERROR.
|
||||
*
|
||||
* @param status Input/output parameter, set to success or
|
||||
* failure code upon return.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DecimalFormatSymbols(UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Creates a DecimalFormatSymbols object with last-resort data.
|
||||
* Intended for callers who cache the symbols data and
|
||||
* set all symbols on the resulting object.
|
||||
*
|
||||
* The last-resort symbols are similar to those for the root data,
|
||||
* except that the grouping separators are empty,
|
||||
* the NaN symbol is U+FFFD rather than "NaN",
|
||||
* and the CurrencySpacing patterns are empty.
|
||||
*
|
||||
* @param status Input/output parameter, set to success or
|
||||
* failure code upon return.
|
||||
* @return last-resort symbols
|
||||
* @stable ICU 52
|
||||
*/
|
||||
static DecimalFormatSymbols* createWithLastResortData(UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DecimalFormatSymbols(const DecimalFormatSymbols&);
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual ~DecimalFormatSymbols();
|
||||
|
||||
/**
|
||||
* Return true if another object is semantically equal to this one.
|
||||
*
|
||||
* @param other the object to be compared with.
|
||||
* @return true if another object is semantically equal to this one.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UBool operator==(const DecimalFormatSymbols& other) const;
|
||||
|
||||
/**
|
||||
* Return true if another object is semantically unequal to this one.
|
||||
*
|
||||
* @param other the object to be compared with.
|
||||
* @return true if another object is semantically unequal to this one.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }
|
||||
|
||||
/**
|
||||
* Get one of the format symbols by its enum constant.
|
||||
* Each symbol is stored as a string so that graphemes
|
||||
* (characters with modifier letters) can be used.
|
||||
*
|
||||
* @param symbol Constant to indicate a number format symbol.
|
||||
* @return the format symbols by the param 'symbol'
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;
|
||||
|
||||
/**
|
||||
* Set one of the format symbols by its enum constant.
|
||||
* Each symbol is stored as a string so that graphemes
|
||||
* (characters with modifier letters) can be used.
|
||||
*
|
||||
* @param symbol Constant to indicate a number format symbol.
|
||||
* @param value value of the format symbol
|
||||
* @param propogateDigits If false, setting the zero digit will not automatically set 1-9.
|
||||
* The default behavior is to automatically set 1-9 if zero is being set and the value
|
||||
* it is being set to corresponds to a known Unicode zero digit.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits);
|
||||
|
||||
/**
|
||||
* Returns the locale for which this object was constructed.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
inline Locale getLocale() const;
|
||||
|
||||
/**
|
||||
* Returns the locale for this object. Two flavors are available:
|
||||
* valid and actual locale.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Get pattern string for 'CurrencySpacing' that can be applied to
|
||||
* currency format.
|
||||
* This API gets the CurrencySpacing data from ResourceBundle. The pattern can
|
||||
* be empty if there is no data from current locale and its parent locales.
|
||||
*
|
||||
* @param type : UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT.
|
||||
* @param beforeCurrency : true if the pattern is for before currency symbol.
|
||||
* false if the pattern is for after currency symbol.
|
||||
* @param status: Input/output parameter, set to success or
|
||||
* failure code upon return.
|
||||
* @return pattern string for currencyMatch, surroundingMatch or spaceInsert.
|
||||
* Return empty string if there is no data for this locale and its parent
|
||||
* locales.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
const UnicodeString& getPatternForCurrencySpacing(UCurrencySpacing type,
|
||||
UBool beforeCurrency,
|
||||
UErrorCode& status) const;
|
||||
/**
|
||||
* Set pattern string for 'CurrencySpacing' that can be applied to
|
||||
* currency format.
|
||||
*
|
||||
* @param type : UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT.
|
||||
* @param beforeCurrency : true if the pattern is for before currency symbol.
|
||||
* false if the pattern is for after currency symbol.
|
||||
* @param pattern : pattern string to override current setting.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
void setPatternForCurrencySpacing(UCurrencySpacing type,
|
||||
UBool beforeCurrency,
|
||||
const UnicodeString& pattern);
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID();
|
||||
|
||||
private:
|
||||
DecimalFormatSymbols();
|
||||
|
||||
/**
|
||||
* Initializes the symbols from the LocaleElements resource bundle.
|
||||
* Note: The organization of LocaleElements badly needs to be
|
||||
* cleaned up.
|
||||
*
|
||||
* @param locale The locale to get symbols for.
|
||||
* @param success Input/output parameter, set to success or
|
||||
* failure code upon return.
|
||||
* @param useLastResortData determine if use last resort data
|
||||
*/
|
||||
void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);
|
||||
|
||||
/**
|
||||
* Initialize the symbols with default values.
|
||||
*/
|
||||
void initialize();
|
||||
|
||||
void setCurrencyForSymbols();
|
||||
|
||||
public:
|
||||
/**
|
||||
* _Internal_ function - more efficient version of getSymbol,
|
||||
* returning a const reference to one of the symbol strings.
|
||||
* The returned reference becomes invalid when the symbol is changed
|
||||
* or when the DecimalFormatSymbols are destroyed.
|
||||
* ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be really public.
|
||||
* Note: moved #ifndef U_HIDE_INTERNAL_API after this, since this is needed for inline in DecimalFormat
|
||||
*
|
||||
* @param symbol Constant to indicate a number format symbol.
|
||||
* @return the format symbol by the param 'symbol'
|
||||
* @internal
|
||||
*/
|
||||
inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* Returns that pattern stored in currecy info. Internal API for use by NumberFormat API.
|
||||
* @internal
|
||||
*/
|
||||
inline const UChar* getCurrencyPattern(void) const;
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
private:
|
||||
/**
|
||||
* Private symbol strings.
|
||||
* They are either loaded from a resource bundle or otherwise owned.
|
||||
* setSymbol() clones the symbol string.
|
||||
* Readonly aliases can only come from a resource bundle, so that we can always
|
||||
* use fastCopyFrom() with them.
|
||||
*
|
||||
* If DecimalFormatSymbols becomes subclassable and the status of fSymbols changes
|
||||
* from private to protected,
|
||||
* or when fSymbols can be set any other way that allows them to be readonly aliases
|
||||
* to non-resource bundle strings,
|
||||
* then regular UnicodeString copies must be used instead of fastCopyFrom().
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
UnicodeString fSymbols[kFormatSymbolCount];
|
||||
|
||||
/**
|
||||
* Non-symbol variable for getConstSymbol(). Always empty.
|
||||
* @internal
|
||||
*/
|
||||
UnicodeString fNoSymbol;
|
||||
|
||||
Locale locale;
|
||||
|
||||
char actualLocale[ULOC_FULLNAME_CAPACITY];
|
||||
char validLocale[ULOC_FULLNAME_CAPACITY];
|
||||
const UChar* currPattern;
|
||||
|
||||
UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT];
|
||||
UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT];
|
||||
};
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
inline UnicodeString
|
||||
DecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {
|
||||
const UnicodeString *strPtr;
|
||||
if(symbol < kFormatSymbolCount) {
|
||||
strPtr = &fSymbols[symbol];
|
||||
} else {
|
||||
strPtr = &fNoSymbol;
|
||||
}
|
||||
return *strPtr;
|
||||
}
|
||||
|
||||
//#ifndef U_HIDE_INTERNAL_API
|
||||
// See comments above for this function. Not hidden.
|
||||
inline const UnicodeString &
|
||||
DecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {
|
||||
const UnicodeString *strPtr;
|
||||
if(symbol < kFormatSymbolCount) {
|
||||
strPtr = &fSymbols[symbol];
|
||||
} else {
|
||||
strPtr = &fNoSymbol;
|
||||
}
|
||||
return *strPtr;
|
||||
}
|
||||
|
||||
//#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
inline void
|
||||
DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits = TRUE) {
|
||||
if(symbol<kFormatSymbolCount) {
|
||||
fSymbols[symbol]=value;
|
||||
}
|
||||
|
||||
// If the zero digit is being set to a known zero digit according to Unicode,
|
||||
// then we automatically set the corresponding 1-9 digits
|
||||
if ( propogateDigits && symbol == kZeroDigitSymbol && value.countChar32() == 1 ) {
|
||||
UChar32 sym = value.char32At(0);
|
||||
if ( u_charDigitValue(sym) == 0 ) {
|
||||
for ( int8_t i = 1 ; i<= 9 ; i++ ) {
|
||||
sym++;
|
||||
fSymbols[(int)kOneDigitSymbol+i-1] = UnicodeString(sym);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
inline Locale
|
||||
DecimalFormatSymbols::getLocale() const {
|
||||
return locale;
|
||||
}
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
inline const UChar*
|
||||
DecimalFormatSymbols::getCurrencyPattern() const {
|
||||
return currPattern;
|
||||
}
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // _DCFMTSYM
|
||||
//eof
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,215 +0,0 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2012, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*
|
||||
* FILE NAME: DOCMAIN.h
|
||||
*
|
||||
* Date Name Description
|
||||
* 12/11/2000 Ram Creation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief (Non API- contains Doxygen definitions)
|
||||
*
|
||||
* This file contains documentation for Doxygen and doesnot have
|
||||
* any significance with respect to C or C++ API
|
||||
*/
|
||||
|
||||
/*! \mainpage
|
||||
*
|
||||
* \section API API Reference Usage
|
||||
*
|
||||
* <h3>C++ Programmers:</h3>
|
||||
* <p>Use <a href="hierarchy.html">Class Hierarchy</a> or <a href="classes.html"> Alphabetical List </a>
|
||||
* or <a href="annotated.html"> Compound List</a>
|
||||
* to find the class you are interested in. For example, to find BreakIterator,
|
||||
* you can go to the <a href="classes.html"> Alphabetical List</a>, then click on
|
||||
* "BreakIterator". Once you are at the class, you will find an inheritance
|
||||
* chart, a list of the public members, a detailed description of the class,
|
||||
* then detailed member descriptions.</p>
|
||||
*
|
||||
* <h3>C Programmers:</h3>
|
||||
* <p>Use <a href="#Module">Module List</a> or <a href="globals.html">File Members</a>
|
||||
* to find a list of all the functions and constants.
|
||||
* For example, to find BreakIterator functions you would click on
|
||||
* <a href="files.html"> File List</a>,
|
||||
* then find "ubrk.h" and click on it. You will find descriptions of Defines,
|
||||
* Typedefs, Enumerations, and Functions, with detailed descriptions below.
|
||||
* If you want to find a specific function, such as ubrk_next(), then click
|
||||
* first on <a href="globals.html"> File Members</a>, then use your browser
|
||||
* Find dialog to search for "ubrk_next()".</p>
|
||||
*
|
||||
*
|
||||
* <h3>API References for Previous Releases</h3>
|
||||
* <p>The API References for each release of ICU are also available as
|
||||
* a zip file from the ICU
|
||||
* <a href="http://site.icu-project.org/download">download page</a>.</p>
|
||||
*
|
||||
* <hr>
|
||||
*
|
||||
* <h2>Architecture (User's Guide)</h2>
|
||||
* <ul>
|
||||
* <li><a href="http://userguide.icu-project.org/">Introduction</a></li>
|
||||
* <li><a href="http://userguide.icu-project.org/i18n">Internationalization</a></li>
|
||||
* <li><a href="http://userguide.icu-project.org/design">Locale Model, Multithreading, Error Handling, etc.</a></li>
|
||||
* <li><a href="http://userguide.icu-project.org/conversion">Conversion</a></li>
|
||||
* </ul>
|
||||
*
|
||||
* <hr>
|
||||
*\htmlonly <h2><a NAME="Module">Module List</a></h2> \endhtmlonly
|
||||
* <table border="1" cols="3" align="center">
|
||||
* <tr>
|
||||
* <td><strong>Module Name</strong></td>
|
||||
* <td><strong>C</strong></td>
|
||||
* <td><strong>C++</strong></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Basic Types and Constants</td>
|
||||
* <td>utypes.h</td>
|
||||
* <td>utypes.h</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Strings and Character Iteration</td>
|
||||
* <td>ustring.h, utf8.h, utf16.h, UText, UCharIterator</td>
|
||||
* <td>icu::UnicodeString, icu::CharacterIterator, icu::Appendable, icu::StringPiece,icu::ByteSink</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Unicode Character<br/>Properties and Names</td>
|
||||
* <td>uchar.h, uscript.h</td>
|
||||
* <td>C API</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Sets of Unicode Code Points and Strings</td>
|
||||
* <td>uset.h</td>
|
||||
* <td>icu::UnicodeSet</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Maps from Strings to Integer Values</td>
|
||||
* <td>(no C API)</td>
|
||||
* <td>icu::BytesTrie, icu::UCharsTrie</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Codepage Conversion</td>
|
||||
* <td>ucnv.h, ucnvsel.hb</td>
|
||||
* <td>C API</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Unicode Text Compression</td>
|
||||
* <td>ucnv.h<br/>(encoding name "SCSU" or "BOCU-1")</td>
|
||||
* <td>C API</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Locales </td>
|
||||
* <td>uloc.h</a></td>
|
||||
* <td>icu::Locale</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Resource Bundles</td>
|
||||
* <td>ures.h</td>
|
||||
* <td>icu::ResourceBundle</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Normalization</td>
|
||||
* <td>unorm2.h</td>
|
||||
* <td>icu::Normalizer2</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Calendars</td>
|
||||
* <td>ucal.h</td>
|
||||
* <td>icu::Calendar</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Date and Time Formatting</td>
|
||||
* <td>udat.h</td>
|
||||
* <td>icu::DateFormat</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Message Formatting</td>
|
||||
* <td>umsg.h</td>
|
||||
* <td>icu::MessageFormat</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Number Formatting</td>
|
||||
* <td>unum.h</td>
|
||||
* <td>icu::NumberFormat</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Number Spellout<br/>(Rule Based Number Formatting)</td>
|
||||
* <td>unum.h<br/>(use UNUM_SPELLOUT)</td>
|
||||
* <td>icu::RuleBasedNumberFormat</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Text Transformation<br/>(Transliteration)</td>
|
||||
* <td>utrans.h</td>
|
||||
* <td>icu::Transliterator</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Bidirectional Algorithm</td>
|
||||
* <td>ubidi.h</td>
|
||||
* <td>C API</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Arabic Shaping</td>
|
||||
* <td>ushape.h</td>
|
||||
* <td>C API</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Collation</td>
|
||||
* <td>ucol.h</td>
|
||||
* <td>icu::Collator</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>String Searching</td>
|
||||
* <td>usearch.h</td>
|
||||
* <td>icu::StringSearch</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Index Characters/<br/>Bucketing for Sorted Lists</td>
|
||||
* <td>(no C API)</td>
|
||||
* <td>icu::AlphabeticIndex</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Text Boundary Analysis<br/>(Break Iteration)</td>
|
||||
* <td>ubrk.h</td>
|
||||
* <td>icu::BreakIterator</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Regular Expressions</td>
|
||||
* <td>uregex.h</td>
|
||||
* <td>icu::RegexPattern, icu::RegexMatcher</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>StringPrep</td>
|
||||
* <td>usprep.h</td>
|
||||
* <td>C API</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>International Domain Names in Applications:<br/>
|
||||
* UTS #46 in C/C++, IDNA2003 only via C API</td>
|
||||
* <td>uidna.h</td>
|
||||
* <td>idna.h</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Identifier Spoofing & Confusability</td>
|
||||
* <td>uspoof.h</td>
|
||||
* <td>C API</td>
|
||||
* <tr>
|
||||
* <td>Universal Time Scale</td>
|
||||
* <td>utmscale.h</td>
|
||||
* <td>C API</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Layout Engine/Complex Text Layout</td>
|
||||
* <td>loengine.h</td>
|
||||
* <td>icu::LayoutEngine,icu::ParagraphLayout</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>ICU I/O</td>
|
||||
* <td>ustdio.h</td>
|
||||
* <td>ustream.h</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* <i>This main page is generated from docmain.h</i>
|
||||
*/
|
||||
@ -1,971 +0,0 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 1997-2015, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
* File DTFMTSYM.H
|
||||
*
|
||||
* Modification History:
|
||||
*
|
||||
* Date Name Description
|
||||
* 02/19/97 aliu Converted from java.
|
||||
* 07/21/98 stephen Added getZoneIndex()
|
||||
* Changed to match C++ conventions
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef DTFMTSYM_H
|
||||
#define DTFMTSYM_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/calendar.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/udat.h"
|
||||
#include "unicode/ures.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Symbols for formatting dates.
|
||||
*/
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
/* forward declaration */
|
||||
class SimpleDateFormat;
|
||||
class Hashtable;
|
||||
|
||||
/**
|
||||
* DateFormatSymbols is a public class for encapsulating localizable date-time
|
||||
* formatting data -- including timezone data. DateFormatSymbols is used by
|
||||
* DateFormat and SimpleDateFormat.
|
||||
* <P>
|
||||
* Rather than first creating a DateFormatSymbols to get a date-time formatter
|
||||
* by using a SimpleDateFormat constructor, clients are encouraged to create a
|
||||
* date-time formatter using the getTimeInstance(), getDateInstance(), or
|
||||
* getDateTimeInstance() method in DateFormat. Each of these methods can return a
|
||||
* date/time formatter initialized with a default format pattern along with the
|
||||
* date-time formatting data for a given or default locale. After a formatter is
|
||||
* created, clients may modify the format pattern using the setPattern function
|
||||
* as so desired. For more information on using these formatter factory
|
||||
* functions, see DateFormat.
|
||||
* <P>
|
||||
* If clients decide to create a date-time formatter with a particular format
|
||||
* pattern and locale, they can do so with new SimpleDateFormat(aPattern,
|
||||
* new DateFormatSymbols(aLocale)). This will load the appropriate date-time
|
||||
* formatting data from the locale.
|
||||
* <P>
|
||||
* DateFormatSymbols objects are clonable. When clients obtain a
|
||||
* DateFormatSymbols object, they can feel free to modify the date-time
|
||||
* formatting data as necessary. For instance, clients can
|
||||
* replace the localized date-time format pattern characters with the ones that
|
||||
* they feel easy to remember. Or they can change the representative cities
|
||||
* originally picked by default to using their favorite ones.
|
||||
* <P>
|
||||
* DateFormatSymbols are not expected to be subclassed. Data for a calendar is
|
||||
* loaded out of resource bundles. The 'type' parameter indicates the type of
|
||||
* calendar, for example, "gregorian" or "japanese". If the type is not gregorian
|
||||
* (or NULL, or an empty string) then the type is appended to the resource name,
|
||||
* for example, 'Eras_japanese' instead of 'Eras'. If the resource 'Eras_japanese' did
|
||||
* not exist (even in root), then this class will fall back to just 'Eras', that is,
|
||||
* Gregorian data. Therefore, the calendar implementor MUST ensure that the root
|
||||
* locale at least contains any resources that are to be particularized for the
|
||||
* calendar type.
|
||||
*/
|
||||
class U_I18N_API DateFormatSymbols U_FINAL : public UObject {
|
||||
public:
|
||||
/**
|
||||
* Construct a DateFormatSymbols object by loading format data from
|
||||
* resources for the default locale, in the default calendar (Gregorian).
|
||||
* <P>
|
||||
* NOTE: This constructor will never fail; if it cannot get resource
|
||||
* data for the default locale, it will return a last-resort object
|
||||
* based on hard-coded strings.
|
||||
*
|
||||
* @param status Status code. Failure
|
||||
* results if the resources for the default cannot be
|
||||
* found or cannot be loaded
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DateFormatSymbols(UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Construct a DateFormatSymbols object by loading format data from
|
||||
* resources for the given locale, in the default calendar (Gregorian).
|
||||
*
|
||||
* @param locale Locale to load format data from.
|
||||
* @param status Status code. Failure
|
||||
* results if the resources for the locale cannot be
|
||||
* found or cannot be loaded
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DateFormatSymbols(const Locale& locale,
|
||||
UErrorCode& status);
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* Construct a DateFormatSymbols object by loading format data from
|
||||
* resources for the default locale, in the default calendar (Gregorian).
|
||||
* <P>
|
||||
* NOTE: This constructor will never fail; if it cannot get resource
|
||||
* data for the default locale, it will return a last-resort object
|
||||
* based on hard-coded strings.
|
||||
*
|
||||
* @param type Type of calendar (as returned by Calendar::getType).
|
||||
* Will be used to access the correct set of strings.
|
||||
* (NULL or empty string defaults to "gregorian".)
|
||||
* @param status Status code. Failure
|
||||
* results if the resources for the default cannot be
|
||||
* found or cannot be loaded
|
||||
* @internal
|
||||
*/
|
||||
DateFormatSymbols(const char *type, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Construct a DateFormatSymbols object by loading format data from
|
||||
* resources for the given locale, in the default calendar (Gregorian).
|
||||
*
|
||||
* @param locale Locale to load format data from.
|
||||
* @param type Type of calendar (as returned by Calendar::getType).
|
||||
* Will be used to access the correct set of strings.
|
||||
* (NULL or empty string defaults to "gregorian".)
|
||||
* @param status Status code. Failure
|
||||
* results if the resources for the locale cannot be
|
||||
* found or cannot be loaded
|
||||
* @internal
|
||||
*/
|
||||
DateFormatSymbols(const Locale& locale,
|
||||
const char *type,
|
||||
UErrorCode& status);
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DateFormatSymbols(const DateFormatSymbols&);
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
DateFormatSymbols& operator=(const DateFormatSymbols&);
|
||||
|
||||
/**
|
||||
* Destructor. This is nonvirtual because this class is not designed to be
|
||||
* subclassed.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
virtual ~DateFormatSymbols();
|
||||
|
||||
/**
|
||||
* Return true if another object is semantically equal to this one.
|
||||
*
|
||||
* @param other the DateFormatSymbols object to be compared with.
|
||||
* @return true if other is semantically equal to this.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UBool operator==(const DateFormatSymbols& other) const;
|
||||
|
||||
/**
|
||||
* Return true if another object is semantically unequal to this one.
|
||||
*
|
||||
* @param other the DateFormatSymbols object to be compared with.
|
||||
* @return true if other is semantically unequal to this.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }
|
||||
|
||||
/**
|
||||
* Gets abbreviated era strings. For example: "AD" and "BC".
|
||||
*
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the era strings.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
const UnicodeString* getEras(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Sets abbreviated era strings. For example: "AD" and "BC".
|
||||
* @param eras Array of era strings (DateFormatSymbols retains ownership.)
|
||||
* @param count Filled in with length of the array.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setEras(const UnicodeString* eras, int32_t count);
|
||||
|
||||
/**
|
||||
* Gets era name strings. For example: "Anno Domini" and "Before Christ".
|
||||
*
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the era name strings.
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
const UnicodeString* getEraNames(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Sets era name strings. For example: "Anno Domini" and "Before Christ".
|
||||
* @param eraNames Array of era name strings (DateFormatSymbols retains ownership.)
|
||||
* @param count Filled in with length of the array.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
void setEraNames(const UnicodeString* eraNames, int32_t count);
|
||||
|
||||
/**
|
||||
* Gets narrow era strings. For example: "A" and "B".
|
||||
*
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the narrow era strings.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
const UnicodeString* getNarrowEras(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Sets narrow era strings. For example: "A" and "B".
|
||||
* @param narrowEras Array of narrow era strings (DateFormatSymbols retains ownership.)
|
||||
* @param count Filled in with length of the array.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
void setNarrowEras(const UnicodeString* narrowEras, int32_t count);
|
||||
|
||||
/**
|
||||
* Gets month strings. For example: "January", "February", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the month strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
const UnicodeString* getMonths(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Sets month strings. For example: "January", "February", etc.
|
||||
*
|
||||
* @param months the new month strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setMonths(const UnicodeString* months, int32_t count);
|
||||
|
||||
/**
|
||||
* Gets short month strings. For example: "Jan", "Feb", etc.
|
||||
*
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the short month strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
const UnicodeString* getShortMonths(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Sets short month strings. For example: "Jan", "Feb", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @param shortMonths the new short month strings. (not adopted; caller retains ownership)
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setShortMonths(const UnicodeString* shortMonths, int32_t count);
|
||||
|
||||
/**
|
||||
* Selector for date formatting context
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
enum DtContextType {
|
||||
FORMAT,
|
||||
STANDALONE,
|
||||
DT_CONTEXT_COUNT
|
||||
};
|
||||
|
||||
/**
|
||||
* Selector for date formatting width
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
enum DtWidthType {
|
||||
ABBREVIATED,
|
||||
WIDE,
|
||||
NARROW,
|
||||
/**
|
||||
* Short width is currently only supported for weekday names.
|
||||
* @stable ICU 51
|
||||
*/
|
||||
SHORT,
|
||||
/**
|
||||
*/
|
||||
DT_WIDTH_COUNT = 4
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets month strings by width and context. For example: "January", "February", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The formatting context, either FORMAT or STANDALONE
|
||||
* @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
|
||||
* @return the month strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;
|
||||
|
||||
/**
|
||||
* Sets month strings by width and context. For example: "January", "February", etc.
|
||||
*
|
||||
* @param months The new month strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The formatting context, either FORMAT or STANDALONE
|
||||
* @param width The width of returned strings, either WIDE, ABBREVIATED, or NARROW.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);
|
||||
|
||||
/**
|
||||
* Gets wide weekday strings. For example: "Sunday", "Monday", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the weekday strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
const UnicodeString* getWeekdays(int32_t& count) const;
|
||||
|
||||
|
||||
/**
|
||||
* Sets wide weekday strings. For example: "Sunday", "Monday", etc.
|
||||
* @param weekdays the new weekday strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setWeekdays(const UnicodeString* weekdays, int32_t count);
|
||||
|
||||
/**
|
||||
* Gets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
|
||||
* misleading; it does not get the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the abbreviated weekday strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
const UnicodeString* getShortWeekdays(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Sets abbreviated weekday strings. For example: "Sun", "Mon", etc. (Note: The method name is
|
||||
* misleading; it does not set the CLDR-style "short" weekday strings, e.g. "Su", "Mo", etc.)
|
||||
* @param abbrevWeekdays the new abbreviated weekday strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setShortWeekdays(const UnicodeString* abbrevWeekdays, int32_t count);
|
||||
|
||||
/**
|
||||
* Gets weekday strings by width and context. For example: "Sunday", "Monday", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The formatting context, either FORMAT or STANDALONE
|
||||
* @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
|
||||
* @return the month strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;
|
||||
|
||||
/**
|
||||
* Sets weekday strings by width and context. For example: "Sunday", "Monday", etc.
|
||||
* @param weekdays The new weekday strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The formatting context, either FORMAT or STANDALONE
|
||||
* @param width The width of returned strings, either WIDE, ABBREVIATED, SHORT, or NARROW
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);
|
||||
|
||||
/**
|
||||
* Gets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The formatting context, either FORMAT or STANDALONE
|
||||
* @param width The width of returned strings, either WIDE or ABBREVIATED. There
|
||||
* are no NARROW quarters.
|
||||
* @return the quarter strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;
|
||||
|
||||
/**
|
||||
* Sets quarter strings by width and context. For example: "1st Quarter", "2nd Quarter", etc.
|
||||
*
|
||||
* @param quarters The new quarter strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The formatting context, either FORMAT or STANDALONE
|
||||
* @param width The width of returned strings, either WIDE or ABBREVIATED. There
|
||||
* are no NARROW quarters.
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);
|
||||
|
||||
/**
|
||||
* Gets AM/PM strings. For example: "AM" and "PM".
|
||||
* @param count Filled in with length of the array.
|
||||
* @return the weekday strings. (DateFormatSymbols retains ownership.)
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
const UnicodeString* getAmPmStrings(int32_t& count) const;
|
||||
|
||||
/**
|
||||
* Sets ampm strings. For example: "AM" and "PM".
|
||||
* @param ampms the new ampm strings. (not adopted; caller retains ownership)
|
||||
* @param count Filled in with length of the array.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setAmPmStrings(const UnicodeString* ampms, int32_t count);
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* This default time separator is used for formatting when the locale
|
||||
* doesn't specify any time separator, and always recognized when parsing.
|
||||
* @internal
|
||||
*/
|
||||
static const UChar DEFAULT_TIME_SEPARATOR = 0x003a; // ':'
|
||||
|
||||
/**
|
||||
* This alternate time separator is always recognized when parsing.
|
||||
* @internal
|
||||
*/
|
||||
static const UChar ALTERNATE_TIME_SEPARATOR = 0x002e; // '.'
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
#ifndef U_HIDE_DRAFT_API
|
||||
/**
|
||||
* Gets the time separator string. For example: ":".
|
||||
* @param result Output param which will receive the time separator string.
|
||||
* @return A reference to 'result'.
|
||||
* @draft ICU 55
|
||||
*/
|
||||
UnicodeString& getTimeSeparatorString(UnicodeString& result) const;
|
||||
|
||||
/**
|
||||
* Sets the time separator string. For example: ":".
|
||||
* @param newTimeSeparator the new time separator string.
|
||||
* @draft ICU 55
|
||||
*/
|
||||
void setTimeSeparatorString(const UnicodeString& newTimeSeparator);
|
||||
#endif /* U_HIDE_DRAFT_API */
|
||||
|
||||
#ifndef U_HIDE_DRAFT_API
|
||||
/**
|
||||
* Gets cyclic year name strings if the calendar has them, by width and context.
|
||||
* For example: "jia-zi", "yi-chou", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The usage context: FORMAT, STANDALONE.
|
||||
* @param width The requested name width: WIDE, ABBREVIATED, NARROW.
|
||||
* @return The year name strings (DateFormatSymbols retains ownership),
|
||||
* or null if they are not available for this calendar.
|
||||
* @draft ICU 54
|
||||
*/
|
||||
const UnicodeString* getYearNames(int32_t& count,
|
||||
DtContextType context, DtWidthType width) const;
|
||||
|
||||
/**
|
||||
* Sets cyclic year name strings by width and context. For example: "jia-zi", "yi-chou", etc.
|
||||
*
|
||||
* @param yearNames The new cyclic year name strings (not adopted; caller retains ownership).
|
||||
* @param count The length of the array.
|
||||
* @param context The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
|
||||
* @param width The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
|
||||
* @draft ICU 54
|
||||
*/
|
||||
void setYearNames(const UnicodeString* yearNames, int32_t count,
|
||||
DtContextType context, DtWidthType width);
|
||||
|
||||
/**
|
||||
* Gets calendar zodiac name strings if the calendar has them, by width and context.
|
||||
* For example: "Rat", "Ox", "Tiger", etc.
|
||||
* @param count Filled in with length of the array.
|
||||
* @param context The usage context: FORMAT, STANDALONE.
|
||||
* @param width The requested name width: WIDE, ABBREVIATED, NARROW.
|
||||
* @return The zodiac name strings (DateFormatSymbols retains ownership),
|
||||
* or null if they are not available for this calendar.
|
||||
* @draft ICU 54
|
||||
*/
|
||||
const UnicodeString* getZodiacNames(int32_t& count,
|
||||
DtContextType context, DtWidthType width) const;
|
||||
|
||||
/**
|
||||
* Sets calendar zodiac name strings by width and context. For example: "Rat", "Ox", "Tiger", etc.
|
||||
*
|
||||
* @param zodiacNames The new zodiac name strings (not adopted; caller retains ownership).
|
||||
* @param count The length of the array.
|
||||
* @param context The usage context: FORMAT, STANDALONE (currently only FORMAT is supported).
|
||||
* @param width The name width: WIDE, ABBREVIATED, NARROW (currently only ABBREVIATED is supported).
|
||||
* @draft ICU 54
|
||||
*/
|
||||
void setZodiacNames(const UnicodeString* zodiacNames, int32_t count,
|
||||
DtContextType context, DtWidthType width);
|
||||
|
||||
#endif /* U_HIDE_DRAFT_API */
|
||||
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* Somewhat temporary constants for leap month pattern types, adequate for supporting
|
||||
* just leap month patterns as needed for Chinese lunar calendar.
|
||||
* Eventually we will add full support for different month pattern types (needed for
|
||||
* other calendars such as Hindu) at which point this approach will be replaced by a
|
||||
* more complete approach.
|
||||
* @internal
|
||||
*/
|
||||
enum EMonthPatternType
|
||||
{
|
||||
kLeapMonthPatternFormatWide,
|
||||
kLeapMonthPatternFormatAbbrev,
|
||||
kLeapMonthPatternFormatNarrow,
|
||||
kLeapMonthPatternStandaloneWide,
|
||||
kLeapMonthPatternStandaloneAbbrev,
|
||||
kLeapMonthPatternStandaloneNarrow,
|
||||
kLeapMonthPatternNumeric,
|
||||
kMonthPatternsCount
|
||||
};
|
||||
|
||||
/**
|
||||
* Somewhat temporary function for getting complete set of leap month patterns for all
|
||||
* contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar
|
||||
* does not have leap month patterns. Note, there is currently no setter for this.
|
||||
* Eventually we will add full support for different month pattern types (needed for
|
||||
* other calendars such as Hindu) at which point this approach will be replaced by a
|
||||
* more complete approach.
|
||||
* @param count Filled in with length of the array (may be 0).
|
||||
* @return The leap month patterns (DateFormatSymbols retains ownership).
|
||||
* May be NULL if there are no leap month patterns for this calendar.
|
||||
* @internal
|
||||
*/
|
||||
const UnicodeString* getLeapMonthPatterns(int32_t& count) const;
|
||||
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
|
||||
#ifndef U_HIDE_DEPRECATED_API
|
||||
/**
|
||||
* Gets timezone strings. These strings are stored in a 2-dimensional array.
|
||||
* @param rowCount Output param to receive number of rows.
|
||||
* @param columnCount Output param to receive number of columns.
|
||||
* @return The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
|
||||
* @deprecated ICU 3.6
|
||||
*/
|
||||
const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;
|
||||
#endif /* U_HIDE_DEPRECATED_API */
|
||||
|
||||
/**
|
||||
* Sets timezone strings. These strings are stored in a 2-dimensional array.
|
||||
* <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in
|
||||
* a DateFormatSymbols. Therefore, the time zone strings set by this mthod
|
||||
* have no effects in an instance of SimpleDateFormat for formatting time
|
||||
* zones.
|
||||
* @param strings The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
|
||||
* @param rowCount The number of rows (count of first index).
|
||||
* @param columnCount The number of columns (count of second index).
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);
|
||||
|
||||
/**
|
||||
* Get the non-localized date-time pattern characters.
|
||||
* @return the non-localized date-time pattern characters
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
static const UChar * U_EXPORT2 getPatternUChars(void);
|
||||
|
||||
/**
|
||||
* Gets localized date-time pattern characters. For example: 'u', 't', etc.
|
||||
* <p>
|
||||
* Note: ICU no longer provides localized date-time pattern characters for a locale
|
||||
* starting ICU 3.8. This method returns the non-localized date-time pattern
|
||||
* characters unless user defined localized data is set by setLocalPatternChars.
|
||||
* @param result Output param which will receive the localized date-time pattern characters.
|
||||
* @return A reference to 'result'.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UnicodeString& getLocalPatternChars(UnicodeString& result) const;
|
||||
|
||||
/**
|
||||
* Sets localized date-time pattern characters. For example: 'u', 't', etc.
|
||||
* @param newLocalPatternChars the new localized date-time
|
||||
* pattern characters.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
void setLocalPatternChars(const UnicodeString& newLocalPatternChars);
|
||||
|
||||
/**
|
||||
* Returns the locale for this object. Two flavors are available:
|
||||
* valid and actual locale.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
|
||||
|
||||
/* The following type and kCapContextUsageTypeCount cannot be #ifndef U_HIDE_INTERNAL_API,
|
||||
they are needed for .h file declarations. */
|
||||
/**
|
||||
* Constants for capitalization context usage types.
|
||||
* @internal
|
||||
*/
|
||||
enum ECapitalizationContextUsageType
|
||||
{
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
kCapContextUsageOther = 0,
|
||||
kCapContextUsageMonthFormat, /* except narrow */
|
||||
kCapContextUsageMonthStandalone, /* except narrow */
|
||||
kCapContextUsageMonthNarrow,
|
||||
kCapContextUsageDayFormat, /* except narrow */
|
||||
kCapContextUsageDayStandalone, /* except narrow */
|
||||
kCapContextUsageDayNarrow,
|
||||
kCapContextUsageEraWide,
|
||||
kCapContextUsageEraAbbrev,
|
||||
kCapContextUsageEraNarrow,
|
||||
kCapContextUsageZoneLong,
|
||||
kCapContextUsageZoneShort,
|
||||
kCapContextUsageMetazoneLong,
|
||||
kCapContextUsageMetazoneShort,
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
kCapContextUsageTypeCount = 14
|
||||
};
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
||||
*
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
virtual UClassID getDynamicClassID() const;
|
||||
|
||||
/**
|
||||
* ICU "poor man's RTTI", returns a UClassID for this class.
|
||||
*
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID();
|
||||
|
||||
private:
|
||||
|
||||
friend class SimpleDateFormat;
|
||||
friend class DateFormatSymbolsSingleSetter; // see udat.cpp
|
||||
|
||||
/**
|
||||
* Abbreviated era strings. For example: "AD" and "BC".
|
||||
*/
|
||||
UnicodeString* fEras;
|
||||
int32_t fErasCount;
|
||||
|
||||
/**
|
||||
* Era name strings. For example: "Anno Domini" and "Before Christ".
|
||||
*/
|
||||
UnicodeString* fEraNames;
|
||||
int32_t fEraNamesCount;
|
||||
|
||||
/**
|
||||
* Narrow era strings. For example: "A" and "B".
|
||||
*/
|
||||
UnicodeString* fNarrowEras;
|
||||
int32_t fNarrowErasCount;
|
||||
|
||||
/**
|
||||
* Month strings. For example: "January", "February", etc.
|
||||
*/
|
||||
UnicodeString* fMonths;
|
||||
int32_t fMonthsCount;
|
||||
|
||||
/**
|
||||
* Short month strings. For example: "Jan", "Feb", etc.
|
||||
*/
|
||||
UnicodeString* fShortMonths;
|
||||
int32_t fShortMonthsCount;
|
||||
|
||||
/**
|
||||
* Narrow month strings. For example: "J", "F", etc.
|
||||
*/
|
||||
UnicodeString* fNarrowMonths;
|
||||
int32_t fNarrowMonthsCount;
|
||||
|
||||
/**
|
||||
* Standalone Month strings. For example: "January", "February", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneMonths;
|
||||
int32_t fStandaloneMonthsCount;
|
||||
|
||||
/**
|
||||
* Standalone Short month strings. For example: "Jan", "Feb", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneShortMonths;
|
||||
int32_t fStandaloneShortMonthsCount;
|
||||
|
||||
/**
|
||||
* Standalone Narrow month strings. For example: "J", "F", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneNarrowMonths;
|
||||
int32_t fStandaloneNarrowMonthsCount;
|
||||
|
||||
/**
|
||||
* CLDR-style format wide weekday strings. For example: "Sunday", "Monday", etc.
|
||||
*/
|
||||
UnicodeString* fWeekdays;
|
||||
int32_t fWeekdaysCount;
|
||||
|
||||
/**
|
||||
* CLDR-style format abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
|
||||
*/
|
||||
UnicodeString* fShortWeekdays;
|
||||
int32_t fShortWeekdaysCount;
|
||||
|
||||
/**
|
||||
* CLDR-style format short weekday strings. For example: "Su", "Mo", etc.
|
||||
*/
|
||||
UnicodeString* fShorterWeekdays;
|
||||
int32_t fShorterWeekdaysCount;
|
||||
|
||||
/**
|
||||
* CLDR-style format narrow weekday strings. For example: "S", "M", etc.
|
||||
*/
|
||||
UnicodeString* fNarrowWeekdays;
|
||||
int32_t fNarrowWeekdaysCount;
|
||||
|
||||
/**
|
||||
* CLDR-style standalone wide weekday strings. For example: "Sunday", "Monday", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneWeekdays;
|
||||
int32_t fStandaloneWeekdaysCount;
|
||||
|
||||
/**
|
||||
* CLDR-style standalone abbreviated (not short) weekday strings. For example: "Sun", "Mon", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneShortWeekdays;
|
||||
int32_t fStandaloneShortWeekdaysCount;
|
||||
|
||||
/**
|
||||
* CLDR-style standalone short weekday strings. For example: "Su", "Mo", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneShorterWeekdays;
|
||||
int32_t fStandaloneShorterWeekdaysCount;
|
||||
|
||||
/**
|
||||
* Standalone Narrow weekday strings. For example: "Sun", "Mon", etc.
|
||||
*/
|
||||
UnicodeString* fStandaloneNarrowWeekdays;
|
||||
int32_t fStandaloneNarrowWeekdaysCount;
|
||||
|
||||
/**
|
||||
* Ampm strings. For example: "AM" and "PM".
|
||||
*/
|
||||
UnicodeString* fAmPms;
|
||||
int32_t fAmPmsCount;
|
||||
|
||||
/**
|
||||
* Narrow Ampm strings. For example: "a" and "p".
|
||||
*/
|
||||
UnicodeString* fNarrowAmPms;
|
||||
int32_t fNarrowAmPmsCount;
|
||||
|
||||
/**
|
||||
* Time separator string. For example: ":".
|
||||
*/
|
||||
UnicodeString fTimeSeparator;
|
||||
|
||||
/**
|
||||
* Quarter strings. For example: "1st quarter", "2nd quarter", etc.
|
||||
*/
|
||||
UnicodeString *fQuarters;
|
||||
int32_t fQuartersCount;
|
||||
|
||||
/**
|
||||
* Short quarters. For example: "Q1", "Q2", etc.
|
||||
*/
|
||||
UnicodeString *fShortQuarters;
|
||||
int32_t fShortQuartersCount;
|
||||
|
||||
/**
|
||||
* Standalone quarter strings. For example: "1st quarter", "2nd quarter", etc.
|
||||
*/
|
||||
UnicodeString *fStandaloneQuarters;
|
||||
int32_t fStandaloneQuartersCount;
|
||||
|
||||
/**
|
||||
* Standalone short quarter strings. For example: "Q1", "Q2", etc.
|
||||
*/
|
||||
UnicodeString *fStandaloneShortQuarters;
|
||||
int32_t fStandaloneShortQuartersCount;
|
||||
|
||||
/**
|
||||
* All leap month patterns, for example "{0}bis".
|
||||
*/
|
||||
UnicodeString *fLeapMonthPatterns;
|
||||
int32_t fLeapMonthPatternsCount;
|
||||
|
||||
/**
|
||||
* Cyclic year names, for example: "jia-zi", "yi-chou", ... "gui-hai";
|
||||
* currently we only have data for format/abbreviated.
|
||||
* For the others, just get from format/abbreviated, ignore set.
|
||||
*/
|
||||
UnicodeString *fShortYearNames;
|
||||
int32_t fShortYearNamesCount;
|
||||
|
||||
/**
|
||||
* Cyclic zodiac names, for example "Rat", "Ox", "Tiger", etc.;
|
||||
* currently we only have data for format/abbreviated.
|
||||
* For the others, just get from format/abbreviated, ignore set.
|
||||
*/
|
||||
UnicodeString *fShortZodiacNames;
|
||||
int32_t fShortZodiacNamesCount;
|
||||
|
||||
/**
|
||||
* Localized names of time zones in this locale. This is a
|
||||
* two-dimensional array of strings of size n by m,
|
||||
* where m is at least 5 and up to 7. Each of the n rows is an
|
||||
* entry containing the localized names for a single TimeZone.
|
||||
*
|
||||
* Each such row contains (with i ranging from 0..n-1):
|
||||
*
|
||||
* zoneStrings[i][0] - time zone ID
|
||||
* example: America/Los_Angeles
|
||||
* zoneStrings[i][1] - long name of zone in standard time
|
||||
* example: Pacific Standard Time
|
||||
* zoneStrings[i][2] - short name of zone in standard time
|
||||
* example: PST
|
||||
* zoneStrings[i][3] - long name of zone in daylight savings time
|
||||
* example: Pacific Daylight Time
|
||||
* zoneStrings[i][4] - short name of zone in daylight savings time
|
||||
* example: PDT
|
||||
* zoneStrings[i][5] - location name of zone
|
||||
* example: United States (Los Angeles)
|
||||
* zoneStrings[i][6] - long generic name of zone
|
||||
* example: Pacific Time
|
||||
* zoneStrings[i][7] - short generic of zone
|
||||
* example: PT
|
||||
*
|
||||
* The zone ID is not localized; it corresponds to the ID
|
||||
* value associated with a system time zone object. All other entries
|
||||
* are localized names. If a zone does not implement daylight savings
|
||||
* time, the daylight savings time names are ignored.
|
||||
*
|
||||
* Note:CLDR 1.5 introduced metazone and its historical mappings.
|
||||
* This simple two-dimensional array is no longer sufficient to represent
|
||||
* localized names and its historic changes. Since ICU 3.8.1, localized
|
||||
* zone names extracted from ICU locale data is stored in a ZoneStringFormat
|
||||
* instance. But we still need to support the old way of customizing
|
||||
* localized zone names, so we keep this field for the purpose.
|
||||
*/
|
||||
UnicodeString **fZoneStrings; // Zone string array set by setZoneStrings
|
||||
UnicodeString **fLocaleZoneStrings; // Zone string array created by the locale
|
||||
int32_t fZoneStringsRowCount;
|
||||
int32_t fZoneStringsColCount;
|
||||
|
||||
Locale fZSFLocale; // Locale used for getting ZoneStringFormat
|
||||
|
||||
/**
|
||||
* Localized date-time pattern characters. For example: use 'u' as 'y'.
|
||||
*/
|
||||
UnicodeString fLocalPatternChars;
|
||||
|
||||
/**
|
||||
* Capitalization transforms. For each usage type, the first array element indicates
|
||||
* whether to titlecase for uiListOrMenu context, the second indicates whether to
|
||||
* titlecase for stand-alone context.
|
||||
*/
|
||||
UBool fCapitalization[kCapContextUsageTypeCount][2];
|
||||
|
||||
private:
|
||||
/** valid/actual locale information
|
||||
* these are always ICU locales, so the length should not be a problem
|
||||
*/
|
||||
char validLocale[ULOC_FULLNAME_CAPACITY];
|
||||
char actualLocale[ULOC_FULLNAME_CAPACITY];
|
||||
|
||||
DateFormatSymbols(); // default constructor not implemented
|
||||
|
||||
/**
|
||||
* Called by the constructors to actually load data from the resources
|
||||
*
|
||||
* @param locale The locale to get symbols for.
|
||||
* @param type Calendar Type (as from Calendar::getType())
|
||||
* @param status Input/output parameter, set to success or
|
||||
* failure code upon return.
|
||||
* @param useLastResortData determine if use last resort data
|
||||
*/
|
||||
void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);
|
||||
|
||||
/**
|
||||
* Copy or alias an array in another object, as appropriate.
|
||||
*
|
||||
* @param dstArray the copy destination array.
|
||||
* @param dstCount fill in with the lenth of 'dstArray'.
|
||||
* @param srcArray the source array to be copied.
|
||||
* @param srcCount the length of items to be copied from the 'srcArray'.
|
||||
*/
|
||||
static void assignArray(UnicodeString*& dstArray,
|
||||
int32_t& dstCount,
|
||||
const UnicodeString* srcArray,
|
||||
int32_t srcCount);
|
||||
|
||||
/**
|
||||
* Return true if the given arrays' contents are equal, or if the arrays are
|
||||
* identical (pointers are equal).
|
||||
*
|
||||
* @param array1 one array to be compared with.
|
||||
* @param array2 another array to be compared with.
|
||||
* @param count the length of items to be copied.
|
||||
* @return true if the given arrays' contents are equal, or if the arrays are
|
||||
* identical (pointers are equal).
|
||||
*/
|
||||
static UBool arrayCompare(const UnicodeString* array1,
|
||||
const UnicodeString* array2,
|
||||
int32_t count);
|
||||
|
||||
/**
|
||||
* Create a copy, in fZoneStrings, of the given zone strings array. The
|
||||
* member variables fZoneStringsRowCount and fZoneStringsColCount should be
|
||||
* set already by the caller.
|
||||
*/
|
||||
void createZoneStrings(const UnicodeString *const * otherStrings);
|
||||
|
||||
/**
|
||||
* Delete all the storage owned by this object.
|
||||
*/
|
||||
void dispose(void);
|
||||
|
||||
/**
|
||||
* Copy all of the other's data to this.
|
||||
* @param other the object to be copied.
|
||||
*/
|
||||
void copyData(const DateFormatSymbols& other);
|
||||
|
||||
/**
|
||||
* Create zone strings array by locale if not yet available
|
||||
*/
|
||||
void initZoneStringsArray(void);
|
||||
|
||||
/**
|
||||
* Delete just the zone strings.
|
||||
*/
|
||||
void disposeZoneStrings(void);
|
||||
|
||||
/**
|
||||
* Returns the date format field index of the pattern character c,
|
||||
* or UDAT_FIELD_COUNT if c is not a pattern character.
|
||||
*/
|
||||
static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);
|
||||
|
||||
/**
|
||||
* Returns TRUE if f (with its pattern character repeated count times) is a numeric field.
|
||||
*/
|
||||
static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);
|
||||
|
||||
/**
|
||||
* Returns TRUE if c (repeated count times) is the pattern character for a numeric field.
|
||||
*/
|
||||
static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);
|
||||
public:
|
||||
#ifndef U_HIDE_INTERNAL_API
|
||||
/**
|
||||
* Gets a DateFormatSymbols by locale.
|
||||
* Unlike the constructors which always use gregorian calendar, this
|
||||
* method uses the calendar in the locale. If the locale contains no
|
||||
* explicit calendar, this method uses the default calendar for that
|
||||
* locale.
|
||||
* @param locale the locale.
|
||||
* @param status error returned here.
|
||||
* @return the new DateFormatSymbols which the caller owns.
|
||||
* @internal For ICU use only.
|
||||
*/
|
||||
static DateFormatSymbols * U_EXPORT2 createForLocale(
|
||||
const Locale &locale, UErrorCode &status);
|
||||
#endif /* U_HIDE_INTERNAL_API */
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // _DTFMTSYM
|
||||
//eof
|
||||
@ -1,158 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008-2009, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*
|
||||
* File DTINTRV.H
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __DTINTRV_H__
|
||||
#define __DTINTRV_H__
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uobject.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Date Interval data type
|
||||
*/
|
||||
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
/**
|
||||
* This class represents a date interval.
|
||||
* It is a pair of UDate representing from UDate 1 to UDate 2.
|
||||
* @stable ICU 4.0
|
||||
**/
|
||||
class U_COMMON_API DateInterval : public UObject {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Construct a DateInterval given a from date and a to date.
|
||||
* @param fromDate The from date in date interval.
|
||||
* @param toDate The to date in date interval.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
DateInterval(UDate fromDate, UDate toDate);
|
||||
|
||||
/**
|
||||
* destructor
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual ~DateInterval();
|
||||
|
||||
/**
|
||||
* Get the from date.
|
||||
* @return the from date in dateInterval.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
UDate getFromDate() const;
|
||||
|
||||
/**
|
||||
* Get the to date.
|
||||
* @return the to date in dateInterval.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
UDate getToDate() const;
|
||||
|
||||
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
DateInterval(const DateInterval& other);
|
||||
|
||||
/**
|
||||
* Default assignment operator
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
DateInterval& operator=(const DateInterval&);
|
||||
|
||||
/**
|
||||
* Equality operator.
|
||||
* @return TRUE if the two DateIntervals are the same
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual UBool operator==(const DateInterval& other) const;
|
||||
|
||||
/**
|
||||
* Non-equality operator
|
||||
* @return TRUE if the two DateIntervals are not the same
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
UBool operator!=(const DateInterval& other) const;
|
||||
|
||||
|
||||
/**
|
||||
* clone this object.
|
||||
* The caller owns the result and should delete it when done.
|
||||
* @return a cloned DateInterval
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual DateInterval* clone() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Default constructor, not implemented.
|
||||
*/
|
||||
DateInterval();
|
||||
|
||||
UDate fromDate;
|
||||
UDate toDate;
|
||||
|
||||
} ;// end class DateInterval
|
||||
|
||||
|
||||
inline UDate
|
||||
DateInterval::getFromDate() const {
|
||||
return fromDate;
|
||||
}
|
||||
|
||||
|
||||
inline UDate
|
||||
DateInterval::getToDate() const {
|
||||
return toDate;
|
||||
}
|
||||
|
||||
|
||||
inline UBool
|
||||
DateInterval::operator!=(const DateInterval& other) const {
|
||||
return ( !operator==(other) );
|
||||
}
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
@ -1,985 +0,0 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2008-2013, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*
|
||||
* File DTITVFMT.H
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __DTITVFMT_H__
|
||||
#define __DTITVFMT_H__
|
||||
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Format and parse date interval in a language-independent manner.
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/ucal.h"
|
||||
#include "unicode/smpdtfmt.h"
|
||||
#include "unicode/dtintrv.h"
|
||||
#include "unicode/dtitvinf.h"
|
||||
#include "unicode/dtptngen.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* DateIntervalFormat is a class for formatting and parsing date
|
||||
* intervals in a language-independent manner.
|
||||
* Only formatting is supported, parsing is not supported.
|
||||
*
|
||||
* <P>
|
||||
* Date interval means from one date to another date,
|
||||
* for example, from "Jan 11, 2008" to "Jan 18, 2008".
|
||||
* We introduced class DateInterval to represent it.
|
||||
* DateInterval is a pair of UDate, which is
|
||||
* the standard milliseconds since 24:00 GMT, Jan 1, 1970.
|
||||
*
|
||||
* <P>
|
||||
* DateIntervalFormat formats a DateInterval into
|
||||
* text as compactly as possible.
|
||||
* For example, the date interval format from "Jan 11, 2008" to "Jan 18,. 2008"
|
||||
* is "Jan 11-18, 2008" for English.
|
||||
* And it parses text into DateInterval,
|
||||
* although initially, parsing is not supported.
|
||||
*
|
||||
* <P>
|
||||
* There is no structural information in date time patterns.
|
||||
* For any punctuations and string literals inside a date time pattern,
|
||||
* we do not know whether it is just a separator, or a prefix, or a suffix.
|
||||
* Without such information, so, it is difficult to generate a sub-pattern
|
||||
* (or super-pattern) by algorithm.
|
||||
* So, formatting a DateInterval is pattern-driven. It is very
|
||||
* similar to formatting in SimpleDateFormat.
|
||||
* We introduce class DateIntervalInfo to save date interval
|
||||
* patterns, similar to date time pattern in SimpleDateFormat.
|
||||
*
|
||||
* <P>
|
||||
* Logically, the interval patterns are mappings
|
||||
* from (skeleton, the_largest_different_calendar_field)
|
||||
* to (date_interval_pattern).
|
||||
*
|
||||
* <P>
|
||||
* A skeleton
|
||||
* <ol>
|
||||
* <li>
|
||||
* only keeps the field pattern letter and ignores all other parts
|
||||
* in a pattern, such as space, punctuations, and string literals.
|
||||
* </li>
|
||||
* <li>
|
||||
* hides the order of fields.
|
||||
* </li>
|
||||
* <li>
|
||||
* might hide a field's pattern letter length.
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
* For those non-digit calendar fields, the pattern letter length is
|
||||
* important, such as MMM, MMMM, and MMMMM; EEE and EEEE,
|
||||
* and the field's pattern letter length is honored.
|
||||
*
|
||||
* For the digit calendar fields, such as M or MM, d or dd, yy or yyyy,
|
||||
* the field pattern length is ignored and the best match, which is defined
|
||||
* in date time patterns, will be returned without honor the field pattern
|
||||
* letter length in skeleton.
|
||||
*
|
||||
* <P>
|
||||
* The calendar fields we support for interval formatting are:
|
||||
* year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute.
|
||||
* Those calendar fields can be defined in the following order:
|
||||
* year > month > date > hour (in day) > minute
|
||||
*
|
||||
* The largest different calendar fields between 2 calendars is the
|
||||
* first different calendar field in above order.
|
||||
*
|
||||
* For example: the largest different calendar fields between "Jan 10, 2007"
|
||||
* and "Feb 20, 2008" is year.
|
||||
*
|
||||
* <P>
|
||||
* For other calendar fields, the compact interval formatting is not
|
||||
* supported. And the interval format will be fall back to fall-back
|
||||
* patterns, which is mostly "{date0} - {date1}".
|
||||
*
|
||||
* <P>
|
||||
* There is a set of pre-defined static skeleton strings.
|
||||
* There are pre-defined interval patterns for those pre-defined skeletons
|
||||
* in locales' resource files.
|
||||
* For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is "yMMMd",
|
||||
* in en_US, if the largest different calendar field between date1 and date2
|
||||
* is "year", the date interval pattern is "MMM d, yyyy - MMM d, yyyy",
|
||||
* such as "Jan 10, 2007 - Jan 10, 2008".
|
||||
* If the largest different calendar field between date1 and date2 is "month",
|
||||
* the date interval pattern is "MMM d - MMM d, yyyy",
|
||||
* such as "Jan 10 - Feb 10, 2007".
|
||||
* If the largest different calendar field between date1 and date2 is "day",
|
||||
* the date interval pattern is "MMM d-d, yyyy", such as "Jan 10-20, 2007".
|
||||
*
|
||||
* For date skeleton, the interval patterns when year, or month, or date is
|
||||
* different are defined in resource files.
|
||||
* For time skeleton, the interval patterns when am/pm, or hour, or minute is
|
||||
* different are defined in resource files.
|
||||
*
|
||||
* <P>
|
||||
* If a skeleton is not found in a locale's DateIntervalInfo, which means
|
||||
* the interval patterns for the skeleton is not defined in resource file,
|
||||
* the interval pattern will falls back to the interval "fallback" pattern
|
||||
* defined in resource file.
|
||||
* If the interval "fallback" pattern is not defined, the default fall-back
|
||||
* is "{date0} - {data1}".
|
||||
*
|
||||
* <P>
|
||||
* For the combination of date and time,
|
||||
* The rule to generate interval patterns are:
|
||||
* <ol>
|
||||
* <li>
|
||||
* when the year, month, or day differs, falls back to fall-back
|
||||
* interval pattern, which mostly is the concatenate the two original
|
||||
* expressions with a separator between,
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 11, 2007 10:10am" is
|
||||
* "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
|
||||
* </li>
|
||||
* <li>
|
||||
* otherwise, present the date followed by the range expression
|
||||
* for the time.
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 10, 2007 11:10am" is "Jan 10, 2007 10:10 am - 11:10am"
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* <P>
|
||||
* If two dates are the same, the interval pattern is the single date pattern.
|
||||
* For example, interval pattern from "Jan 10, 2007" to "Jan 10, 2007" is
|
||||
* "Jan 10, 2007".
|
||||
*
|
||||
* Or if the presenting fields between 2 dates have the exact same values,
|
||||
* the interval pattern is the single date pattern.
|
||||
* For example, if user only requests year and month,
|
||||
* the interval pattern from "Jan 10, 2007" to "Jan 20, 2007" is "Jan 2007".
|
||||
*
|
||||
* <P>
|
||||
* DateIntervalFormat needs the following information for correct
|
||||
* formatting: time zone, calendar type, pattern, date format symbols,
|
||||
* and date interval patterns.
|
||||
* It can be instantiated in 2 ways:
|
||||
* <ol>
|
||||
* <li>
|
||||
* create an instance using default or given locale plus given skeleton.
|
||||
* Users are encouraged to created date interval formatter this way and
|
||||
* to use the pre-defined skeleton macros, such as
|
||||
* UDAT_YEAR_NUM_MONTH, which consists the calendar fields and
|
||||
* the format style.
|
||||
* </li>
|
||||
* <li>
|
||||
* create an instance using default or given locale plus given skeleton
|
||||
* plus a given DateIntervalInfo.
|
||||
* This factory method is for powerful users who want to provide their own
|
||||
* interval patterns.
|
||||
* Locale provides the timezone, calendar, and format symbols information.
|
||||
* Local plus skeleton provides full pattern information.
|
||||
* DateIntervalInfo provides the date interval patterns.
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
* <P>
|
||||
* For the calendar field pattern letter, such as G, y, M, d, a, h, H, m, s etc.
|
||||
* DateIntervalFormat uses the same syntax as that of
|
||||
* DateTime format.
|
||||
*
|
||||
* <P>
|
||||
* Code Sample: general usage
|
||||
* <pre>
|
||||
* \code
|
||||
* // the date interval object which the DateIntervalFormat formats on
|
||||
* // and parses into
|
||||
* DateInterval* dtInterval = new DateInterval(1000*3600*24, 1000*3600*24*2);
|
||||
* UErrorCode status = U_ZERO_ERROR;
|
||||
* DateIntervalFormat* dtIntervalFmt = DateIntervalFormat::createInstance(
|
||||
* UDAT_YEAR_MONTH_DAY,
|
||||
* Locale("en", "GB", ""), status);
|
||||
* UnicodeUnicodeString dateIntervalString;
|
||||
* FieldPosition pos = 0;
|
||||
* // formatting
|
||||
* dtIntervalFmt->format(dtInterval, dateIntervalUnicodeString, pos, status);
|
||||
* delete dtIntervalFmt;
|
||||
* \endcode
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
class U_I18N_API DateIntervalFormat : public Format {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Construct a DateIntervalFormat from skeleton and the default locale.
|
||||
*
|
||||
* This is a convenient override of
|
||||
* createInstance(const UnicodeString& skeleton, const Locale& locale,
|
||||
* UErrorCode&)
|
||||
* with the value of locale as default locale.
|
||||
*
|
||||
* @param skeleton the skeleton on which interval format based.
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @return a date time interval formatter which the caller owns.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
static DateIntervalFormat* U_EXPORT2 createInstance(
|
||||
const UnicodeString& skeleton,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Construct a DateIntervalFormat from skeleton and a given locale.
|
||||
* <P>
|
||||
* In this factory method,
|
||||
* the date interval pattern information is load from resource files.
|
||||
* Users are encouraged to created date interval formatter this way and
|
||||
* to use the pre-defined skeleton macros.
|
||||
*
|
||||
* <P>
|
||||
* There are pre-defined skeletons (defined in udate.h) having predefined
|
||||
* interval patterns in resource files.
|
||||
* Users are encouraged to use those macros.
|
||||
* For example:
|
||||
* DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
|
||||
*
|
||||
* The given Locale provides the interval patterns.
|
||||
* For example, for en_GB, if skeleton is UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY,
|
||||
* which is "yMMMEEEd",
|
||||
* the interval patterns defined in resource file to above skeleton are:
|
||||
* "EEE, d MMM, yyyy - EEE, d MMM, yyyy" for year differs,
|
||||
* "EEE, d MMM - EEE, d MMM, yyyy" for month differs,
|
||||
* "EEE, d - EEE, d MMM, yyyy" for day differs,
|
||||
* @param skeleton the skeleton on which the interval format is based.
|
||||
* @param locale the given locale
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @return a date time interval formatter which the caller owns.
|
||||
* @stable ICU 4.0
|
||||
* <p>
|
||||
* <h4>Sample code</h4>
|
||||
* \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtPreDefined1
|
||||
* \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtPreDefined
|
||||
* <p>
|
||||
*/
|
||||
|
||||
static DateIntervalFormat* U_EXPORT2 createInstance(
|
||||
const UnicodeString& skeleton,
|
||||
const Locale& locale,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Construct a DateIntervalFormat from skeleton
|
||||
* DateIntervalInfo, and default locale.
|
||||
*
|
||||
* This is a convenient override of
|
||||
* createInstance(const UnicodeString& skeleton, const Locale& locale,
|
||||
* const DateIntervalInfo& dtitvinf, UErrorCode&)
|
||||
* with the locale value as default locale.
|
||||
*
|
||||
* @param skeleton the skeleton on which interval format based.
|
||||
* @param dtitvinf the DateIntervalInfo object.
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @return a date time interval formatter which the caller owns.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
static DateIntervalFormat* U_EXPORT2 createInstance(
|
||||
const UnicodeString& skeleton,
|
||||
const DateIntervalInfo& dtitvinf,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Construct a DateIntervalFormat from skeleton
|
||||
* a DateIntervalInfo, and the given locale.
|
||||
*
|
||||
* <P>
|
||||
* In this factory method, user provides its own date interval pattern
|
||||
* information, instead of using those pre-defined data in resource file.
|
||||
* This factory method is for powerful users who want to provide their own
|
||||
* interval patterns.
|
||||
* <P>
|
||||
* There are pre-defined skeletons (defined in udate.h) having predefined
|
||||
* interval patterns in resource files.
|
||||
* Users are encouraged to use those macros.
|
||||
* For example:
|
||||
* DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)
|
||||
*
|
||||
* The DateIntervalInfo provides the interval patterns.
|
||||
* and the DateIntervalInfo ownership remains to the caller.
|
||||
*
|
||||
* User are encouraged to set default interval pattern in DateIntervalInfo
|
||||
* as well, if they want to set other interval patterns ( instead of
|
||||
* reading the interval patterns from resource files).
|
||||
* When the corresponding interval pattern for a largest calendar different
|
||||
* field is not found ( if user not set it ), interval format fallback to
|
||||
* the default interval pattern.
|
||||
* If user does not provide default interval pattern, it fallback to
|
||||
* "{date0} - {date1}"
|
||||
*
|
||||
* @param skeleton the skeleton on which interval format based.
|
||||
* @param locale the given locale
|
||||
* @param dtitvinf the DateIntervalInfo object.
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @return a date time interval formatter which the caller owns.
|
||||
* @stable ICU 4.0
|
||||
* <p>
|
||||
* <h4>Sample code</h4>
|
||||
* \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtPreDefined1
|
||||
* \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtCustomized
|
||||
* <p>
|
||||
*/
|
||||
static DateIntervalFormat* U_EXPORT2 createInstance(
|
||||
const UnicodeString& skeleton,
|
||||
const Locale& locale,
|
||||
const DateIntervalInfo& dtitvinf,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual ~DateIntervalFormat();
|
||||
|
||||
/**
|
||||
* Clone this Format object polymorphically. The caller owns the result and
|
||||
* should delete it when done.
|
||||
* @return A copy of the object.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual Format* clone(void) const;
|
||||
|
||||
/**
|
||||
* Return true if the given Format objects are semantically equal. Objects
|
||||
* of different subclasses are considered unequal.
|
||||
* @param other the object to be compared with.
|
||||
* @return true if the given Format objects are semantically equal.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual UBool operator==(const Format& other) const;
|
||||
|
||||
/**
|
||||
* Return true if the given Format objects are not semantically equal.
|
||||
* Objects of different subclasses are considered unequal.
|
||||
* @param other the object to be compared with.
|
||||
* @return true if the given Format objects are not semantically equal.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
UBool operator!=(const Format& other) const;
|
||||
|
||||
|
||||
using Format::format;
|
||||
|
||||
/**
|
||||
* Format an object to produce a string. This method handles Formattable
|
||||
* objects with a DateInterval type.
|
||||
* If a the Formattable object type is not a DateInterval,
|
||||
* then it returns a failing UErrorCode.
|
||||
*
|
||||
* @param obj The object to format.
|
||||
* Must be a DateInterval.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param fieldPosition On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual UnicodeString& format(const Formattable& obj,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
UErrorCode& status) const ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Format a DateInterval to produce a string.
|
||||
*
|
||||
* @param dtInterval DateInterval to be formatted.
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param fieldPosition On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
UnicodeString& format(const DateInterval* dtInterval,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
UErrorCode& status) const ;
|
||||
|
||||
|
||||
/**
|
||||
* Format 2 Calendars to produce a string.
|
||||
*
|
||||
* Note: "fromCalendar" and "toCalendar" are not const,
|
||||
* since calendar is not const in SimpleDateFormat::format(Calendar&),
|
||||
*
|
||||
* @param fromCalendar calendar set to the from date in date interval
|
||||
* to be formatted into date interval string
|
||||
* @param toCalendar calendar set to the to date in date interval
|
||||
* to be formatted into date interval string
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param fieldPosition On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status Output param filled with success/failure status.
|
||||
* Caller needs to make sure it is SUCCESS
|
||||
* at the function entrance
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
UnicodeString& format(Calendar& fromCalendar,
|
||||
Calendar& toCalendar,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& fieldPosition,
|
||||
UErrorCode& status) const ;
|
||||
|
||||
/**
|
||||
* Date interval parsing is not supported. Please do not use.
|
||||
* <P>
|
||||
* This method should handle parsing of
|
||||
* date time interval strings into Formattable objects with
|
||||
* DateInterval type, which is a pair of UDate.
|
||||
* <P>
|
||||
* Before calling, set parse_pos.index to the offset you want to start
|
||||
* parsing at in the source. After calling, parse_pos.index is the end of
|
||||
* the text you parsed. If error occurs, index is unchanged.
|
||||
* <P>
|
||||
* When parsing, leading whitespace is discarded (with a successful parse),
|
||||
* while trailing whitespace is left as is.
|
||||
* <P>
|
||||
* See Format::parseObject() for more.
|
||||
*
|
||||
* @param source The string to be parsed into an object.
|
||||
* @param result Formattable to be set to the parse result.
|
||||
* If parse fails, return contents are undefined.
|
||||
* @param parse_pos The position to start parsing at. Since no parsing
|
||||
* is supported, upon return this param is unchanged.
|
||||
* @return A newly created Formattable* object, or NULL
|
||||
* on failure. The caller owns this and should
|
||||
* delete it when done.
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
virtual void parseObject(const UnicodeString& source,
|
||||
Formattable& result,
|
||||
ParsePosition& parse_pos) const;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the date time interval patterns.
|
||||
* @return the date time interval patterns associated with
|
||||
* this date interval formatter.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
const DateIntervalInfo* getDateIntervalInfo(void) const;
|
||||
|
||||
|
||||
/**
|
||||
* Set the date time interval patterns.
|
||||
* @param newIntervalPatterns the given interval patterns to copy.
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns,
|
||||
UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the date formatter
|
||||
* @return the date formatter associated with this date interval formatter.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
const DateFormat* getDateFormat(void) const;
|
||||
|
||||
/**
|
||||
* Returns a reference to the TimeZone used by this DateIntervalFormat's calendar.
|
||||
* @return the time zone associated with the calendar of DateIntervalFormat.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual const TimeZone& getTimeZone(void) const;
|
||||
|
||||
/**
|
||||
* Sets the time zone for the calendar used by this DateIntervalFormat object. The
|
||||
* caller no longer owns the TimeZone object and should not delete it after this call.
|
||||
* @param zoneToAdopt the TimeZone to be adopted.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual void adoptTimeZone(TimeZone* zoneToAdopt);
|
||||
|
||||
/**
|
||||
* Sets the time zone for the calendar used by this DateIntervalFormat object.
|
||||
* @param zone the new time zone.
|
||||
* @stable ICU 4.8
|
||||
*/
|
||||
virtual void setTimeZone(const TimeZone& zone);
|
||||
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
DateIntervalFormat(const DateIntervalFormat&);
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
DateIntervalFormat& operator=(const DateIntervalFormat&);
|
||||
|
||||
private:
|
||||
|
||||
/*
|
||||
* This is for ICU internal use only. Please do not use.
|
||||
* Save the interval pattern information.
|
||||
* Interval pattern consists of 2 single date patterns and the separator.
|
||||
* For example, interval pattern "MMM d - MMM d, yyyy" consists
|
||||
* a single date pattern "MMM d", another single date pattern "MMM d, yyyy",
|
||||
* and a separator "-".
|
||||
* The pattern is divided into 2 parts. For above example,
|
||||
* the first part is "MMM d - ", and the second part is "MMM d, yyyy".
|
||||
* Also, the first date appears in an interval pattern could be
|
||||
* the earlier date or the later date.
|
||||
* And such information is saved in the interval pattern as well.
|
||||
*/
|
||||
struct PatternInfo {
|
||||
UnicodeString firstPart;
|
||||
UnicodeString secondPart;
|
||||
/**
|
||||
* Whether the first date in interval pattern is later date or not.
|
||||
* Fallback format set the default ordering.
|
||||
* And for a particular interval pattern, the order can be
|
||||
* overriden by prefixing the interval pattern with "latestFirst:" or
|
||||
* "earliestFirst:"
|
||||
* For example, given 2 date, Jan 10, 2007 to Feb 10, 2007.
|
||||
* if the fallback format is "{0} - {1}",
|
||||
* and the pattern is "d MMM - d MMM yyyy", the interval format is
|
||||
* "10 Jan - 10 Feb, 2007".
|
||||
* If the pattern is "latestFirst:d MMM - d MMM yyyy",
|
||||
* the interval format is "10 Feb - 10 Jan, 2007"
|
||||
*/
|
||||
UBool laterDateFirst;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
DateIntervalFormat();
|
||||
|
||||
/**
|
||||
* Construct a DateIntervalFormat from DateFormat,
|
||||
* a DateIntervalInfo, and skeleton.
|
||||
* DateFormat provides the timezone, calendar,
|
||||
* full pattern, and date format symbols information.
|
||||
* It should be a SimpleDateFormat object which
|
||||
* has a pattern in it.
|
||||
* the DateIntervalInfo provides the interval patterns.
|
||||
*
|
||||
* Note: the DateIntervalFormat takes ownership of both
|
||||
* DateFormat and DateIntervalInfo objects.
|
||||
* Caller should not delete them.
|
||||
*
|
||||
* @param locale the locale of this date interval formatter.
|
||||
* @param dtItvInfo the DateIntervalInfo object to be adopted.
|
||||
* @param skeleton the skeleton of the date formatter
|
||||
* @param status output param set to success/failure code on exit
|
||||
*/
|
||||
DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo,
|
||||
const UnicodeString* skeleton, UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Construct a DateIntervalFormat from DateFormat
|
||||
* and a DateIntervalInfo.
|
||||
*
|
||||
* It is a wrapper of the constructor.
|
||||
*
|
||||
* @param locale the locale of this date interval formatter.
|
||||
* @param dtitvinf the DateIntervalInfo object to be adopted.
|
||||
* @param skeleton the skeleton of this formatter.
|
||||
* @param status Output param set to success/failure code.
|
||||
* @return a date time interval formatter which the caller owns.
|
||||
*/
|
||||
static DateIntervalFormat* U_EXPORT2 create(const Locale& locale,
|
||||
DateIntervalInfo* dtitvinf,
|
||||
const UnicodeString* skeleton,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Create a simple date/time formatter from skeleton, given locale,
|
||||
* and date time pattern generator.
|
||||
*
|
||||
* @param skeleton the skeleton on which date format based.
|
||||
* @param locale the given locale.
|
||||
* @param dtpng the date time pattern generator.
|
||||
* @param status Output param to be set to success/failure code.
|
||||
* If it is failure, the returned date formatter will
|
||||
* be NULL.
|
||||
* @return a simple date formatter which the caller owns.
|
||||
*/
|
||||
static SimpleDateFormat* U_EXPORT2 createSDFPatternInstance(
|
||||
const UnicodeString& skeleton,
|
||||
const Locale& locale,
|
||||
DateTimePatternGenerator* dtpng,
|
||||
UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Below are for generating interval patterns local to the formatter
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Format 2 Calendars using fall-back interval pattern
|
||||
*
|
||||
* The full pattern used in this fall-back format is the
|
||||
* full pattern of the date formatter.
|
||||
*
|
||||
* @param fromCalendar calendar set to the from date in date interval
|
||||
* to be formatted into date interval string
|
||||
* @param toCalendar calendar set to the to date in date interval
|
||||
* to be formatted into date interval string
|
||||
* @param appendTo Output parameter to receive result.
|
||||
* Result is appended to existing contents.
|
||||
* @param pos On input: an alignment field, if desired.
|
||||
* On output: the offsets of the alignment field.
|
||||
* @param status output param set to success/failure code on exit
|
||||
* @return Reference to 'appendTo' parameter.
|
||||
*/
|
||||
UnicodeString& fallbackFormat(Calendar& fromCalendar,
|
||||
Calendar& toCalendar,
|
||||
UnicodeString& appendTo,
|
||||
FieldPosition& pos,
|
||||
UErrorCode& status) const;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize interval patterns locale to this formatter
|
||||
*
|
||||
* This code is a bit complicated since
|
||||
* 1. the interval patterns saved in resource bundle files are interval
|
||||
* patterns based on date or time only.
|
||||
* It does not have interval patterns based on both date and time.
|
||||
* Interval patterns on both date and time are algorithm generated.
|
||||
*
|
||||
* For example, it has interval patterns on skeleton "dMy" and "hm",
|
||||
* but it does not have interval patterns on skeleton "dMyhm".
|
||||
*
|
||||
* The rule to generate interval patterns for both date and time skeleton are
|
||||
* 1) when the year, month, or day differs, concatenate the two original
|
||||
* expressions with a separator between,
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 11, 2007 10:10am" is
|
||||
* "Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am"
|
||||
*
|
||||
* 2) otherwise, present the date followed by the range expression
|
||||
* for the time.
|
||||
* For example, interval pattern from "Jan 10, 2007 10:10 am"
|
||||
* to "Jan 10, 2007 11:10am" is
|
||||
* "Jan 10, 2007 10:10 am - 11:10am"
|
||||
*
|
||||
* 2. even a pattern does not request a certain calendar field,
|
||||
* the interval pattern needs to include such field if such fields are
|
||||
* different between 2 dates.
|
||||
* For example, a pattern/skeleton is "hm", but the interval pattern
|
||||
* includes year, month, and date when year, month, and date differs.
|
||||
*
|
||||
*
|
||||
* @param status output param set to success/failure code on exit
|
||||
*/
|
||||
void initializePattern(UErrorCode& status);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set fall back interval pattern given a calendar field,
|
||||
* a skeleton, and a date time pattern generator.
|
||||
* @param field the largest different calendar field
|
||||
* @param skeleton a skeleton
|
||||
* @param status output param set to success/failure code on exit
|
||||
*/
|
||||
void setFallbackPattern(UCalendarDateFields field,
|
||||
const UnicodeString& skeleton,
|
||||
UErrorCode& status);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* get separated date and time skeleton from a combined skeleton.
|
||||
*
|
||||
* The difference between date skeleton and normalizedDateSkeleton are:
|
||||
* 1. both 'y' and 'd' are appeared only once in normalizeDateSkeleton
|
||||
* 2. 'E' and 'EE' are normalized into 'EEE'
|
||||
* 3. 'MM' is normalized into 'M'
|
||||
*
|
||||
** the difference between time skeleton and normalizedTimeSkeleton are:
|
||||
* 1. both 'H' and 'h' are normalized as 'h' in normalized time skeleton,
|
||||
* 2. 'a' is omitted in normalized time skeleton.
|
||||
* 3. there is only one appearance for 'h', 'm','v', 'z' in normalized time
|
||||
* skeleton
|
||||
*
|
||||
*
|
||||
* @param skeleton given combined skeleton.
|
||||
* @param date Output parameter for date only skeleton.
|
||||
* @param normalizedDate Output parameter for normalized date only
|
||||
*
|
||||
* @param time Output parameter for time only skeleton.
|
||||
* @param normalizedTime Output parameter for normalized time only
|
||||
* skeleton.
|
||||
*
|
||||
*/
|
||||
static void U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,
|
||||
UnicodeString& date,
|
||||
UnicodeString& normalizedDate,
|
||||
UnicodeString& time,
|
||||
UnicodeString& normalizedTime);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate date or time interval pattern from resource,
|
||||
* and set them into the interval pattern locale to this formatter.
|
||||
*
|
||||
* It needs to handle the following:
|
||||
* 1. need to adjust field width.
|
||||
* For example, the interval patterns saved in DateIntervalInfo
|
||||
* includes "dMMMy", but not "dMMMMy".
|
||||
* Need to get interval patterns for dMMMMy from dMMMy.
|
||||
* Another example, the interval patterns saved in DateIntervalInfo
|
||||
* includes "hmv", but not "hmz".
|
||||
* Need to get interval patterns for "hmz' from 'hmv'
|
||||
*
|
||||
* 2. there might be no pattern for 'y' differ for skeleton "Md",
|
||||
* in order to get interval patterns for 'y' differ,
|
||||
* need to look for it from skeleton 'yMd'
|
||||
*
|
||||
* @param dateSkeleton normalized date skeleton
|
||||
* @param timeSkeleton normalized time skeleton
|
||||
* @return whether the resource is found for the skeleton.
|
||||
* TRUE if interval pattern found for the skeleton,
|
||||
* FALSE otherwise.
|
||||
*/
|
||||
UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
|
||||
const UnicodeString& timeSkeleton);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate interval pattern from existing resource
|
||||
*
|
||||
* It not only save the interval patterns,
|
||||
* but also return the extended skeleton and its best match skeleton.
|
||||
*
|
||||
* @param field largest different calendar field
|
||||
* @param skeleton skeleton
|
||||
* @param bestSkeleton the best match skeleton which has interval pattern
|
||||
* defined in resource
|
||||
* @param differenceInfo the difference between skeleton and best skeleton
|
||||
* 0 means the best matched skeleton is the same as input skeleton
|
||||
* 1 means the fields are the same, but field width are different
|
||||
* 2 means the only difference between fields are v/z,
|
||||
* -1 means there are other fields difference
|
||||
*
|
||||
* @param extendedSkeleton extended skeleton
|
||||
* @param extendedBestSkeleton extended best match skeleton
|
||||
* @return whether the interval pattern is found
|
||||
* through extending skeleton or not.
|
||||
* TRUE if interval pattern is found by
|
||||
* extending skeleton, FALSE otherwise.
|
||||
*/
|
||||
UBool setIntervalPattern(UCalendarDateFields field,
|
||||
const UnicodeString* skeleton,
|
||||
const UnicodeString* bestSkeleton,
|
||||
int8_t differenceInfo,
|
||||
UnicodeString* extendedSkeleton = NULL,
|
||||
UnicodeString* extendedBestSkeleton = NULL);
|
||||
|
||||
/**
|
||||
* Adjust field width in best match interval pattern to match
|
||||
* the field width in input skeleton.
|
||||
*
|
||||
* TODO (xji) make a general solution
|
||||
* The adjusting rule can be:
|
||||
* 1. always adjust
|
||||
* 2. never adjust
|
||||
* 3. default adjust, which means adjust according to the following rules
|
||||
* 3.1 always adjust string, such as MMM and MMMM
|
||||
* 3.2 never adjust between string and numeric, such as MM and MMM
|
||||
* 3.3 always adjust year
|
||||
* 3.4 do not adjust 'd', 'h', or 'm' if h presents
|
||||
* 3.5 do not adjust 'M' if it is numeric(?)
|
||||
*
|
||||
* Since date interval format is well-formed format,
|
||||
* date and time skeletons are normalized previously,
|
||||
* till this stage, the adjust here is only "adjust strings, such as MMM
|
||||
* and MMMM, EEE and EEEE.
|
||||
*
|
||||
* @param inputSkeleton the input skeleton
|
||||
* @param bestMatchSkeleton the best match skeleton
|
||||
* @param bestMatchIntervalPattern the best match interval pattern
|
||||
* @param differenceInfo the difference between 2 skeletons
|
||||
* 1 means only field width differs
|
||||
* 2 means v/z exchange
|
||||
* @param adjustedIntervalPattern adjusted interval pattern
|
||||
*/
|
||||
static void U_EXPORT2 adjustFieldWidth(
|
||||
const UnicodeString& inputSkeleton,
|
||||
const UnicodeString& bestMatchSkeleton,
|
||||
const UnicodeString& bestMatchIntervalPattern,
|
||||
int8_t differenceInfo,
|
||||
UnicodeString& adjustedIntervalPattern);
|
||||
|
||||
/**
|
||||
* Concat a single date pattern with a time interval pattern,
|
||||
* set it into the intervalPatterns, while field is time field.
|
||||
* This is used to handle time interval patterns on skeleton with
|
||||
* both time and date. Present the date followed by
|
||||
* the range expression for the time.
|
||||
* @param format date and time format
|
||||
* @param formatLen format string length
|
||||
* @param datePattern date pattern
|
||||
* @param field time calendar field: AM_PM, HOUR, MINUTE
|
||||
* @param status output param set to success/failure code on exit
|
||||
*/
|
||||
void concatSingleDate2TimeInterval(const UChar* format,
|
||||
int32_t formatLen,
|
||||
const UnicodeString& datePattern,
|
||||
UCalendarDateFields field,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* check whether a calendar field present in a skeleton.
|
||||
* @param field calendar field need to check
|
||||
* @param skeleton given skeleton on which to check the calendar field
|
||||
* @return true if field present in a skeleton.
|
||||
*/
|
||||
static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,
|
||||
const UnicodeString& skeleton);
|
||||
|
||||
|
||||
/**
|
||||
* Split interval patterns into 2 part.
|
||||
* @param intervalPattern interval pattern
|
||||
* @return the index in interval pattern which split the pattern into 2 part
|
||||
*/
|
||||
static int32_t U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern);
|
||||
|
||||
|
||||
/**
|
||||
* Break interval patterns as 2 part and save them into pattern info.
|
||||
* @param field calendar field
|
||||
* @param intervalPattern interval pattern
|
||||
*/
|
||||
void setIntervalPattern(UCalendarDateFields field,
|
||||
const UnicodeString& intervalPattern);
|
||||
|
||||
|
||||
/**
|
||||
* Break interval patterns as 2 part and save them into pattern info.
|
||||
* @param field calendar field
|
||||
* @param intervalPattern interval pattern
|
||||
* @param laterDateFirst whether later date appear first in interval pattern
|
||||
*/
|
||||
void setIntervalPattern(UCalendarDateFields field,
|
||||
const UnicodeString& intervalPattern,
|
||||
UBool laterDateFirst);
|
||||
|
||||
|
||||
/**
|
||||
* Set pattern information.
|
||||
*
|
||||
* @param field calendar field
|
||||
* @param firstPart the first part in interval pattern
|
||||
* @param secondPart the second part in interval pattern
|
||||
* @param laterDateFirst whether the first date in intervalPattern
|
||||
* is earlier date or later date
|
||||
*/
|
||||
void setPatternInfo(UCalendarDateFields field,
|
||||
const UnicodeString* firstPart,
|
||||
const UnicodeString* secondPart,
|
||||
UBool laterDateFirst);
|
||||
|
||||
|
||||
// from calendar field to pattern letter
|
||||
static const UChar fgCalendarFieldToPatternLetter[];
|
||||
|
||||
|
||||
/**
|
||||
* The interval patterns for this locale.
|
||||
*/
|
||||
DateIntervalInfo* fInfo;
|
||||
|
||||
/**
|
||||
* The DateFormat object used to format single pattern
|
||||
*/
|
||||
SimpleDateFormat* fDateFormat;
|
||||
|
||||
/**
|
||||
* The 2 calendars with the from and to date.
|
||||
* could re-use the calendar in fDateFormat,
|
||||
* but keeping 2 calendars make it clear and clean.
|
||||
*/
|
||||
Calendar* fFromCalendar;
|
||||
Calendar* fToCalendar;
|
||||
|
||||
/**
|
||||
* Date time pattern generator
|
||||
*/
|
||||
DateTimePatternGenerator* fDtpng;
|
||||
|
||||
/**
|
||||
* Following are interval information relavent (locale) to this formatter.
|
||||
*/
|
||||
UnicodeString fSkeleton;
|
||||
PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];
|
||||
};
|
||||
|
||||
inline UBool
|
||||
DateIntervalFormat::operator!=(const Format& other) const {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // _DTITVFMT_H__
|
||||
//eof
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user