Edit

kc3-lang/angle/src/common/string_utils.h

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2017-09-25 02:35:57
    Hash : 6276b922
    Message : Vulkan: Implement basic uniform shader parsing. This is a first step at implementing uniforms with descriptor sets. It does not actually bind uniforms and upload data, but it does implement uniform shader parsing. Uniforms are gathered into a single uniform block which is bound to set 0, with binding 0 for vertex uniforms and binding 1 for fragment uniforms. Also adds a ReplaceSubstring helper to string_utils. Also removes the precision writing from OutputVulkanGLSL since this was generating warnings with glslang. BUG=angleproject:2167 Change-Id: I9ec8351ec1973e583100f99292b0080ee968067b Reviewed-on: https://chromium-review.googlesource.com/699938 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>

  • src/common/string_utils.h
  • //
    // Copyright 2015 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    // string_utils:
    //   String helper functions.
    //
    
    #ifndef LIBANGLE_STRING_UTILS_H_
    #define LIBANGLE_STRING_UTILS_H_
    
    #include <string>
    #include <vector>
    
    #include "common/Optional.h"
    
    namespace angle
    {
    
    extern const char kWhitespaceASCII[];
    
    enum WhitespaceHandling
    {
        KEEP_WHITESPACE,
        TRIM_WHITESPACE,
    };
    
    enum SplitResult
    {
        SPLIT_WANT_ALL,
        SPLIT_WANT_NONEMPTY,
    };
    
    std::vector<std::string> SplitString(const std::string &input,
                                         const std::string &delimiters,
                                         WhitespaceHandling whitespace,
                                         SplitResult resultType);
    
    void SplitStringAlongWhitespace(const std::string &input,
                                    std::vector<std::string> *tokensOut);
    
    std::string TrimString(const std::string &input, const std::string &trimChars);
    
    bool HexStringToUInt(const std::string &input, unsigned int *uintOut);
    
    bool ReadFileToString(const std::string &path, std::string *stringOut);
    
    Optional<std::vector<wchar_t>> WidenString(size_t length, const char *cString);
    
    // Check if the string str begins with the given prefix.
    // Prefix may not be NULL and needs to be NULL terminated.
    // The comparison is case sensitive.
    bool BeginsWith(const std::string &str, const char *prefix);
    
    // Check if the string str begins with the given prefix.
    // str and prefix may not be NULL and need to be NULL terminated.
    // The comparison is case sensitive.
    bool BeginsWith(const char *str, const char *prefix);
    
    // Check if the string str ends with the given suffix.
    // Suffix may not be NUL and needs to be NULL terminated.
    // The comparison is case sensitive.
    bool EndsWith(const std::string& str, const char* suffix);
    
    // Convert to lower-case.
    void ToLower(std::string *str);
    
    // Replaces the substring 'substring' in 'str' with 'replacement'. Returns true if successful.
    bool ReplaceSubstring(std::string *str,
                          const std::string &substring,
                          const std::string &replacement);
    
    }  // namespace angle
    
    #endif // LIBANGLE_STRING_UTILS_H_