Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/l10ntools/inc/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 4 kB image not shown  

Quelle  po.hxx   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */


#ifndef INCLUDED_L10NTOOLS_INC_PO_HXX
#define INCLUDED_L10NTOOLS_INC_PO_HXX

#include <fstream>
#include <memory>
#include <string_view>

#include <rtl/string.hxx>

class GenPoEntry;


/** Interface to use po entries in localization

    PoEntry based on GenPoEntry class which stores attributes
    of general po entry(see po.cxx). It makes easy to get/set
    all information needed to localize one english(US) string.
    It contains some basic checkings and some string
    transformations between po string and string used by
    localization tools.
*/

class PoEntry
{
private:

    std::unique_ptr<GenPoEntry> m_pGenPo;
    bool m_bIsInitialized;

public:

    friend class PoOfstream;
    friend class PoIfstream;

    enum TYPE { TTEXT, TQUICKHELPTEXT, TTITLE };
    enum Exception { NOSOURCFILE, NORESTYPE, NOGROUPID, NOSTRING, WRONGHELPTEXT };

                    PoEntry();
                    PoEntry( std::string_view rSourceFile, std::string_view rResType, std::string_view rGroupId,
                             std::string_view rLocalId, std::string_view rHelpText, const OString& rText,
                             const TYPE eType );
                    ~PoEntry();

                    PoEntry( const PoEntry& rPo );
    PoEntry&        operator=( const PoEntry& rPo );
    PoEntry&        operator=( PoEntry&& rPo ) noexcept;

    OString const &  getSourceFile() const;      ///< Get name of file from which entry is extracted
    OString         getGroupId() const;
    OString         getLocalId() const;
    OString         getResourceType() const;    ///< Get the type of component from which entry is extracted
    TYPE            getType() const;            ///< Get the type of entry
    OString const & getMsgCtxt() const;
    OString const & getMsgId() const;
    OString const & getMsgStr() const;
    bool            isFuzzy() const;

    /// Check whether po-s belong to the same localization component
    static bool     IsInSameComp(const PoEntry& rPo1,const PoEntry& rPo2);
    static OString  genKeyId(const OString& rGenerator);

};

/** Interface to work with header of po/pot files

    This class stores information which is in header of
    a po file. It's main function to generate header to
    template po files(pot).
*/

class PoHeader
{
private:

    std::unique_ptr<GenPoEntry> m_pGenPo;
    bool m_bIsInitialized;

public:

    friend class PoOfstream;
    friend class PoIfstream;

                    PoHeader( std::string_view rExtSrc ); ///< Template Constructor
                    PoHeader( std::string_view rExtSrc, const OString& rPoHeaderMsgStr );
                    ~PoHeader();
                    PoHeader(const PoHeader&) = delete;
    PoHeader&       operator=(const PoHeader&) = delete;
};

/// Interface to write po entry to files as output streams
class PoOfstream
{
private:

    std::ofstream   m_aOutPut;
    bool            m_bIsAfterHeader;

public:

    enum OpenMode { TRUNC, APP };

            PoOfstream();
            PoOfstream(const OString& rFileName, OpenMode aMode );
            ~PoOfstream();
            PoOfstream(const PoOfstream&) = delete;
    PoOfstream& operator=(const PoOfstream&) = delete;
    bool    isOpen() const  { return m_aOutPut.is_open(); }

    void    open(const OString& rFileName, OpenMode aMode = TRUNC );
    void    close();
    void    writeHeader(const PoHeader& rHeader);
    void    writeEntry(const PoEntry& rPo);
};

/// Interface to read po entry from files as input streams
class PoIfstream
{
private:

    std::ifstream   m_aInPut;
    bool            m_bEof;

public:

    class Exception final : public std::exception { };

            PoIfstream();
            PoIfstream( const OString& rFileName );
            ~PoIfstream();
            PoIfstream(const PoIfstream&) = delete;
    PoIfstream& operator=(const PoIfstream&) = delete;
    bool    isOpen() const  { return m_aInPut.is_open(); }
    bool    eof() const     { return m_bEof; }

    void    open(const OString& rFileName);
    void    open(const OString& rFileName, OString& sPoHeader);
    void    close();
    void    readEntry(PoEntry& rPo);
};

#endif // INCLUDED_L10NTOOLS_INC_PO_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Messung V0.5
C=91 H=93 G=91

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.