Coverage Report

Created: 2025-08-25 06:16

/src/alembic/lib/Alembic/AbcMaterial/InternalUtil.cpp
Line
Count
Source (jump to first uncovered line)
1
//-*****************************************************************************
2
//
3
// Copyright (c) 2009-2012,
4
//  Sony Pictures Imageworks Inc. and
5
//  Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6
//
7
// All rights reserved.
8
//
9
// Redistribution and use in source and binary forms, with or without
10
// modification, are permitted provided that the following conditions are
11
// met:
12
// *       Redistributions of source code must retain the above copyright
13
// notice, this list of conditions and the following disclaimer.
14
// *       Redistributions in binary form must reproduce the above
15
// copyright notice, this list of conditions and the following disclaimer
16
// in the documentation and/or other materials provided with the
17
// distribution.
18
// *       Neither the name of Sony Pictures Imageworks, nor
19
// Industrial Light & Magic, nor the names of their contributors may be used
20
// to endorse or promote products derived from this software without specific
21
// prior written permission.
22
//
23
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
//
35
//-*****************************************************************************
36
37
#include "InternalUtil.h"
38
39
#include <Alembic/Util/All.h>
40
41
#include <sstream>
42
43
namespace Alembic {
44
namespace AbcMaterial {
45
namespace ALEMBIC_VERSION_NS {
46
namespace Util {
47
48
std::string
49
buildTargetName( const std::string & iTarget,
50
                 const std::string & iShaderType,
51
                 const std::string & iSuffix )
52
0
{
53
0
    std::string name = iTarget;
54
0
    name += ".";
55
0
    name += iShaderType;
56
57
0
    if (!iSuffix.empty())
58
0
    {
59
0
        name += "." + iSuffix;
60
0
    }
61
62
0
    return name;
63
0
}
64
65
66
void validateName( const std::string & iName,
67
                   const std::string & iExceptionVariableName )
68
0
{
69
0
    if ( iName.find('.') != std::string::npos ||
70
0
         iName.find('/') != std::string::npos )
71
0
    {
72
0
        ABC_THROW( "invalid name for " << iExceptionVariableName <<
73
0
                   ":" << iName );
74
0
    }
75
0
}
76
77
78
void split_tokens( const std::string & iValue,
79
                   std::vector<std::string> & oResult,
80
                   size_t iMaxSplit )
81
0
{
82
0
    oResult.clear();
83
84
0
    if ( iValue.empty() )
85
0
    {
86
0
        oResult.push_back("");
87
0
        return;
88
0
    }
89
90
0
    size_t pos = 0;
91
92
0
    for ( size_t i = 0;
93
0
        ( iMaxSplit == 0 || i < iMaxSplit ) && pos < iValue.size(); ++i )
94
0
    {
95
0
        size_t nextDotIndex = iValue.find('.', pos);
96
97
0
        if ( nextDotIndex == std::string::npos )
98
0
        {
99
0
            break;
100
0
        }
101
102
0
        oResult.push_back( iValue.substr( pos, nextDotIndex-pos ) );
103
104
0
        if ( nextDotIndex == iValue.size() - 1 )
105
0
        {
106
0
            oResult.push_back( "" );
107
0
        }
108
109
0
        pos = nextDotIndex + 1;
110
0
    }
111
112
0
    if ( pos < iValue.size() )
113
0
    {
114
0
        oResult.push_back( iValue.substr( pos ) );
115
0
    }
116
0
}
117
118
} // End namespace Util
119
} // End namespace ALEMBIC_VERSION_NS
120
} // End namespace AbcGeom
121
} // End namespace Alembic