|
|
|||
File indexing completed on 2026-09-28 09:19:50
0001 // Copyright (c) 2025 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _DE_ValidationUtils_HeaderFile 0015 #define _DE_ValidationUtils_HeaderFile 0016 0017 #include <TCollection_AsciiString.hxx> 0018 #include <DE_ConfigurationNode.hxx> 0019 #include <DE_Provider.hxx> 0020 0021 class TDocStd_Document; 0022 0023 //! Utility class providing static methods for common validation operations 0024 //! used across DataExchange providers. Includes validation for configuration nodes, 0025 //! file paths, streams, and other common scenarios with optional verbose error reporting. 0026 class DE_ValidationUtils 0027 { 0028 public: 0029 //! Validates that configuration node is not null and matches expected type 0030 //! @param[in] theNode configuration node to validate 0031 //! @param[in] theExpectedType expected RTTI type 0032 //! @param[in] theContext context string for error messages 0033 //! @param[in] theIsVerbose if true, sends detailed error messages via Message::SendFail 0034 //! @return true if node is valid, false otherwise 0035 Standard_EXPORT static bool ValidateConfigurationNode( 0036 const occ::handle<DE_ConfigurationNode>& theNode, 0037 const occ::handle<Standard_Type>& theExpectedType, 0038 const TCollection_AsciiString& theContext, 0039 const bool theIsVerbose = true); 0040 0041 //! Checks if file exists and is readable 0042 //! @param[in] thePath file path to check 0043 //! @param[in] theContext context string for error messages 0044 //! @param[in] theIsVerbose if true, sends detailed error messages via Message::SendFail 0045 //! @return true if file exists and is readable, false otherwise 0046 Standard_EXPORT static bool ValidateFileForReading(const TCollection_AsciiString& thePath, 0047 const TCollection_AsciiString& theContext, 0048 const bool theIsVerbose = true); 0049 0050 //! Checks if file location is writable (file may or may not exist) 0051 //! @param[in] thePath file path to check 0052 //! @param[in] theContext context string for error messages 0053 //! @param[in] theIsVerbose if true, sends detailed error messages via Message::SendFail 0054 //! @return true if location is writable, false otherwise 0055 Standard_EXPORT static bool ValidateFileForWriting(const TCollection_AsciiString& thePath, 0056 const TCollection_AsciiString& theContext, 0057 const bool theIsVerbose = true); 0058 0059 //! Validates read stream list, warns if multiple streams 0060 //! @param[in] theStreams read stream list to validate 0061 //! @param[in] theContext context string for error messages 0062 //! @param[in] theIsVerbose if true, sends detailed error/warning messages 0063 //! @return true if stream list is valid, false otherwise 0064 Standard_EXPORT static bool ValidateReadStreamList(const DE_Provider::ReadStreamList& theStreams, 0065 const TCollection_AsciiString& theContext, 0066 const bool theIsVerbose = true); 0067 0068 //! Validates write stream list, warns if multiple streams 0069 //! @param[in] theStreams write stream list to validate 0070 //! @param[in] theContext context string for error messages 0071 //! @param[in] theIsVerbose if true, sends detailed error/warning messages 0072 //! @return true if stream list is valid, false otherwise 0073 Standard_EXPORT static bool ValidateWriteStreamList(DE_Provider::WriteStreamList& theStreams, 0074 const TCollection_AsciiString& theContext, 0075 const bool theIsVerbose = true); 0076 0077 //! Validates that TDocStd_Document handle is not null 0078 //! @param[in] theDocument document to validate 0079 //! @param[in] theContext context string for error messages 0080 //! @param[in] theIsVerbose if true, sends detailed error messages via Message::SendFail 0081 //! @return true if document is not null, false otherwise 0082 Standard_EXPORT static bool ValidateDocument(const occ::handle<TDocStd_Document>& theDocument, 0083 const TCollection_AsciiString& theContext, 0084 const bool theIsVerbose = true); 0085 0086 //! Sends warning when format doesn't support length unit scaling 0087 //! @param[in] theLengthUnit length unit value to check 0088 //! @param[in] theContext context string for warning messages 0089 //! @param[in] theIsVerbose if true, sends warning messages via Message::SendWarning 0090 //! @return true always (this is just a warning) 0091 Standard_EXPORT static bool WarnLengthUnitNotSupported(const double theLengthUnit, 0092 const TCollection_AsciiString& theContext, 0093 const bool theIsVerbose = true); 0094 0095 //! Creates buffer by reading from file stream for content checking 0096 //! @param[in] thePath file path for reading 0097 //! @param[out] theBuffer output buffer with file content 0098 //! @return true if successful, false otherwise 0099 Standard_EXPORT static bool CreateContentBuffer(const TCollection_AsciiString& thePath, 0100 occ::handle<NCollection_Buffer>& theBuffer); 0101 0102 //! Creates buffer by reading from input stream for content checking 0103 //! @param[in,out] theStream input stream to read from (position will be restored) 0104 //! @param[out] theBuffer output buffer with stream content 0105 //! @return true if successful, false otherwise 0106 Standard_EXPORT static bool CreateContentBuffer(std::istream& theStream, 0107 occ::handle<NCollection_Buffer>& theBuffer); 0108 }; 0109 0110 #endif // _DE_ValidationUtils_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|