This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Juha Alanen
committed
Jun 10, 2019
1 parent
892699a
commit 7027e47
Showing
20 changed files
with
486 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <mbgl/style/expression/expression.hpp> | ||
#include <mbgl/style/expression/parsing_context.hpp> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
namespace expression { | ||
|
||
class NumberFormat final : public Expression { | ||
public: | ||
NumberFormat(std::unique_ptr<Expression> number_, | ||
optional<std::unique_ptr<Expression>> locale_, | ||
optional<std::unique_ptr<Expression>> currency_, | ||
optional<std::unique_ptr<Expression>> minFractionDigits_, | ||
optional<std::unique_ptr<Expression>> maxFractionDigits_); | ||
|
||
static ParseResult parse(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx); | ||
|
||
EvaluationResult evaluate(const EvaluationContext& params) const override; | ||
void eachChild(const std::function<void(const Expression&)>& visit) const override; | ||
bool operator==(const Expression& e) const override; | ||
std::vector<optional<Value>> possibleOutputs() const override; | ||
|
||
mbgl::Value serialize() const override; | ||
std::string getOperator() const override { return "number-format"; } | ||
|
||
private: | ||
std::unique_ptr<Expression> number; | ||
std::unique_ptr<Expression> locale; | ||
std::unique_ptr<Expression> currency; | ||
std::unique_ptr<Expression> minFractionDigits; | ||
std::unique_ptr<Expression> maxFractionDigits; | ||
}; | ||
|
||
} // namespace expression | ||
} // namespace style | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import QtQuick 2.0 | ||
|
||
Item { | ||
function formatNumber(number, localeId, currency, minFractionDigits, maxFractionDigits) { | ||
if (currency !== "undefined") { | ||
return Number(number).toLocaleCurrencyString(Qt.locale(localeId)) | ||
} else { | ||
return Number(number).toLocaleString(Qt.locale(localeId), 'f', maxFractionDigits) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.