LCOV - code coverage report
Current view: top level - include/osl - pipe_decl.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_OSL_PIPE_DECL_HXX
      20             : #define INCLUDED_OSL_PIPE_DECL_HXX
      21             : 
      22             : #include <osl/pipe.h>
      23             : #   include <osl/security.hxx>
      24             : #include <rtl/ustring.hxx>
      25             : 
      26             : namespace osl {
      27             : 
      28             : class StreamPipe;
      29             : 
      30             : /** Represents a pipe.
      31             : */
      32             : class Pipe
      33             : {
      34             : protected:
      35             :     oslPipe m_handle;
      36             : 
      37             : public:
      38             : 
      39             :     /** Does not create a pipe. Use assignment operator to
      40             :         make this a useable pipe.
      41             :     */
      42             :     inline Pipe();
      43             : 
      44             :     /** Creates an insecure pipe that is accessible for all users.
      45             :         @param strName
      46             :         @param Options
      47             :     */
      48             :     inline Pipe(const ::rtl::OUString& strName, oslPipeOptions Options);
      49             : 
      50             :     /** Creates a secure pipe that access depends on the umask settings.
      51             :         @param strName
      52             :         @param Options
      53             :         @param rSecurity
      54             :     */
      55             :     inline Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity);
      56             : 
      57             :     /** Copy constructor.
      58             :     */
      59             :     inline Pipe(const Pipe& pipe);
      60             : 
      61             :     /** Constructs a Pipe reference without acquiring the handle
      62             :     */
      63             :     inline Pipe( oslPipe pipe, __sal_NoAcquire noacquire );
      64             : 
      65             :     /** Creates pipe as wrapper around the underlying oslPipe.
      66             :         @param Pipe
      67             :     */
      68             :     inline Pipe(oslPipe Pipe);
      69             : 
      70             :     /** Destructor. Destroys the underlying oslPipe.
      71             :     */
      72             :     inline ~Pipe();
      73             : 
      74             :     inline bool SAL_CALL is() const;
      75             : 
      76             :     /** Creates an insecure pipe that is accessible for all users
      77             :         with the given attributes.
      78             :         If the pipe was already created, the old one will be discarded.
      79             :         @param strName
      80             :         @param Options
      81             :         @param rSec
      82             :         @return True if socket was successfully created.
      83             :     */
      84             :     inline bool create( const ::rtl::OUString & strName,
      85             :                             oslPipeOptions Options, const Security &rSec );
      86             : 
      87             :     /** Creates a secure that access rights depend on the umask settings
      88             :         with the given attributes.
      89             : 
      90             :         If socket was already created, the old one will be discarded.
      91             :         @param strName
      92             :         @param Options
      93             :         @return True if socket was successfully created.
      94             :     */
      95             :     inline bool create( const ::rtl::OUString & strName, oslPipeOptions Options = osl_Pipe_OPEN );
      96             : 
      97             :     /** releases the underlying handle
      98             :      */
      99             :     inline void SAL_CALL clear();
     100             : 
     101             :     /** Assignment operator. If pipe was already created, the old one will
     102             :         be discarded.
     103             :     */
     104             :     inline Pipe& SAL_CALL operator= (const Pipe& pipe);
     105             : 
     106             :     /** Assignment operator. If pipe was already created, the old one will
     107             :         be discarded.
     108             :     */
     109             :     inline Pipe& SAL_CALL operator= (const oslPipe pipe );
     110             : 
     111             :     /** Checks if the pipe is valid.
     112             :         @return True if the object represents a valid pipe.
     113             :     */
     114             :     inline bool SAL_CALL isValid() const;
     115             : 
     116             :     inline bool SAL_CALL operator==( const Pipe& rPipe ) const;
     117             : 
     118             :     /** Closes the pipe.
     119             :     */
     120             :     inline void SAL_CALL close();
     121             : 
     122             :     /** Accept connection on an existing pipe
     123             :     */
     124             :     inline oslPipeError SAL_CALL accept(StreamPipe& Connection);
     125             : 
     126             : 
     127             :     /** Delivers a constant describing the last error for the pipe system.
     128             :         @return ENONE if no error occurred, invalid_PipeError if
     129             :         an unknown (unmapped) error occurred, otherwise an enum describing the
     130             :         error.
     131             :     */
     132             :     inline oslPipeError SAL_CALL getError() const;
     133             : 
     134             :     inline oslPipe SAL_CALL getHandle() const;
     135             : };
     136             : 
     137             : /** A pipe to send or receive a stream of data.
     138             : */
     139         732 : class StreamPipe : public Pipe
     140             : {
     141             : public:
     142             : 
     143             :     /** Creates an unattached pipe. You must attach the pipe to an oslPipe
     144             :         e.g. by using the operator=(oslPipe), before you can use the stream-
     145             :         functionality of the object.
     146             :     */
     147             :     inline StreamPipe();
     148             : 
     149             :     /** Creates pipe as wrapper around the underlying oslPipe.
     150             :         @param Pipe
     151             :     */
     152             :     inline StreamPipe(oslPipe Pipe);
     153             : 
     154             :     /** Copy constructor.
     155             :         @param Pipe
     156             :     */
     157             :     inline StreamPipe(const StreamPipe& Pipe);
     158             : 
     159             :     /** Creates a pipe.
     160             :         @param strName
     161             :         @param Options
     162             :     */
     163             :     inline StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options = osl_Pipe_OPEN);
     164             : 
     165             :     /** Creates a pipe.
     166             :         @param strName
     167             :         @param Options
     168             :         @param rSec
     169             :     */
     170             :     inline StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec );
     171             : 
     172             :     /** Constructs a Pipe reference without acquiring the handle
     173             :     */
     174             :     inline StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire );
     175             : 
     176             :     /** Attaches the oslPipe to this object. If the object
     177             :         already was attached to an oslPipe, the old one will
     178             :         be closed and destroyed.
     179             :         @param Pipe
     180             :     */
     181             :     inline StreamPipe & SAL_CALL operator=(oslPipe Pipe);
     182             : 
     183             :     /** Assignment operator
     184             :     */
     185             :     inline StreamPipe& SAL_CALL operator=(const Pipe& pipe);
     186             : 
     187             :     /** Tries to receives BytesToRead data from the connected pipe,
     188             : 
     189             :         @param pBuffer [out] Points to a buffer that will be filled with the received
     190             :         data.
     191             :         @param BytesToRead [in] The number of bytes to read. pBuffer must have at least
     192             :         this size.
     193             :         @return the number of received bytes.
     194             :     */
     195             :     inline sal_Int32 SAL_CALL recv(void* pBuffer, sal_Int32 BytesToRead) const;
     196             : 
     197             :     /** Tries to sends BytesToSend data from the connected pipe.
     198             : 
     199             :         @param pBuffer [in] Points to a buffer that contains the send-data.
     200             :         @param BytesToSend [in] The number of bytes to send. pBuffer must have at least
     201             :         this size.
     202             :         @return the number of transferred bytes.
     203             :     */
     204             :     inline sal_Int32 SAL_CALL send(const void* pBuffer, sal_Int32 BytesToSend) const;
     205             : 
     206             :     /** Retrieves n bytes from the stream and copies them into pBuffer.
     207             :         The method avoids incomplete reads due to packet boundaries.
     208             :         @param pBuffer receives the read data.
     209             :         @param n the number of bytes to read. pBuffer must be large enough
     210             :         to hold the n bytes!
     211             :         @return the number of read bytes. The number will only be smaller than
     212             :         n if an exceptional condition (e.g. connection closed) occurs.
     213             :     */
     214             :     inline sal_Int32 SAL_CALL read(void* pBuffer, sal_Int32 n) const;
     215             : 
     216             :     /** Writes n bytes from pBuffer to the stream. The method avoids
     217             :         incomplete writes due to packet boundaries.
     218             :         @param pBuffer contains the data to be written.
     219             :         @param n the number of bytes to write.
     220             :         @return the number of written bytes. The number will only be smaller than
     221             :         n if an exceptional condition (e.g. connection closed) occurs.
     222             :     */
     223             :     sal_Int32 SAL_CALL write(const void* pBuffer, sal_Int32 n) const;
     224             : };
     225             : 
     226             : }
     227             : #endif
     228             : 
     229             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11